Hi Romain,<br><br>I tried the commands you gave and I get the following error:<br><br>RcppArmadilloEg.cpp: In function ‘SEXPREC* fastLm(SEXPREC*, SEXPREC*)’:<br>RcppArmadilloEg.cpp:19: error: ‘create’ is not a member of ‘Rcpp::List’<br>
make: *** [RcppArmadilloEg.o] Error 1<br><br>is there some kind of update I need to make?<br><br>almost there!<br>abhisek<br><br><div class="gmail_quote">On Tue, Mar 30, 2010 at 3:12 PM, Romain Francois <span dir="ltr">&lt;<a href="mailto:romain@r-enthusiasts.com">romain@r-enthusiasts.com</a>&gt;</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;">Le 30/03/10 15:36, Douglas Bates a écrit :<div class="im"><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Tue, Mar 30, 2010 at 1:15 AM, Romain Francois<br>
&lt;<a href="mailto:romain@r-enthusiasts.com" target="_blank">romain@r-enthusiasts.com</a>&gt;  wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br>
</blockquote>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
If you want to compile the code that is here<br>
<a href="http://dirk.eddelbuettel.com/code/rcpp.armadillo.html" target="_blank">http://dirk.eddelbuettel.com/code/rcpp.armadillo.html</a> directly from R<br>
CMD SHLIB, you can do this:<br>
</blockquote>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
romain@naxos /tmp $ export PKG_CXXFLAGS=`Rscript -e<br>
&quot;RcppArmadillo:::CxxFlags()&quot;`<br>
romain@naxos /tmp $ export PKG_LIBS=`Rscript -e &quot;RcppArmadillo:::LdFlags()&quot;`<br>
romain@naxos /tmp $ R CMD SHLIB armaex.cpp<br>
</blockquote>
<br>
The way that RcppArmadillo:::LdFlags() is currently defined there is a<br>
possibility of getting different Lapack and BLAS libraries when using<br>
R or calls to RcppArmadillo.  R uses the libraries defined by the<br>
macros LAPACK_LIBS, BLAS_LIBS and FLIBS in the file<br>
<br>
file.path(R.home(&quot;etc&quot;), &quot;Makeconf&quot;)  # evaluate this in R<br>
<br>
It is not certain that those will be the same as the libraries used by<br>
Armadillo.  If they are not shared objects you run the risk of getting<br>
two copies of Lapack, etc.  and possibly different BLAS, leading to<br>
different performance characteristics and perhaps different results.<br>
</blockquote>
<br></div>
Hmmm. Interesting. I did not think of that problem.<br>
<br>
On my machine, I have :<br>
<br>
Rscript -e &quot;RcppArmadillo:::LdFlags()&quot;<br>
/Library/Frameworks/R.framework/Resources/library/Rcpp/lib/x86_64/libRcpp.a -L/usr/lib -larmadillo<br>
<br>
so linking against Rcpp &quot;user&quot; library and armadillo... but when I manually set PKG_LIBS to just Rcpp user library, it still works, so we actually do not need to link against armadillo library. armadillo itself does not __need__ to get compiled into a library because it is all templates.<div>
<div></div><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

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