|
View:
New views
13 Messages
—
Rating Filter:
Alert me
|
|
|
SWIG newbie questions: R SWIG errors or warnings? is R SWIG functional?Doing:
swig -c++ -v -r -o simpletest_wrap.cpp simpletest.i PKG_LIBS="simpletest.cpp" R CMD SHLIB simpletest_wrap.cpp yields the following reports simpletest_wrap.cpp:725:2: warning: #warning "R Swig currently fails on runtime for 2.6 and higher." simpletest_wrap.cpp:726:2: warning: #warning "Contact maintainer if you would like to help fix" Does this mean that R SWIG is not really functional yet? My hope was to implement a simulation template class in C++ and construct wrappers with SWIG for R and octave to plot things and compile output, but I'm no longer confident that it is possible. To make this worthwhile I would need to be able to: 1) instantiate wrapped c++ data (parameter) classes from R/octave. Wrapped constructors take vector arguments. 2) instantiate wrapped c++ simulation class from R/octave. Wrapped constructors take wrapped class instances (from 1) as arguments. 3) call simulation class member functions from R/octave (i.e. simulation.run and simulation.output type things). Is what I'm describing possible to do without major pains? Would it be way easier with SWIG python? Any feedback is greatly appreciated ... at this point I'm just about ready to do the read/write to text file solution or write a wrapper for R, I've already spent way too long fiddling with SWIG. david // simpletest.i %module simpletest %{ #include "./simpletest.cpp" %} %include "./simpletest.cpp" %template(something3) something<3>; // this *is* a 3 (I am templating on a spatial dimension d=1,2,3) // simpletest.cpp //#include "/usr/include/boost/numeric/ublas/vector.hpp" #include <boost/numeric/ublas/vector.hpp> #include <boost/numeric/ublas/io.hpp> #include <iostream> // this is the line which causes problems: //namespace boost {namespace numeric {namespace ublas {}}} //using namespace boost::numeric::ublas; template<int d> class something { double thingy; boost::numeric::ublas::vector<int> a; public: something(): a(3){ a(1)=1; a(3)=3; a(4)=2; info(); } void info(){ std::cout << a; } }; -- David Cottrell http://www.math.mcgill.ca/~cottrell ------------------------------------------------------------------------- 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 |
|
|
Re: SWIG newbie questions: R SWIG errors or warnings? is R SWIG functional?On Tue, 2008-04-22 at 10:44 -0400, David Cottrell wrote:
> Doing: > > swig -c++ -v -r -o simpletest_wrap.cpp simpletest.i > PKG_LIBS="simpletest.cpp" R CMD SHLIB simpletest_wrap.cpp I guess you use swig 1.3.34 and R2.6? Try swig 1.3.35 then! > yields the following reports > > simpletest_wrap.cpp:725:2: warning: #warning "R Swig currently fails on > runtime for 2.6 and higher." > simpletest_wrap.cpp:726:2: warning: #warning "Contact maintainer if you > would like to help fix" > > Does this mean that R SWIG is not really functional yet? YMMV.... > My hope was to implement a simulation template class in C++ and > construct wrappers with SWIG for R and octave to plot things and compile > output, but I'm no longer confident that it is possible. > > To make this worthwhile I would need to be able to: > > 1) instantiate wrapped c++ data (parameter) classes from R/octave. > Wrapped constructors take vector arguments. > > 2) instantiate wrapped c++ simulation class from R/octave. Wrapped > constructors take wrapped class instances (from 1) as arguments. > > 3) call simulation class member functions from R/octave (i.e. > simulation.run and simulation.output type things). > > Is what I'm describing possible to do without major pains? Would it be > way easier with SWIG python? > > Any feedback is greatly appreciated ... at this point I'm just about > ready to do the read/write to text file solution or write a wrapper for > R, I've already spent way too long fiddling with SWIG. my experience so far is that swig + python & octave work nicely... I was not successful with R, but just try it out ... I would be interested in learning whether it works for you (or someone). > david > > > // simpletest.i > %module simpletest > > %{ > #include "./simpletest.cpp" > %} > > %include "./simpletest.cpp" > > %template(something3) something<3>; // this *is* a 3 (I am templating on > a spatial dimension d=1,2,3) > > > > // simpletest.cpp > //#include "/usr/include/boost/numeric/ublas/vector.hpp" > #include <boost/numeric/ublas/vector.hpp> > #include <boost/numeric/ublas/io.hpp> > #include <iostream> > > // this is the line which causes problems: > //namespace boost {namespace numeric {namespace ublas {}}} > //using namespace boost::numeric::ublas; > > template<int d> class something { > double thingy; > boost::numeric::ublas::vector<int> a; > public: > something(): a(3){ > a(1)=1; > a(3)=3; > a(4)=2; > info(); > } > void info(){ > std::cout << a; > } > > }; Soeren ------------------------------------------------------------------------- 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 |
|
|
Re: SWIG newbie questions: R SWIG errors or warnings? is R SWIG functional?Soeren Sonnenburg wrote:
> On Tue, 2008-04-22 at 10:44 -0400, David Cottrell wrote: > > Doing: > > > > swig -c++ -v -r -o simpletest_wrap.cpp simpletest.i > > PKG_LIBS="simpletest.cpp" R CMD SHLIB simpletest_wrap.cpp > > I guess you use swig 1.3.34 and R2.6? Try swig 1.3.35 then! > > > yields the following reports > > > > simpletest_wrap.cpp:725:2: warning: #warning "R Swig currently fails on > > runtime for 2.6 and higher." > > simpletest_wrap.cpp:726:2: warning: #warning "Contact maintainer if you > > would like to help fix" > > > > Does this mean that R SWIG is not really functional yet? > > YMMV.... > my experience so far is that swig + python & octave work nicely... I was > not successful with R, but just try it out ... I would be interested in > learning whether it works for you (or someone). > SWIG works fine with R <= 2.6, most of the test-suite works well. Not sure about 2.7, they seem to knock out new versions of R rather quickly and there were some non-backwards compatible changes going from 2.5 to 2.6. William ------------------------------------------------------------------------- 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 |
|
|
Re: SWIG newbie questions: R SWIG errors or warnings? is R SWIG functional?On Thu, 2008-04-24 at 22:50 +0100, William S Fulton wrote:
> Soeren Sonnenburg wrote: > > On Tue, 2008-04-22 at 10:44 -0400, David Cottrell wrote: > > > Doing: > > > > > > swig -c++ -v -r -o simpletest_wrap.cpp simpletest.i > > > PKG_LIBS="simpletest.cpp" R CMD SHLIB simpletest_wrap.cpp > > > > I guess you use swig 1.3.34 and R2.6? Try swig 1.3.35 then! > > > > > yields the following reports > > > > > > simpletest_wrap.cpp:725:2: warning: #warning "R Swig currently fails on > > > runtime for 2.6 and higher." > > > simpletest_wrap.cpp:726:2: warning: #warning "Contact maintainer if you > > > would like to help fix" > > > > > > Does this mean that R SWIG is not really functional yet? > > > > YMMV.... > ... > > my experience so far is that swig + python & octave work nicely... I was > > not successful with R, but just try it out ... I would be interested in > > learning whether it works for you (or someone). > > > SWIG works fine with R <= 2.6, most of the test-suite works well. Not > sure about 2.7, they seem to knock out new versions of R rather quickly > and there were some non-backwards compatible changes going from 2.5 to 2.6. Except for - Checking testcase constants under r - Checking testcase cpp_broken under r - Checking testcase namespace_union under r - Checking testcase nested_comment under r - Checking testcase template_default_pointer under r - Checking testcase template_expr under r all tests run through on R 2.7 too (swig-svn version, my patch applied). Regarding the changes from R2.5->2.7 the RVERSION25/26/27 makro taking care of this only changes the way how strings are created - a one liner change - I don't think that this will break anything. But still R 2.7. is now the current stable which Rswig doesn't support. However R & swig did not work for me (already crashing when only loading the libs) but it might be that this is a bug in R 2.7... I am still investigating... Soeren ------------------------------------------------------------------------- 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 |
|
|
Re: SWIG newbie questions: R SWIG errors or warnings? is R SWIG functional?On Fri, 2008-04-25 at 08:50 +0200, Soeren Sonnenburg wrote:
> On Thu, 2008-04-24 at 22:50 +0100, William S Fulton wrote: > > Soeren Sonnenburg wrote: > > > On Tue, 2008-04-22 at 10:44 -0400, David Cottrell wrote: > > > > Doing: > > > > > > > > swig -c++ -v -r -o simpletest_wrap.cpp simpletest.i > > > > PKG_LIBS="simpletest.cpp" R CMD SHLIB simpletest_wrap.cpp > > > > > > I guess you use swig 1.3.34 and R2.6? Try swig 1.3.35 then! > > > > > > > yields the following reports > > > > > > > > simpletest_wrap.cpp:725:2: warning: #warning "R Swig currently fails on > > > > runtime for 2.6 and higher." > > > > simpletest_wrap.cpp:726:2: warning: #warning "Contact maintainer if you > > > > would like to help fix" > > > > > > > > Does this mean that R SWIG is not really functional yet? > > > > > > YMMV.... > > ... > > > my experience so far is that swig + python & octave work nicely... I was > > > not successful with R, but just try it out ... I would be interested in > > > learning whether it works for you (or someone). > > > > > SWIG works fine with R <= 2.6, most of the test-suite works well. Not > > sure about 2.7, they seem to knock out new versions of R rather quickly > > and there were some non-backwards compatible changes going from 2.5 to 2.6. > > Except for > > - Checking testcase constants under r > - Checking testcase cpp_broken under r > - Checking testcase namespace_union under r > - Checking testcase nested_comment under r > - Checking testcase template_default_pointer under r > - Checking testcase template_expr under r > > all tests run through on R 2.7 too (swig-svn version, my patch applied). > Regarding the changes from R2.5->2.7 the RVERSION25/26/27 makro taking > care of this only changes the way how strings are created - a one liner > change - I don't think that this will break anything. > > But still R 2.7. is now the current stable which Rswig doesn't support. > > However R & swig did not work for me (already crashing when only loading > the libs) but it might be that this is a bug in R 2.7... I am still > investigating... OK, after investigating for some time: There was actually not only a bug in SWIG but in R 2.7 (and still is - long input lines cause it to crash, solution posted to Rd mailinglist). Which means R+swig works in principle. However there are definitely a couple of (minor/easily fixable) bugs in the R wrapper that need further fixes before shogun ( http://www.shogun-toolbox.org ) fully works: 1) the dispatcher (called when an object is constructed) wrongly calls extends(argtypes[1], 'numeric')) which will never be true for a matrix (some magic is needed here). Workaround for now is to not use RealFeatures(my_matrix), but rf=RealFeatures() rf$copy_feature_matrix(rf, my_matrix) 2) arguments that take a double* will all be modified via as.numeric(arg) which converts matrices -> vectors. IMHO it does not make sense to do any conversion at all but for compatibility a workaround for now is to use %{ if (!is.numeric($input)) $input = as.numeric($input) %} in the scoercein typemap in rtype.swg 3) the R2.7 swig mkCharEnc fix (patch submitted here on the ml) Soeren ------------------------------------------------------------------------- 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 |
|
|
Re: SWIG newbie questions: R SWIG errors or warnings? is R SWIG functional?Thanks. I've noticed the R 2.7 release and checked in some fixes before I
checked my e-mail this evenining. I'll try to get the patches in place in the next few days. R 2.7 seems to pass all the regression tests except for the function pointer one, and I got it to work with QuantLib. On Friday 25 April 2008 12:40:21 pm Soeren Sonnenburg wrote: > OK, after investigating for some time: > > There was actually not only a bug in SWIG but in R 2.7 (and still is - > long input lines cause it to crash, solution posted to Rd mailinglist). > Which means R+swig works in principle. However there are definitely a > couple of (minor/easily fixable) bugs in the R wrapper that need further > fixes before shogun ( http://www.shogun-toolbox.org ) fully works: > > 1) the dispatcher (called when an object is constructed) wrongly calls > extends(argtypes[1], 'numeric')) which will never be true for > a matrix (some magic is needed here). > Workaround for now is to not use > RealFeatures(my_matrix), but > rf=RealFeatures() > rf$copy_feature_matrix(rf, my_matrix) > 2) arguments that take a double* will all be modified via > as.numeric(arg) which converts matrices -> vectors. IMHO it > does not make sense to do any conversion > at all but for compatibility a workaround for now is to use > %{ if (!is.numeric($input)) $input = as.numeric($input) %} > in the scoercein typemap in rtype.swg > 3) the R2.7 swig mkCharEnc fix (patch submitted here on the ml) > > Soeren ------------------------------------------------------------------------- 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 |
|
|
Re: SWIG newbie questions: R SWIG errors or warnings? is R SWIG functional?On Sat, 2008-04-26 at 04:13 -0400, Joseph Wang wrote:
Hi Joseph, > Thanks. I've noticed the R 2.7 release and checked in some fixes before I > checked my e-mail this evenining. I'll try to get the patches in place in Yes I get some conflicts now - I am fine to not have an extra case for R2.6 :) > the next few days. R 2.7 seems to pass all the regression tests except for > the function pointer one, and I got it to work with QuantLib. What about the other two problems I am seeing? Why can't we get rid of the scorecein typemap in rtype.swg at all? I mean it is bad if things get converted to numeric (or so) although there is a magic (user written!) typemap doing the work. I still don't understand why ther should be any conversion at all... wrong type -> sorry wrong type error no? Also what about the dispatcher? Any ideas on how to better check if two types are compatible (extends seems not be the right thing for numeric types)... Soeren > On Friday 25 April 2008 12:40:21 pm Soeren Sonnenburg wrote: > > > OK, after investigating for some time: > > > > There was actually not only a bug in SWIG but in R 2.7 (and still is - > > long input lines cause it to crash, solution posted to Rd mailinglist). > > Which means R+swig works in principle. However there are definitely a > > couple of (minor/easily fixable) bugs in the R wrapper that need further > > fixes before shogun ( http://www.shogun-toolbox.org ) fully works: > > > > 1) the dispatcher (called when an object is constructed) wrongly calls > > extends(argtypes[1], 'numeric')) which will never be true for > > a matrix (some magic is needed here). > > Workaround for now is to not use > > RealFeatures(my_matrix), but > > rf=RealFeatures() > > rf$copy_feature_matrix(rf, my_matrix) > > 2) arguments that take a double* will all be modified via > > as.numeric(arg) which converts matrices -> vectors. IMHO it > > does not make sense to do any conversion > > at all but for compatibility a workaround for now is to use > > %{ if (!is.numeric($input)) $input = as.numeric($input) %} > > in the scoercein typemap in rtype.swg > > 3) the R2.7 swig mkCharEnc fix (patch submitted here on the ml) > > > > Soeren > > ------------------------------------------------------------------------- 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 |
|
|
Re: SWIG newbie questions: R SWIG errors or warnings? is R SWIG functional?On Saturday 26 April 2008 04:57:26 am Soeren Sonnenburg wrote:
> What about the other two problems I am seeing? Why can't we get rid of > the scorecein typemap in rtype.swg at all? I mean it is bad if things > get converted to numeric (or so) although there is a magic (user > written!) typemap doing the work. I still don't understand why ther > should be any conversion at all... A lot of R-Swig was written with trial and error. I just removed the scorecein typemaps for integers and floats, and the regression tests ran fine as did my quantlib scripts. So I just commented them out. > Also what about the dispatcher? Any ideas on how to better check if two > types are compatible (extends seems not be the right thing for numeric > types)... No ideas, but I'm interested in anything anyone else can think of..... ------------------------------------------------------------------------- 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 |
|
|
Re: SWIG newbie questions: R SWIG errors or warnings? is R SWIG functional?On Sat, 2008-04-26 at 15:43 -0400, Joseph Wang wrote:
> On Saturday 26 April 2008 04:57:26 am Soeren Sonnenburg wrote: > > What about the other two problems I am seeing? Why can't we get rid of > > the scorecein typemap in rtype.swg at all? I mean it is bad if things > > get converted to numeric (or so) although there is a magic (user > > written!) typemap doing the work. I still don't understand why ther > > should be any conversion at all... > > A lot of R-Swig was written with trial and error. I just removed the > scorecein typemaps for integers and floats, and the regression tests ran fine > as did my quantlib scripts. So I just commented them out. Because now on swig-svn still any matrix is converted to a vector due to these scoerecein typemaps. I just removed them (see attached patch) and the tests still run through and now also in my project ( shogun ) copy_matrix / get_fm (matrix in/out) work. > > Also what about the dispatcher? Any ideas on how to better check if two > > types are compatible (extends seems not be the right thing for numeric > > types)... > > No ideas, but I'm interested in anything anyone else can think of..... We could make an exception for the numeric type, like instead of asking for extends(x,'numeric') we ask is.numeric(x) ? That would be sufficient... Soeren [rtype.diff] Index: Lib/r/rtype.swg =================================================================== --- Lib/r/rtype.swg (revision 10394) +++ Lib/r/rtype.swg (working copy) @@ -36,6 +36,7 @@ */ +/* %typemap(scoercein) int, int *, int & %{ $input = as($input, "integer"); %} %typemap(scoercein) ptrdiff_t, ptrdiff_t *, ptrdiff_t & @@ -78,11 +79,9 @@ %} -/* **************************************************************** */ %typemap(scoercein) bool, bool *, bool & "$input = as.logical($input) "; -/* %typemap(scoercein) int, int *, int &, @@ -119,11 +118,11 @@ long*, long long * %{ $input = as.numeric($input) %} -*/ %typemap(scoercein) char *, string, std::string, string &, std::string & %{ $input = as($input, "character") %} +*/ %typemap(scoerceout) enum SWIGTYPE %{ $result = enumFromInteger($result, "$R_class") %} ------------------------------------------------------------------------- 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 |
|
|
Re: SWIG newbie questions: R SWIG errors or warnings? is R SWIG functional?On Sat, 2008-04-26 at 15:43 -0400, Joseph Wang wrote:
> On Saturday 26 April 2008 04:57:26 am Soeren Sonnenburg wrote: [...] > > Also what about the dispatcher? Any ideas on how to better check if two > > types are compatible (extends seems not be the right thing for numeric > > types)... > > No ideas, but I'm interested in anything anyone else can think of..... OK, I came up with a patch that solves this problem (for me): I save the args in a argv list and if use is.numeric(argv[[1]]) for numeric types ... Another issue I've noticed is with 'garbage collection': There seems to be a problem when I use %feature("ref") and %feature("unref"), could it be a problem that the C++ functions I've bound to this are named ref() and unref()? Soeren [r_cxx.diff] Index: Source/Modules/r.cxx =================================================================== --- Source/Modules/r.cxx (revision 10394) +++ Source/Modules/r.cxx (working copy) @@ -1604,6 +1604,7 @@ int nfunc = Len(dispatch); Printv(f->code, "argtypes <- mapply(class, list(...))\n", + "argv <- list(...)\n", "argc <- length(argtypes)\n", NIL ); Printf(f->code, "# dispatch functions %d\n", nfunc); @@ -1637,10 +1638,17 @@ if(tm) { replaceRClass(tm, Getattr(p, "type")); } + if (DohStrcmp(tm,"numeric")==0) { + Printf(f->code, "%sis.numeric(argv[[%d]])", + j == 0 ? "" : " && ", + j+1); + } + else { Printf(f->code, "%sextends(argtypes[%d], '%s')", j == 0 ? "" : " && ", j+1, tm); + } p = Getattr(p, "tmap:in:next"); } Printf(f->code, ") { f <- %s%s }\n", sfname, overname); ------------------------------------------------------------------------- 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 |
|
|
Re: SWIG newbie questions: R SWIG errors or warnings? is R SWIG functional?On Sunday 27 April 2008 01:24:58 am Soeren Sonnenburg wrote:
About scoercein, I commented them in the Lib/r files which means that it won't emit any of the coercion code. > OK, I came up with a patch that solves this problem (for me): > > I save the args in a argv list and if use is.numeric(argv[[1]]) for > numeric types ... The patch you put in doesn't seem to break any of the regression tests or my QuantLib demos, so I've checked it into trunk. > Another issue I've noticed is with 'garbage collection': There seems to > be a problem when I use > > %feature("ref") and %feature("unref"), could it be a problem that the > C++ functions I've bound to this are named ref() and unref()? What's the exact nature of the problem? I haven't much work with making sure that memory management works correctly so there might be a lot of things that are broken. ------------------------------------------------------------------------- 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 |
|
|
Re: SWIG newbie questions: R SWIG errors or warnings? is R SWIG functional?On Sun, 2008-04-27 at 14:29 -0400, Joseph Wang wrote:
> On Sunday 27 April 2008 01:24:58 am Soeren Sonnenburg wrote: > > About scoercein, I commented them in the Lib/r files which means that it won't > emit any of the coercion code. OK, for shogun I will start porting all the examples I have for octave/python to R. And play around a bit. Lets see whether I notice a problem (should be of minor nature anyway, worst that could happen is that something has to be recast to be numeric :) > > OK, I came up with a patch that solves this problem (for me): > > > > I save the args in a argv list and if use is.numeric(argv[[1]]) for > > numeric types ... > > The patch you put in doesn't seem to break any of the regression tests or my > QuantLib demos, so I've checked it into trunk. Yeah that shouldn't do any harm. > > Another issue I've noticed is with 'garbage collection': There seems to > > be a problem when I use > > > > %feature("ref") and %feature("unref"), could it be a problem that the > > C++ functions I've bound to this are named ref() and unref()? > > What's the exact nature of the problem? I haven't much work with making sure > that memory management works correctly so there might be a lot of things that > are broken. Well I've noticed a double free when running a toy example while ref/unref were used (these work in octave/python)... so I guess something is not inc_ref'd or dec_ref'd twice... Anyway this is (for now) the least important thing. Anyway if both quantlib and shogun work using swig then Rswig has some serious+big enough applications and the regression tests are complex enough such that one could actually recommend it... Thanks for your help, I will ping back when I discover an issue (apart from ref/unref). Soeren ------------------------------------------------------------------------- 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 |
|
|
Re: SWIG newbie questions: R SWIG errors or warnings? is R SWIG functional?On Sun, 2008-04-27 at 14:29 -0400, Joseph Wang wrote:
> On Sunday 27 April 2008 01:24:58 am Soeren Sonnenburg wrote: Hi Joseph, I've now managed to get all examples from octave/python ported to R, however I needed some tiny adjustment to rtype.swg get them to work (see attached patch). > About scoercein, I commented them in the Lib/r files which means that it won't > emit any of the coercion code. This seems not enough, as as($input, "numeric") is still turning the matrix into a flat vector. Simply commenting removing the $input = as($input, "numeric"); command from scoercein makes things work for me. Another issue I stumbled accross: I have some typemap working on a templated structure, which is correctly wrapped by R. However again the call to function tries to do a coercion where none is necessary. The fix here was again to remove all the SWIGTYPE, SWIGTYPE*, SWIGTYPE& coerceIfNotSubclass calls. I've ran the whole testsuite and still every example (except for one that didn't compile) works fine :-) So please try with quantlib and apply or fix and apply :) > > Another issue I've noticed is with 'garbage collection': There seems to > > be a problem when I use > > > > %feature("ref") and %feature("unref"), could it be a problem that the > > C++ functions I've bound to this are named ref() and unref()? > > What's the exact nature of the problem? I haven't much work with making sure > that memory management works correctly so there might be a lot of things that > are broken. I am for now ignoring garbage collection. What I still don't understand is the ref warning I am getting (even though I have my ref/unref code commented out): > x=LDA() > x An object of class "_p_CLDA" Slot "ref": Error in slot(object, what) : no slot of name "ref" for this object of class "_p_CLDA" > where is that ref coming from? And what should it be? Is this about reference counting? I am not sure what I should do to get rid of this... any ideas? Soeren [rtype.diff] Index: Lib/r/rtype.swg =================================================================== --- Lib/r/rtype.swg (revision 10412) +++ Lib/r/rtype.swg (working copy) @@ -45,9 +45,9 @@ %typemap(scoercein) unsigned int, unsigned int *, unsigned int & %{ $input = as($input, "integer"); %} %typemap(scoercein) double, double *, double & - %{ $input = as($input, "numeric"); %} + %{ %} %typemap(scoercein) float, float *, float & - %{ $input = as($input, "numeric"); %} + %{ %} %typemap(scoercein) char, char *, char & %{ $input = as($input, "character"); %} %typemap(scoercein) string, string *, string & @@ -61,7 +61,10 @@ %typemap(scoercein) enum SWIGTYPE * %{ $input = enumToInteger($input, "$R_class") %} -%typemap(scoercein) SWIGTYPE * +%typemap(scoercein) SWIGTYPE, SWIGTYPE *, SWIGTYPE & + %{ %} + +/*%typemap(scoercein) SWIGTYPE* %{ $input = coerceIfNotSubclass($input, "$R_class") %} %typemap(scoercein) SWIGTYPE & @@ -69,7 +72,7 @@ %typemap(scoercein) SWIGTYPE %{ $input = coerceIfNotSubclass($input, "$&R_class") %} - +*/ %typemap(scoercein) SWIGTYPE[ANY] %{ ------------------------------------------------------------------------- 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 |
| Free Forum Powered by Nabble | Forum Help |