Re: [Rcpp-devel] Turning a vector into a matrix

2013-05-31 Thread Søren Højsgaard
Romain and Dirk: Thanks for your help and patience! Søren -Original Message- From: Dirk Eddelbuettel [mailto:[email protected]] Sent: 31. maj 2013 13:24 To: Søren Højsgaard Cc: Romain Francois; [email protected] Subject: Re: [Rcpp-devel] Turning a vector into a matrix

Re: [Rcpp-devel] Turning a vector into a matrix

2013-05-31 Thread Dirk Eddelbuettel
On 31 May 2013 at 10:28, Søren Højsgaard wrote: | Romain, | | Perhaps I now see the light at the end of the tunnel (hope it is not a train comming against me!): If I understand this correctly, the following | | > template | > Matrix vec2matrix2(Vector x, int nrow, int ncol) { | >return Mat

Re: [Rcpp-devel] Turning a vector into a matrix

2013-05-31 Thread Søren Højsgaard
Cc: [email protected] Subject: Re: [Rcpp-devel] Turning a vector into a matrix Ah ok, so you want to use this from R, I would suggest to Rcpp::export a dispatcher, something like this: #include using namespace Rcpp ; // the template template Matrix vec2matrix__impl(Vect

Re: [Rcpp-devel] Turning a vector into a matrix

2013-05-31 Thread Romain Francois
r 1 Error in Rcpp::sourceCpp("./util.cpp") : Error 1 occurred building shared library. -Original Message- From: [email protected] [mailto:[email protected]] On Behalf Of Romain Francois Sent: 31. maj 2013 11:22 To: rcpp-deve

Re: [Rcpp-devel] Turning a vector into a matrix

2013-05-31 Thread Romain Francois
From: [email protected] [mailto:[email protected]] On Behalf Of Romain Francois Sent: 31. maj 2013 11:22 To: [email protected] Subject: Re: [Rcpp-devel] Turning a vector into a matrix Hello Søren, This is easy templat

Re: [Rcpp-devel] Turning a vector into a matrix

2013-05-31 Thread Søren Højsgaard
library. -Original Message- From: [email protected] [mailto:[email protected]] On Behalf Of Romain Francois Sent: 31. maj 2013 11:22 To: [email protected] Subject: Re: [Rcpp-devel] Turning a vector into

Re: [Rcpp-devel] Turning a vector into a matrix

2013-05-31 Thread Romain Francois
ow, int ncol) { return IntegerMatrix(nrow, ncol, x.begin()); } Any help would be more than welcome. Best regards Søren -Original Message- From: Dirk Eddelbuettel [mailto:[email protected]] Sent: 31. maj 2013 03:01 To: Søren Højsgaard Cc: [email protected] Subject: Re: [Rcpp-devel

Re: [Rcpp-devel] Turning a vector into a matrix

2013-05-31 Thread Søren Højsgaard
.ac.at Subject: Re: [Rcpp-devel] Turning a vector into a matrix Soren, You missed the most appropriate constructor: template Matrix( const int& nrows_, const int& ncols, Iterator start ) ; With that we just do this: R> Rcpp::sourceCpp('/tmp/soren.cpp') R>

Re: [Rcpp-devel] Turning a vector into a matrix

2013-05-30 Thread Dirk Eddelbuettel
Soren, You missed the most appropriate constructor: template Matrix( const int& nrows_, const int& ncols, Iterator start ) ; With that we just do this: R> Rcpp::sourceCpp('/tmp/soren.cpp') R> soren(1:4,2,2) [,1] [,2] [1,]13 [2,]24 R> and the file s

[Rcpp-devel] Turning a vector into a matrix

2013-05-30 Thread Søren Højsgaard
Dear all Apologies for a trivial question. I want to turn the vector vec <- 1:4 into a matrix 1 3 2 3 I do: src1 <-' NumericVector vec(vec_); NumericMatrix mat( as(nrow_), as(ncol_) ); for(int ii=0; iihttps://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel