Skip to content

Commit

Permalink
define rtypecheck in the R SWIG typemaps
Browse files Browse the repository at this point in the history
this fixes all the limitations of passing a matrix or a vector
as a function argument longer than 1
  • Loading branch information
vigsterkr committed Jan 19, 2018
1 parent 9d2e76e commit a4c84ee
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/interfaces/r/swig_typemaps.i
Expand Up @@ -42,6 +42,9 @@ extern "C" {
$1 = (TYPEOF($input) == r_type && Rf_ncols($input)==1 ) ? 1 : 0;
}

%typemap("rtypecheck") shogun::SGVector<sg_type>
%{ is.numeric($arg) %}

%typemap(in) shogun::SGVector<sg_type>
{
SEXP rvec=$input;
Expand Down Expand Up @@ -101,6 +104,9 @@ TYPEMAP_OUT_SGVECTOR(INTSXP, INTEGER, "integer", uint16_t, int, "Word")
$1 = (TYPEOF($input) == r_type) ? 1 : 0;
}

%typemap("rtypecheck") shogun::SGMatrix<sg_type>
%{ is.numeric($arg) %}

%typemap(in) shogun::SGMatrix<sg_type>
{
if( TYPEOF($input) != r_type)
Expand Down

0 comments on commit a4c84ee

Please sign in to comment.