<div dir="ltr"><div><div><div><div><div>Hi Jianyang,<br></div>It seems that the problem still exists, and the problem is mainly due to the following statement:<br><pre>Rcpp::as<Eigen::MatrixXd>( A );</pre>It means we cannot directly cast SEXP to Eigen::MatrixXd.<br>
<br>If you want to operate A using Eigen, there are several ways to do it:<br></div><br>1. Map A to Eigen::Map<Eigen::MatrixXd><br><pre>typedef Eigen::Map<Eigen::MatrixXd> MapMat;<br>MapMat _A = Rcpp::as<MapMat>( A );</pre>
In this case _A shares the same data with A, so changing _A will also change A.<br><br></div>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.<br>
<pre>Eigen::MatrixXd _A_copy(_A);</pre>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<br><pre>Eigen::MatrixXd _A_copy = _A;</pre><br></div><div>
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.<br>
</div><div> <br></div><div><br></div>Best,<br></div>Yixuan<br><div><div><br></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-02-16 16:53 GMT-05:00 Jianyang Zhao <span dir="ltr"><<a href="mailto:uzhao@ucdavis.edu" target="_blank">uzhao@ucdavis.edu</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello All,<div><br></div><div>I got into same problem in this thread. Is it solved? I use last version R, Rcpp and RcppEigen under windows. </div>
<div><br></div><div><a href="http://lists.r-forge.r-project.org/pipermail/rcpp-devel/2012-May/003792.html" target="_blank">http://lists.r-forge.r-project.org/pipermail/rcpp-devel/2012-May/003792.html</a><br>
</div><div><br></div><div>Thanks,</div><div><br></div><div>Jianyang</div></div>
<br>_______________________________________________<br>
Rcpp-devel mailing list<br>
<a href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a><br></blockquote></div><br><br clear="all"><br>
-- <br>Yixuan Qiu <<a href="mailto:yixuan.qiu@cos.name" target="_blank">yixuan.qiu@cos.name</a>><br>Department of Statistics,<br>Purdue University<br>
</div>