I need a function to copy a matrix/submatrix a into matrix/submatrix b without transposing a. I wrote the function below to address this, is there a more efficient way to do this? Out of curiosity, why does rmatrixcopy transpose a before copying?
Thanks, Dave /************************************************************************* Copy
Input parameters: M - number of rows N - number of columns A - source matrix, MxN submatrix is copied without transposing IA - submatrix offset (row index) JA - submatrix offset (column index) B - destination matrix, must be large enough to store result IB - submatrix offset (row index) JB - submatrix offset (column index) *************************************************************************/ static void algMatCopy(const alglib::ae_int_t m, const alglib:ae_int_t n, const alglib:real_2d_array &a, const alglib:ae_int_t ia, const alglib:ae_int_t ja, alglib:real_2d_array &b, const alglib:ae_int_t ib, const alglib:ae_int_t jb) { alglib::real_2d_array aT; aT.setlength(n,m); // because rmatrixcopy transposes a before copying to b. alglib::rmatrixcopy(m, n, a, ia, ja, aT, 0, 0); alglib::rmatrixcopy(m, n, aT, 0, 0, b, ib, jb); }
|