<div dir="ltr"><div><div><div><div>Hi Dirk,<br><br></div>Thanks for the quick response. In the broader project, the vector being copied from is an Rcpp::NumericVector that contatenates vectorized versions of a number of other objects that are integrated numerically using the boost odeint solvers. I couldn't quite get the numerical integrators to play nice with Armadillo objects, and in using std::copy I was trying to avoid converting the vector 'v' to an arma::vec since I would have to convert it back for further integration. Perhaps this was a mistake?<br><br></div>Still, I don't quite understand why armadillo row pointers don't work which armadillo column pointers are fine. <br><br></div>Thanks,<br></div>Jon<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 12, 2016 at 2:10 PM, Dirk Eddelbuettel <span dir="ltr"><<a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
On 12 October 2016 at 13:43, Jonathan Fintzi wrote:<br>
| Hello,<br>
|<br>
| I am trying to use the std::copy() function to copy elements from an<br>
| Rcpp::NumericVector into rows of armadillo matrices. A simplified version of my<br>
| code is as follows:<br>
|<br>
| cppFunction('void copyinto(Rcpp::NumericVector& v, arma::mat& d1, arma::mat&<br>
| d2) {<br>
|         std::copy(v.begin(), v.begin() + 3, d1.begin_row(0));<br>
|         std::copy(v.begin() + 3, v.end(), d2.begin_row(0));<br>
| }', depends = "RcppArmadillo")<br>
<br>
</span>You should not need to mix an _Rcpp_ vector with an _Armadillo_ matrix using<br>
std::copy.  Check the decent Armadillo docs -- all the subsetting and slicing<br>
can be done with Armadillo.  And that is what I would do.<br>
<br>
But maybe I didn't quite understand what you are really after.<br>
<br>
Dirk<br>
<span class=""><br>
| v <- runif(6)<br>
| d1 <- matrix(0.0, 3,3)<br>
| d2 <- matrix(0.0, 3,3)<br>
|<br>
| copyinto(v, d1, d2)<br>
|<br>
| However, when I attempt to compile the code, I receive a list of compilation<br>
| errors including "no type named 'XXXXXX' in 'class arma::Mat<double><br>
| row_iterator", where XXXXXX is iterator_category, value_type, difference_type,<br>
| pointer, and reference.<br>
|<br>
| If I change the iterators to column iterators (e.g. d1.begin_col(0)) everything<br>
| compiles and works just fine. I feel that I must be missing something quite<br>
| basic here, but in searching around I haven't been able to identify my mistake.<br>
|<br>
| Thank you for your help!<br>
| Jon<br>
</span>| ______________________________<wbr>_________________<br>
| Rcpp-devel mailing list<br>
| <a href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-<wbr>project.org</a><br>
| <a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" rel="noreferrer" target="_blank">https://lists.r-forge.r-<wbr>project.org/cgi-bin/mailman/<wbr>listinfo/rcpp-devel</a><br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
<a href="http://dirk.eddelbuettel.com" rel="noreferrer" target="_blank">http://dirk.eddelbuettel.com</a> | @eddelbuettel | <a href="mailto:edd@debian.org">edd@debian.org</a><br>
</font></span></blockquote></div><br></div>