[Rcpp-devel] cbind

2012-12-02 Thread Honglang Wang
Dear All, I am new to Rcpp. If I want to do the similar thing as "cbind" in R, what should I do in RcppArmadillo? Thanks. Best wishes! Honglang Wang Office C402 Wells Hall Department of Statistics and Probability Michigan State University 1579 I Spartan Village, East Lansing, MI 4

[Rcpp-devel] Why this is not working

2012-12-03 Thread Honglang Wang
") =Z); } Thanks. Best wishes! Honglang Wang Office C402 Wells Hall Department of Statistics and Probability Michigan State University 1579 I Spartan Village, East Lansing, MI 48823 wangh...@msu.edu ___ Rcpp-devel mailing list Rcpp-devel@lis

[Rcpp-devel] How to increase the coding efficiency

2012-12-04 Thread Honglang Wang
} Anyone could help me with how to increase the efficiency of the coding? Thanks. Best wishes! Honglang Wang Office C402 Wells Hall Department of Statistics and Probability Michigan State University 1579 I Spartan Village, East Lansing, MI 48823 wangh.

Re: [Rcpp-devel] How to increase the coding efficiency

2012-12-04 Thread Honglang Wang
Inv = arma::trans(D)*W*D; arma::vec betahat = arma::inv(Inv)*arma::trans(D)*W*y; arma::colvec betahat0(betahat.begin(),betahat.size()/2,false); return List::create(Named("betahat") = betahat0); } Best wishes! Honglang Wang Office C402 Wells Hall Department of Statistics and Probab

Re: [Rcpp-devel] How to increase the coding efficiency

2012-12-04 Thread Honglang Wang
Yes, the main issue for my coding is the allocation of memory. And I have fixed one of the biggest memory allocation issue: 4000 by 4000 diagonal matrix. And since I am not familiar with Rcpp and RcppArmadillo, I have no idea how to reuse the memory. I hope I can have some materials to learn this.

Re: [Rcpp-devel] How to increase the coding efficiency

2012-12-05 Thread Honglang Wang
*W*y; arma::colvec betahat0(betahat.begin(),betahat.size()/2,false); return List::create(Named("betahat") = betahat0); } Best wishes! Honglang Wang Office C402 Wells Hall Department of Statistics and Probability Michigan State University 1579 I Spartan Village, East Lansing, MI 48

Re: [Rcpp-devel] How to increase the coding efficiency

2012-12-05 Thread Honglang Wang
I am sorry. I think you are right. I know little about computation. And it will be great that you write what you would like to wrote to explain to me. I am really learning a lot from this discussion. Before I even have not heard of profiling of a program. Thanks. Best wishes! Honglang Wang

Re: [Rcpp-devel] How to increase the coding efficiency

2012-12-06 Thread Honglang Wang
Thanks Douglas, I will study your code and Eigen carefully. Best wishes! Honglang Wang Office C402 Wells Hall Department of Statistics and Probability Michigan State University 1579 I Spartan Village, East Lansing, MI 48823 wangh...@msu.edu On Thu, Dec 6, 2012 at 1:33 PM, Douglas Bates

Re: [Rcpp-devel] How to increase the coding efficiency

2012-12-11 Thread Honglang Wang
I tried out that if the dim of the matrix less than or equal to 4, inv() and solve() have the same speed. Best wishes! Honglang Wang Office C402 Wells Hall Department of Statistics and Probability Michigan State University 1579 I Spartan Village, East Lansing, MI 48823 wangh...@msu.edu On

Re: [Rcpp-devel] How to increase the coding efficiency

2012-12-11 Thread Honglang Wang
betahat.size()/2,false); return List::create(Named("betahat") = betahat0); } Best wishes! Honglang Wang Office C402 Wells Hall Department of Statistics and Probability Michigan State University 1579 I Spartan Village, East Lansing, MI 48823 wangh...@msu.edu On Thu, Dec 6, 2012 at 2:10 A

Re: [Rcpp-devel] How to increase the coding efficiency

2012-12-12 Thread Honglang Wang
7;memory not mapped' Error in betahat(ker, inv[l], cbind(inv[1:ll], inv[(ll + 1):(2 * ll)]), : badly formed function expression Calls: system.time ... apply -> FUN -> betahat -> .External -> cpp_exception Execution halted And I really have no idea what is the problem. Best

[Rcpp-devel] How to free memory in Rcpp

2012-12-13 Thread Honglang Wang
Dear All, How to free memory in Rcpp? What's the command? Thanks. Best wishes! Honglang Wang Office C402 Wells Hall Department of Statistics and Probability Michigan State University 1579 I Spartan Village, East Lansing, MI 48823 wangh...@ms

Re: [Rcpp-devel] How to free memory in Rcpp

2012-12-13 Thread Honglang Wang
error. I am just wondering whether I need to free some memory in this code. Thanks. Best wishes! Honglang Wang Office C402 Wells Hall Department of Statistics and Probability Michigan State University 1579 I Spartan Village, East Lansing, MI 48823 wangh...@msu.edu On Thu, Dec 13, 2012 at

Re: [Rcpp-devel] How to free memory in Rcpp

2012-12-13 Thread Honglang Wang
separately (since I set the seed, it used the same data), but it worked well in this case. Then I really have no idea what is going on there. Best wishes! Honglang Wang Office C402 Wells Hall Department of Statistics and Probability Michigan State University 1579 I Spartan Village, East Lansing, MI 48823

Re: [Rcpp-devel] How to free memory in Rcpp

2012-12-13 Thread Honglang Wang
Hi Yan, Thanks a lot. Your advice is really the point for me. Have a good night. Best wishes! Honglang Wang Office C402 Wells Hall Department of Statistics and Probability Michigan State University 1579 I Spartan Village, East Lansing, MI 48823 wangh...@msu.edu On Thu, Dec 13, 2012 at 10:54

Re: [Rcpp-devel] How to free memory in Rcpp

2012-12-14 Thread Honglang Wang
hat -> .External -> cpp_exception Execution halted What should I do? Do I have to do like: arma::colvec betahat0(betahat.begin(),betahat.size()/2,false); NumericVector betahat00(p); betahat00 = betahat0; return List::create(Named("betahat") = betahat00); Best wishes! Honglang Wang Offi

Re: [Rcpp-devel] How to free memory in Rcpp

2012-12-14 Thread Honglang Wang
Thanks, Romain. Best wishes! Honglang Wang Office C402 Wells Hall Department of Statistics and Probability Michigan State University 1579 I Spartan Village, East Lansing, MI 48823 wangh...@msu.edu On Fri, Dec 14, 2012 at 11:04 AM, Romain Francois wrote: > I dont know. This looks lik

[Rcpp-devel] Connection between arma and rcpp

2013-01-29 Thread Honglang Wang
= Ar.ncol(); arma::mat A(Ar.begin(),n,m,false); A.reshape(m,n); arma::mat U(m,1)=f2(A,1, function(x) foo(f=f1,x)$r); double r = arma::accu(U); return r; } A <- matrix(rnorm(8),nrow=4) fpp(mean, apply, A) Anyone can help me out? Thanks a lot? Best wishes! Honglang Wang Office

Re: [Rcpp-devel] Connection between arma and rcpp

2013-01-29 Thread Honglang Wang
a=0; a(A.row(a))); } double r = arma::accu(U); return r; } ### how to deal with the arma object A.row(a) for the input of foo, which need rcpp object? A <- matrix(rnorm(8),nrow=4) fpp(mean,A) Thanks. Best wishes! Honglang Wang Office C402 Wells Hall Department of Statistics and Probabil

Re: [Rcpp-devel] Connection between arma and rcpp

2013-01-29 Thread Honglang Wang
Thanks, Kevin. Your last comment saves me a day, lol. Since I do not know how to learn Rcpp effectively, there is no big pic of Rcpp in my mind. This is the first time I know that we could change the type of the input into arma. Thanks a lot. That's what I want. Best wishes! Honglang