Re: [Rcpp-devel] About calling C/C++ functions in R

2010-06-15 Thread xiagao1982
Thanks for your advice! I'll plan to read the documents carefully. Now I am anxious to make the program running. If possible, could you please give me an example to achieve that? Best regards, Gao Xia xiagao1982 2010-06-16 发件人: Dirk Eddelbuettel 发送时间: 2010-06-16 09:14:07 收件人: xiagao1982

Re: [Rcpp-devel] About calling C/C++ functions in R

2010-06-15 Thread Dirk Eddelbuettel
On 16 June 2010 at 08:13, xiagao1982 wrote: | Dear friends, | | I am a newcomer of Rcpp and RInside. I installed them in my system and | successfully build the following example: | | #include // | for the embedded R via RInside | | Rcpp::NumericMatrix createMatri

[Rcpp-devel] About calling C/C++ functions in R

2010-06-15 Thread xiagao1982
Dear friends, I am a newcomer of Rcpp and RInside. I installed them in my system and successfully build the following example: #include // for the embedded R via RInside Rcpp::NumericMatrix createMatrix(const int n) { Rcpp::NumericMatrix M(n,n); for (int i=0

Re: [Rcpp-devel] Is there an Rcpp class for arrays with > 2 dimensions?

2010-06-15 Thread Dominick Samperi
[should have used reply all] On Tue, Jun 15, 2010 at 3:11 PM, Romain Francois wrote: > > But there seems to be a problem due to non-public fields. >> > > What do you mean ? I made the mistake of using NumericMatrix(Dimension(2,3,4)) instead of NumericVector(Dimension(2,3,4)). That is why I had c

Re: [Rcpp-devel] Is R_len_t the preferred type for iterating over Vector elements?

2010-06-15 Thread Romain Francois
Le 15/06/10 23:06, Douglas Bates a écrit : Suppose I want to iterate over the values of a NumericVector x. If one wants to "future-proof" one's code a bit, I presume the preferred idiom is for(R_len_t i = 0; i< x.size(); ++i) x[i] = ... as opposed to declaring i to be an int or a size_t. I

[Rcpp-devel] Is R_len_t the preferred type for iterating over Vector elements?

2010-06-15 Thread Douglas Bates
Suppose I want to iterate over the values of a NumericVector x. If one wants to "future-proof" one's code a bit, I presume the preferred idiom is for(R_len_t i = 0; i < x.size(); ++i) x[i] = ... as opposed to declaring i to be an int or a size_t. Is that correct? ___

Re: [Rcpp-devel] Is there an Rcpp class for arrays with > 2 dimensions?

2010-06-15 Thread Douglas Bates
On Tue, Jun 15, 2010 at 2:11 PM, Romain Francois wrote: > > Le 15/06/10 20:45, Dominick Samperi a écrit : >> >> I have tried something like >> >> Rcpp::NumericVector nm(Rcpp::Dimension(2,3,4)); > > I get this: > >> require( Rcpp ) > Le chargement a nécessité le package : Rcpp >> require( inline )

Re: [Rcpp-devel] Is there an Rcpp class for arrays with > 2 dimensions?

2010-06-15 Thread Romain Francois
(cc'ing the list since apparently you did not) Le 15/06/10 21:50, Dominick Samperi a écrit : On Tue, Jun 15, 2010 at 3:11 PM, Romain Francois mailto:[email protected]>> wrote: which looks about right. although not much useful without some more support such as extract or set the v

Re: [Rcpp-devel] Is there an Rcpp class for arrays with > 2 dimensions?

2010-06-15 Thread Romain Francois
Le 15/06/10 20:45, Dominick Samperi a écrit : I have tried something like Rcpp::NumericVector nm(Rcpp::Dimension(2,3,4)); I get this: > require( Rcpp ) Le chargement a nécessité le package : Rcpp > require( inline ) Le chargement a nécessité le package : inline > fx <- cxxfunction( signature

Re: [Rcpp-devel] Is there an Rcpp class for arrays with > 2 dimensions?

2010-06-15 Thread Dominick Samperi
I have tried something like Rcpp::NumericVector nm(Rcpp::Dimension(2,3,4)); But there seems to be a problem due to non-public fields. Am I misunderstanding the purpose of Dimension() here? On Tue, Jun 15, 2010 at 2:19 PM, Romain Francois wrote: > Le 15/06/10 20:08, Douglas Bates a écrit : > >

Re: [Rcpp-devel] RcppArmadillo

2010-06-15 Thread Davor Cubranic
I've seen 2-10 times figure mentioned as a reasonable expectation for this. (I hit around 5-6x on my last few projects.) Avoid calling back into R (i.e., Rcpp::Function) too frequently, because crossing that interpreter boundary carries a real price. Also, if your R code is mostly staying insid

Re: [Rcpp-devel] RcppArmadillo

2010-06-15 Thread Dirk Eddelbuettel
Hi Chuck, On 15 June 2010 at 12:24, Chuck Anderson wrote: | I translated some R code I have for training neural networks into C++ | using Armadillo and call it using RcppArmadillo. It was great fun to | see how Armadillo allows a pretty direct translation from R to C++. Cool. That's pretty

[Rcpp-devel] RcppArmadillo

2010-06-15 Thread Chuck Anderson
I translated some R code I have for training neural networks into C++ using Armadillo and call it using RcppArmadillo. It was great fun to see how Armadillo allows a pretty direct translation from R to C++. However, I only see a speed up of 2 over the R execution time. I expected much more.

Re: [Rcpp-devel] Is there an Rcpp class for arrays with > 2 dimensions?

2010-06-15 Thread Romain Francois
Le 15/06/10 20:08, Douglas Bates a écrit : I may be confusing Armadillo classes and Rcpp classes but I seem to recall that there is an Rcpp class for arrays with more than 2 dimensions. However, I can't find anything that looks like that in the declarations or in the unit tests. I can easily c

[Rcpp-devel] Is there an Rcpp class for arrays with > 2 dimensions?

2010-06-15 Thread Douglas Bates
I may be confusing Armadillo classes and Rcpp classes but I seem to recall that there is an Rcpp class for arrays with more than 2 dimensions. However, I can't find anything that looks like that in the declarations or in the unit tests. I can easily create such an object by installing a dim attri

Re: [Rcpp-devel] XPtr

2010-06-15 Thread Romain Francois
Le 15/06/10 17:27, Dominick Samperi a écrit : This code seems simple enough (from cxxPack)... RcppExport SEXP testBankOpen(SEXP name, SEXP id, SEXP balance) { BEGIN_RCPP BankAccount *p = new BankAccount(Rcpp::as(name), Rcpp::as(id), Rcpp::as(

[Rcpp-devel] XPtr

2010-06-15 Thread Dominick Samperi
This code seems simple enough (from cxxPack)... RcppExport SEXP testBankOpen(SEXP name, SEXP id, SEXP balance) { BEGIN_RCPP BankAccount *p = new BankAccount(Rcpp::as(name), Rcpp::as(id), Rcpp::as(balance)); Rcpp::XPtr xp(p, true); return xp