Re: [Rd] Adding a Matrix Exponentiation Operator

From: Antonio, Fabio Di Narzo <antonio.fabio_at_gmail.com>
Date: Sat, 05 Apr 2008 18:51:53 +0200

2008/4/5, Rory Winston <rory.winston_at_gmail.com>: <snip>
>
> /* Convenience function */
> static void copyMatrixData(SEXP a, SEXP b, int nrows, int ncols, int mode) {
> for (int i=0; i < ncols; ++i)
> for (int j=0; j < nrows; ++j)
> REAL(b)[i * nrows + j] = REAL(a)[i * nrows + j];
> }

I would use 'memcpy' here instead of the double for loop, i.e.: memcpy(REAL(b), REAL(a), length(b) * sizeof(double))

-- 
Antonio, Fabio Di Narzo
Ph.D. student at
Department of Statistical Sciences
University of Bologna, Italy

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Sat 05 Apr 2008 - 17:02:53 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 08 Apr 2008 - 08:31:04 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive