« Return to Thread: typemaps in R

typemaps in R

by Bastian Angermann :: Rate this Message:

Reply to Author | View in Thread

Hi,

the typemaps for mapping unsigned int to an appropriate type in
R seem to be broken.
I am trying to wrap a class with constructor
Erdos_Renyi_Network(unsigned int ng, double af,double prob);
Calling network <- Erdos_Renyi_Network(ng=10,af=0.5,p=0.1) results in:
Error in Erdos_Renyi_Network(ng = 10, af = 0.5, p = 0.1) :
  REAL() can only be applied to a 'numeric', not a 'integer'


Reviewing the output generated by SWIG reveals that the unsigned int argument is cast into an "integer":
  ng = as(ng, "integer");
but the C++ code calls:
        arg1 = static_cast< unsigned int >(REAL(ng)[0]);
for the same argument.

Could this be fixed by changing line 45,46 in rtypes.swg to
%typemap(scoercein) unsigned int, unsigned int *, unsigned int &
  %{  $input = as($input, "numeric");     %} ?
This removes be cast to "integer" done in R and things seem to work, but I don't know if I am introducing other bugs by this "fix".

Any comments would be appreciated,
Bastian

I am using the SVN revision 10421 of SWIG and R version 2.7.0.
--
GMX startet ShortView.de. Hier findest Du Leute mit Deinen Interessen!
Jetzt dabei sein: http://www.shortview.de/?mc=sv_ext_mf@gmx

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user

 « Return to Thread: typemaps in R

LightInTheBox - Buy quality products at wholesale price