From antonio.pv.gs at gmail.com  Mon Jan 11 17:54:50 2016
From: antonio.pv.gs at gmail.com (Antonio Perez)
Date: Mon, 11 Jan 2016 17:54:50 +0100
Subject: [Rd] coerce SEXP type to C++ matrix class and back
In-Reply-To: <22163.42469.934862.828950@max.nulle.part>
References: <CABGWzFSLgybYi0Tw2XhWXZVdMf11HXF6EwLapugDaMqddg_wCA@mail.gmail.com>
	<22163.42469.934862.828950@max.nulle.part>
Message-ID: <CABGWzFQKosWnwC9NL9AN5yh6RPZkE1wESYCTmgb+eVf24xpeag@mail.gmail.com>

Dirk,

I am sorry if it sounded disrespectful. On the contrary, as I said,
your packages Rcpp and RcppArmadillo work very well, and use both of
them in more "complex" applications. However, in this particular case
in which I have just one object of one type (matrix double) with its
elements stored column-major similarly to R I though that could find a
reasonable method to coerce my SEXP matrix into a Matrix double in
armadillo without using two packages for this.

I hope this is understood.



I though that there might beI ptough that might result which I insist
has similar and , a matrix with one typeit seems veryas we say
literally in Spanishother

2016-01-11 13:53 GMT+01:00 Dirk Eddelbuettel <edd at debian.org>:
>
> I don't want to sound disrespectful, but why not use RcppArmadillo if
> simplicity is you goal?
>
> It is hard to beat the _fully automatic_ conversion:
>
> R> cppFunction("arma::mat doubleUp(const arma::mat & x) { return 2*x; }", depends="RcppArmadillo")
> R> doubleUp(matrix(1:9,3,3))
>      [,1] [,2] [,3]
> [1,]    2    8   14
> [2,]    4   10   16
> [3,]    6   12   18
> R>
>
> You can of course do all that by hand too, but why do you think both Rcpp and
> RcppArmadillo have, respectively, tens of thousands of lines of code?
>
> Dirk
>
> --
> http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org



[Rd] coerce SEXP type to C++ matrix class and back
Antonio Perez