Hi Dirk,<br><br>I was referring to this page: <a href="http://dirk.eddelbuettel.com/code/rcpp.armadillo.html" target="_blank">http://dirk.eddelbuettel.com/code/rcpp.armadillo.html</a><br>i was trying to run the code there.<br>
<br>here is my understanding so far (im new to linux and c++ so i apologize for seeming rather slow!):<br>
1. The Rcpp package helps C++ and R recognize each others stuff (like variables). <br><br>2. The RcppArmadillo package extends this functionality to objects used in armadillo (such as matrices and vectors e.g. colvec). <br>
<br>3. In FastLM, armadillo is being included but not RcppArmadillo. but that is ok because there is a loop in there which converts an vector as defined in armadillo to one which Rcpp recognizes. And it is this vector which which gets passed back to R through the Rcpp interface. also, it uses cfunction which is different from what im doing here as i think you mentioned earlier (it worked by the way!)<br>
<br>what i tried to do was as follows:<br>a) to run the code as in the link above and include Rcpp and RcppArmadillo and I was getting the errors as described in my initial post. <br>b) then i tried the same code but only including Rcpp and armadillo. <br>
<br>if my reasoning above is correct, part (b) should not run as Rcpp would not recognize stuff like arma::colvec. but, i get the exact same error as above! <br><br>so that suggests, that while compiling the code, the compiler is not even getting to the point in procedure b when it should encounters an type it doesnt recognize. which means that somehow, armadillo is giving problems. but that is as far as i can understand. either that or my understanding is way off.<br>
<br>appreciate your patience and help!<br>abhisek<br><br><br>
<br><div class="gmail_quote">On Fri, Mar 26, 2010 at 4:20 PM, Dirk Eddelbuettel <span dir="ltr"><<a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><br>
On 26 March 2010 at 15:32, Abhisek wrote:<br>
| Hi Dirk,<br>
|<br>
| Just so that I understand. I copied the code in the RcppArmadillo section<br>
| on your website and pasted and saved it.<br>
<br>
</div>What code? What page?<br>
<div><br>
| Are you saying I should change<br>
| #include <RcppArmadillo> to #include <Rcpp> and #include <armadillo> ?<br>
<br>
</div>No that is not what I said. I said<br>
<div><br>
You can't just look at FastLM() and think your code will run like it.<br>
RcppArmadillo __does not export its classes__. It is an implementation<br>
reference -- it gives you guidance as to how to implement C++ packages of<br>
your own against other libraries.<br>
<br>
If you "just" want to use Armadillo and have Rcpp help you, look at the<br>
installed example 'FastLM' in the Rcpp package. In other words ignore<br>
RcppArmadillo for now.<br>
<br>
</div>So look at /usr/local/lib/Rcpp/examples/FastLM/ and the files there. Run<br>
<br>
fastLMviaArmadillo.r<br>
<br>
and look at it. That should work.<br>
<br>
You can also look at the _entire RcppArmadillo package_ and see how the<br>
pieces fit together, including src/Makevars.<br>
<br>
But don't just take semi-random shortcuts and expect that to work. If we<br>
could make it any simpler, we would. There is a reason RcppArmadilli is<br>
package and not just a file.<br>
<font color="#888888"><br>
Dirk<br>
</font><div><div></div><div><br>
| best,<br>
| abhisek<br>
|<br>
| On Fri, Mar 26, 2010 at 1:40 PM, Dirk Eddelbuettel <<a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a>> wrote:<br>
|<br>
| ><br>
| > Hi Abhisek,<br>
| ><br>
| > On 26 March 2010 at 12:28, Abhisek wrote:<br>
| > | I downloaded the stuff just last friday so it should be the latest<br>
| > version<br>
| > | of Rcpp as well as Armadillo. I used install.packages() for Rcpp and<br>
| > | RcppArmadillo. Armadillo is 0.9.4. Im using xubuntu karmic koala.<br>
| ><br>
| > Ok, that is all good. And if RcppArmadillo installed you have proper<br>
| > libraries, Armadillo included.<br>
| ><br>
| > I think part of your problem is a misunderstanding of an issue we may not<br>
| > have made particularly clear: You can't just look at FastLM() and think<br>
| > your code will run like it. RcppArmadillo __does not export its classes__.<br>
| > It is an implementation reference -- it gives you guidance as to how to<br>
| > implement C++ packages of your own against other libraries.<br>
| ><br>
| > If you "just" want to use Armadillo and have Rcpp help you, look at the<br>
| > installed example 'FastLM' in the Rcpp package. In other words ignore<br>
| > RcppArmadillo for now.<br>
| ><br>
| > The example (in 0.7.10) uses an idiom we no longer like and I am about to<br>
| > change that for an upcoming 0.7.11 release, but it should works as is and<br>
| > just use inline -- so no messing with makefile etc.<br>
| ><br>
| > Try that and see how it goes and keep us posted.<br>
| ><br>
| > Cheers, Dirk<br>
| ><br>
| ><br>
| > | i also had some problem using Armadillo which I posted on the Armadillo<br>
| > | discussion board. Conrad got back to me. Here is the discussion:<br>
| > | <a href="https://sourceforge.net/apps/phpbb/arma/viewtopic.php?f=1&t=4" target="_blank">https://sourceforge.net/apps/phpbb/arma/viewtopic.php?f=1&t=4</a><br>
| > |<br>
| > | so it may be that armadillo is the problem but im really not sure.<br>
| > |<br>
| > | Many thanks<br>
| > | Abhisek<br>
| > |<br>
| > | On Fri, Mar 26, 2010 at 12:17 PM, Dirk Eddelbuettel <<a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a>><br>
| > wrote:<br>
| > |<br>
| > | ><br>
| > | > (resending, this time to list I omitted last time, sorry. --Dirk)<br>
| > | ><br>
| > | > On 26 March 2010 at 11:10, Abhisek wrote:<br>
| > | > | Hi,<br>
| > | > |<br>
| > | > | Ive been trying to make RcppArmadillo work using the example file<br>
| > | > (fastLM).<br>
| > | > | I copied and pasted the code and saved it as RcppArmadilloEg.cpp (not<br>
| > to<br>
| > | > use<br>
| > | > | fastLM but to figure out how to work RcppArmadillo). Then i tried<br>
| > using<br>
| > | > the<br>
| > | > | command R CMD SHLIB RcppArmadilloEg.cpp but an error came up saying<br>
| > that<br>
| > | > | RcppArmadillo.h not found.<br>
| > | > |<br>
| > | > | So i tried doing a symbolic link from /usr/local/include to the<br>
| > directory<br>
| > | > | where RcppArmadillo.h and RcppArmadilloDefines.h is stored. I also<br>
| > did a<br>
| > | > | symbolic link analogously for RcppArmadillo.so. When i ran R CMD<br>
| > SHLIB<br>
| > | > | again I got the following error:<br>
| > | > |<br>
| > | > | abhisek@shieks:~/Desktop/Personal/Test$ R CMD SHLIB<br>
| > RcppArmadilloEg.cpp<br>
| > | > | g++ -I/usr/share/R/include<br>
| > | > | -I/home/abhisek/R/i486-pc-linux-gnu-library/2.10/Rcpp/lib -fpic -g<br>
| > -O2<br>
| > | > -c<br>
| > | > | RcppArmadilloEg.cpp -o RcppArmadilloEg.o<br>
| > | ><br>
| > | > So far so good: one -I for R as usual, one for Rcpp.<br>
| > | ><br>
| > | > | In file included from<br>
| > | > |<br>
| > /home/abhisek/R/i486-pc-linux-gnu-library/2.10/Rcpp/lib/RcppCommon.h:215,<br>
| > | > | from<br>
| > | > | /home/abhisek/R/i486-pc-linux-gnu-library/2.10/Rcpp/lib/Rcpp.h:28,<br>
| > | > | from RcppArmadilloEg.cpp:1:<br>
| > | > |<br>
| > | ><br>
| > /home/abhisek/R/i486-pc-linux-gnu-library/2.10/Rcpp/lib/Rcpp/internal/wrap.h:<br>
| > | > | In function ‘SEXPREC*<br>
| > | > Rcpp::internal::wrap_dispatch_unknown_iterable(const<br>
| > | > | T&, Rcpp::traits::false_type) [with T = arma::Col<double>]’:<br>
| > | > |<br>
| > | ><br>
| > /home/abhisek/R/i486-pc-linux-gnu-library/2.10/Rcpp/lib/Rcpp/internal/wrap.h:491:<br>
| > | > | instantiated from ‘SEXPREC*<br>
| > Rcpp::internal::wrap_dispatch_unknown(const<br>
| > | > T&,<br>
| > | > | Rcpp::traits::false_type) [with T = arma::Col<double>]’<br>
| > | > |<br>
| > | ><br>
| > /home/abhisek/R/i486-pc-linux-gnu-library/2.10/Rcpp/lib/Rcpp/internal/wrap.h:509:<br>
| > | > | instantiated from ‘SEXPREC*<br>
| > | > | Rcpp::internal::wrap_dispatch_unknown_importable(const T&,<br>
| > | > | Rcpp::traits::false_type) [with T = arma::Col<double>]’<br>
| > | > |<br>
| > | ><br>
| > /home/abhisek/R/i486-pc-linux-gnu-library/2.10/Rcpp/lib/Rcpp/internal/wrap.h:526:<br>
| > | > | instantiated from ‘SEXPREC* Rcpp::internal::wrap_dispatch(const T&,<br>
| > | > | Rcpp::traits::wrap_type_unknown_tag) [with T = arma::Col<double>]’<br>
| > | > |<br>
| > | ><br>
| > /home/abhisek/R/i486-pc-linux-gnu-library/2.10/Rcpp/lib/Rcpp/internal/wrap.h:541:<br>
| > | > | instantiated from ‘SEXPREC* Rcpp::wrap(const T&) [with T =<br>
| > | > | arma::Col<double>]’<br>
| > | > |<br>
| > /home/abhisek/R/i486-pc-linux-gnu-library/2.10/Rcpp/lib/Rcpp/Named.h:54:<br>
| > | > | instantiated from ‘Rcpp::Named::Named(const std::string&, const T&)<br>
| > [with<br>
| > | > T<br>
| > | > | = arma::colvec]’<br>
| > | > | RcppArmadilloEg.cpp:19: instantiated from here<br>
| > | > |<br>
| > | ><br>
| > /home/abhisek/R/i486-pc-linux-gnu-library/2.10/Rcpp/lib/Rcpp/internal/wrap.h:394:<br>
| > | > | error: cannot convert ‘const arma::Col<double>’ to ‘SEXPREC*’ in<br>
| > | > | initialization<br>
| > | > | make: *** [RcppArmadilloEg.o] Error 1<br>
| > | > |<br>
| > | > |<br>
| > | > | could someone provide some advice?<br>
| > | ><br>
| > | > Which Rcpp version do you have installed?<br>
| > | ><br>
| > | > Which Armadillo version do you have installed?<br>
| > | ><br>
| > | > I have not tried the free-floating direct compile you try here. Maybe<br>
| > the<br>
| > | > defines for RcppArmadillo that we use are missing here -- hard to say.<br>
| > | ><br>
| > | > Could you try to create your own little package but copying the<br>
| > | > RcppArmadillo<br>
| > | > files, changes DESCRIPTION to what you do and changes the FastLM code<br>
| > in<br>
| > | > C++<br>
| > | > and R?<br>
| > | ><br>
| > | > Dirk<br>
| > | ><br>
| > | > --<br>
| > | > Registration is open for the 2nd International conference R / Finance<br>
| > 2010<br>
| > | > See <a href="http://www.RinFinance.com" target="_blank">http://www.RinFinance.com</a> for details, and see you in Chicago in<br>
| > | > April!<br>
| > | ><br>
| ><br>
| > --<br>
| > Registration is open for the 2nd International conference R / Finance<br>
| > 2010<br>
| > See <a href="http://www.RinFinance.com" target="_blank">http://www.RinFinance.com</a> for details, and see you in Chicago in<br>
| > April!<br>
| ><br>
<br>
</div></div>--<br>
<div><div></div><div> Registration is open for the 2nd International conference R / Finance 2010<br>
See <a href="http://www.RinFinance.com" target="_blank">http://www.RinFinance.com</a> for details, and see you in Chicago in April!<br>
</div></div></blockquote></div><br>