[Rcpp-devel] Is this issue solved?
yixuan.qiu at cos.name
Mon Feb 17 00:30:59 CET 2014
It seems that the problem still exists, and the problem is mainly due to
the following statement:
Rcpp::as<Eigen::MatrixXd>( A );
It means we cannot directly cast SEXP to Eigen::MatrixXd.
If you want to operate A using Eigen, there are several ways to do it:
1. Map A to Eigen::Map<Eigen::MatrixXd>
typedef Eigen::Map<Eigen::MatrixXd> MapMat;
MapMat _A = Rcpp::as<MapMat>( A );
In this case _A shares the same data with A, so changing _A will also
2. If you want to copy the data of A to a Eigen::MatrixXd variable, you can
use a copy constructor as suggested by Doug Bates.
3. In Eigen the assignment of a matrix will also do the copy (at least for
the following example), so it is also true to use
Eigen::MatrixXd _A_copy = _A;
As a whole, the general rule at this moment is that you always convert A to
an Eigen::Map<Eigen::MatrixXd> object first, and then operate on _A either
by directly accessing it or by copying it to an Eigen::MatrixXd object.
2014-02-16 16:53 GMT-05:00 Jianyang Zhao <uzhao at ucdavis.edu>:
> Hello All,
> I got into same problem in this thread. Is it solved? I use last version
> R, Rcpp and RcppEigen under windows.
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
Yixuan Qiu <yixuan.qiu at cos.name>
Department of Statistics,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Rcpp-devel