[Rcpp-devel] broken package after udpate
Dirk Eddelbuettel
edd at debian.org
Sat Nov 17 00:08:33 CET 2012
On 17 November 2012 at 11:31, baptiste auguie wrote:
| Hi,
|
| (Hopefully this makes it to the list; I believe I've had problems reaching it
| because of a recent change between @gmail and @googlemail).
Looks like it.
| I made a minimal package * to illustrate the problem of my recently broken
| package cda (since yesterday's update of Rcpp). There's only one function euler
| () in a Module named cda. It used to return a 3x3 matrix, but after updating to
| Rcpp 0.10 it returns a vector. You can run the example with
|
| $ R -f inst/testing/test.r
|
| What am I doing wrong?
|
| Best,
|
| baptiste
|
| * https://dl.dropbox.com/u/352834/cda_1.2.1.tar.gz
Good example. I added one line
Rcpp::Rcout << "In Euler, Rot is " << std::endl << Rot << std::endl;
and the end of 'Euler' and we see that the dimension is in fact there, but
then gets lost on the way out:
edd at max:/tmp/baptiste$ r -lcda -p -e'M <- cda$euler(1.1, 2.0, 3.1); dim(M); class(M); M'
[1] "cda" "grid" "reshape2" "randtoolbox"
[5] "rngWELL" "statmod" "plyr" "RcppArmadillo"
[9] "Rcpp" "methods" "base"
In Euler, Rot is
-0.4378 -0.8983 0.0378
-0.3894 0.1515 -0.9085
0.8104 -0.4125 -0.4161
[1] -0.43778268 -0.38941320 0.81037256 -0.89828547 0.15154235 -0.41245379
[7] 0.03780919 -0.90851102 -0.41614684
NULL
[1] "numeric"
[1] -0.43778268 -0.38941320 0.81037256 -0.89828547 0.15154235 -0.41245379
[7] 0.03780919 -0.90851102 -0.41614684
edd at max:/tmp/baptiste$
That is with the newest Rcpp and RcppArmadillo. So somewhere we are loosing
the matrix attribute.
If I 'make the whole thing slower' by explicitly converting, it works -- I
just add euler2 as
NumericMatrix euler2(const double phi, const double theta, const double psi) {
arma::mat M(3,3);
M = euler(phi, theta, psi);
return Rcpp::wrap(M);
}
// [...]
function( "euler2", &euler2, "Constructs a 3x3 Euler rotation matrix" ) ;\
as seen here:
edd at max:/tmp/baptiste$ r -lcda -p -e'M <- cda$euler2(1.1, 2.0, 3.1); dim(M); class(M); M'
[1] "cda" "grid" "reshape2" "randtoolbox"
[5] "rngWELL" "statmod" "plyr" "RcppArmadillo"
[9] "Rcpp" "methods" "base"
In Euler, Rot is
-0.4378 -0.8983 0.0378
-0.3894 0.1515 -0.9085
0.8104 -0.4125 -0.4161
[,1] [,2] [,3]
[1,] -0.4377827 -0.8982855 0.03780919
[2,] -0.3894132 0.1515423 -0.90851102
[3,] 0.8103726 -0.4124538 -0.41614684
[1] 3 3
[1] "matrix"
[,1] [,2] [,3]
[1,] -0.4377827 -0.8982855 0.03780919
[2,] -0.3894132 0.1515423 -0.90851102
[3,] 0.8103726 -0.4124538 -0.41614684
edd at max:/tmp/baptiste$
So somewhere between the compiler getting smarter, Conrad optimising
expression and us, an attribute got lost.
Maybe Romain can find a way to make this explicit.
Cheers, Dirk
--
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
More information about the Rcpp-devel
mailing list