Hi,
Just starting to learn about Rcpp tonight (Using it through the inline library)
I'm attempting to construct a matrix and then fill it with values as I iterate
through my function. The results are wrong. Am I accessing the cells of the
matrix incorrectly?
The idea was to have an integer in the first position of each row, and then the
polynomials in the subsequent positions.
Any suggestions?
----------------------------
Here is my test code:
Test2 <- cxxfunction(
signature(),
plugin="Rcpp",
body="
Rcpp::NumericMatrix out_xx(10, 4);
for(int i = 1; i != 10; i++){
out_xx(i,0) = i;
out_xx(i,1) = i^2;
out_xx(i,2) = i^3;
out_xx(i,3) = i^4;
}
return Rcpp::wrap(out_xx);
"
)
-----------------------------
> Test2()
[,1] [,2] [,3] [,4]
[1,] 0 0 0 0
[2,] 1 3 2 5
[3,] 2 0 1 6
[4,] 3 1 0 7
[5,] 4 6 7 0
[6,] 5 7 6 1
[7,] 6 4 5 2
[8,] 7 5 4 3
[9,] 8 10 11 12
[10,] 9 11 10 13
--
Noah Silverman
UCLA Department of Statistics
8117 Math Sciences Building #8208
Los Angeles, CA 90095
_______________________________________________
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel