forum.alglib.net

ALGLIB forum
It is currently Tue Jul 02, 2024 8:44 am

All times are UTC


Forum rules


1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Why does alglib::rmatrixcopy transpose a before copying?
PostPosted: Wed Jun 26, 2024 11:47 pm 
Offline

Joined: Wed Jun 26, 2024 11:37 pm
Posts: 1
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);
}


Top
 Profile  
 
 Post subject: Re: Why does alglib::rmatrixcopy transpose a before copying?
PostPosted: Thu Jun 27, 2024 1:34 pm 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 920
Hi!

It does not transpose the matrix! The comment says 'without transposing' because there is a similar functions which performs copy-and-transpose.

So, there is no need to copy the matrix via temporary storage. Actually, the design reminds me of one old joke: 'our CPU implements multiplication via division by the inverse number'.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group