From antonio.fabio at gmail.com  Sat Apr  5 18:51:53 2008
From: antonio.fabio at gmail.com (Antonio, Fabio Di Narzo)
Date: Sat, 5 Apr 2008 18:51:53 +0200
Subject: [Rd] Adding a Matrix Exponentiation Operator
In-Reply-To: <3f446aa30804050644y2fa4cc77l5c22dabc80fe4cec@mail.gmail.com>
References: <3f446aa30804050644y2fa4cc77l5c22dabc80fe4cec@mail.gmail.com>
Message-ID: <b0808fdc0804050951g4f4cff45r7cde7008efceadac@mail.gmail.com>

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



[Rd] Adding a Matrix Exponentiation Operator
Antonio, Fabio Di Narzo