thk686 / odeintr

An R package for integrating differential equations in C++
18 stars 2 forks source link

Unable to get simple example to work and don't know where to start #3

Closed ghost closed 8 years ago

ghost commented 8 years ago

Hi there,

I am unable to get the simplest odeintr example to work, and don't know where to start to fix it.

If I run compile_sys("logistic", "dxdt = x * (1 - x)") system.time({x = logistic(0.001, 15, 0.01)})

I get a huge reel of errors, starting with

compile_sys("logistic", "dxdt = x * (1 - x)") clang++ -std=c++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.2/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.2/Resources/library/BH/include" -I"/private/var/folders/cz/2dkzgssx7_x57b40072gp2gc0000gn/T/RtmpvlQ69x" -I"/Library/Frameworks/R.framework/Versions/3.2/Resources/library/Rcpp/include" -fPIC -Wall -mtune=core2 -g -O2 -c file104252f0376b1.cpp -o file104252f0376b1.o file104252f0376b1.cpp:18:16: error: too few template arguments for class template 'array' typedef std::array state_type; ^ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/array:121:30: note: template is declared here struct _LIBCPP_TYPE_VIS_ONLY array ^ file104252f0376b1.cpp:37:9: error: subscripted value is not an array, pointer, or vector dxdt[0] = x[0] * (1 - x[0]);

and ending with

/usr/local/include/boost/range/begin.hpp:106:61: note: candidate template ignored: substitution failure [with T = int]: no type named 'type' in 'boost::range_iterator<const int, void>' inline BOOST_DEDUCED_TYPENAME range_iterator::type begin( const T& r )


1 warning and 18 errors generated.
make: **\* [file104252f0376b1.o] Error 1

I can run 
sourceCpp(code='
  #include <Rcpp.h>
  // [[Rcpp::export]]
  int fibonacci(const int x) {
    if (x == 0) return(0);
    if (x == 1) return(1);
    return (fibonacci(x - 1)) + fibonacci(x - 2);
  }'
)

fine, and I've been testing out other Rcpp examples which work okay as well. I've tried it on my laptop too and get the same errors. 

Thanks. 
thk686 commented 8 years ago

That's a bug in the code. However I believe it is fixed in the development version. Can you please install from github and try again? Thanks.

ghost commented 8 years ago

That looks better, thanks. The same code runs with 6 warnings - screenshot attached.

screen shot 2016-06-06 at 09 47 50

thk686 commented 8 years ago

All of those warnings come from Boost odeint when compiled with clang. Gcc does not produce any warnings.

THK

On Mon, Jun 6, 2016 at 3:50 AM, ellen12345 notifications@github.com wrote:

That looks better, thanks. The same code runs with 6 warnings - screenshot attached.

[image: screen shot 2016-06-06 at 09 47 50] https://cloud.githubusercontent.com/assets/19689441/15816695/e23ba990-2bcb-11e6-88ec-0c3ba637a962.png

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/thk686/odeintr/issues/3#issuecomment-223902024, or mute the thread https://github.com/notifications/unsubscribe/AAkLyW4_7azaWKNyqM2O67U7oNahDDjAks5qI99OgaJpZM4Irm4F .