comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: large matrix operations
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: large matrix operations [message #62901 is a reply to message #62900] Mon, 13 October 2008 10:07 Go to previous messageGo to previous message
Vince Hradil is currently offline  Vince Hradil
Messages: 574
Registered: December 1999
Senior Member
On Oct 13, 11:00 am, Vince Hradil <vincehra...@gmail.com> wrote:
> On Oct 13, 10:08 am, Vince Hradil <vincehra...@gmail.com> wrote:
>
>> On Oct 13, 9:44 am, arp...@gmail.com wrote:
>
>>> It seems that very large matrix, e.g.1.0e6*1.0e5*100 operations, such
>>> as multiplication and matrix  multiplication, in IDL is very  slow.
>>> Anyone know how to speed up large matrix operations ?
>
>> Multiplication should be pretty fast.  Matrix multiplication can be
>> slow if you have to transpose the matrices.  This can be sped up by
>> using MatrixMultiply() instead of # or ##.  Perhaps Temporary() can be
>> used to avoid allocation of extra memory.  I think David has the best
>> ideas, though.
>
> oops, that should be MATRIX_MULTIPY()

So much for that theory...

Hardware:
IDL> print, !version
{ x86 Win32 Windows Microsoft Windows 7.0 Oct 25 2007 32 64}

Results:
% TEST: Allocating A array
% TEST: took 0.14000010 sec
% TEST: Allocating B array
% TEST: took 0.21899986 sec
% TEST: A#B
% TEST: took 40.878000 sec
% TEST: matrix_multipy(A,B)
% TEST: took 42.284000 sec
% TEST: transpose(A)#B
% TEST: took 42.645000 sec
% TEST: matrix_multipy(A,B,/atranspose)
% TEST: took 43.449000 sec
% TEST: transpose(temporary(A))#B
% TEST: took 43.387000 sec
% TEST: matrix_multipy(temporary(A),B,/atranspose)
% TEST: took 50.029000 sec

Code:
;;;;;;;;;;;;;;;;;;;;;;;;;
pro test

nel = 2000L

t0 = systime(1)
message, 'Allocating A array', /info
a = randomu(seed,[nel,nel])
message, 'took '+strtrim(systime(1)-t0,2)+' sec', /info

t0 = systime(1)
message, 'Allocating B array', /info
b = randomu(seed,[nel,nel])
message, 'took '+strtrim(systime(1)-t0,2)+' sec', /info

t0 = systime(1)
message, 'A#B', /info
c = a#b
message, 'took '+strtrim(systime(1)-t0,2)+' sec', /info

t0 = systime(1)
message, 'matrix_multipy(A,B)', /info
c = matrix_multiply(a,b)
message, 'took '+strtrim(systime(1)-t0,2)+' sec', /info

t0 = systime(1)
message, 'transpose(A)#B', /info
c = transpose(a)#b
message, 'took '+strtrim(systime(1)-t0,2)+' sec', /info

t0 = systime(1)
message, 'matrix_multipy(A,B,/atranspose)', /info
c = matrix_multiply(a,b,/atranspose)
message, 'took '+strtrim(systime(1)-t0,2)+' sec', /info

ahold = a

t0 = systime(1)
message, 'transpose(temporary(A))#B', /info
c = transpose(temporary(a))#b
message, 'took '+strtrim(systime(1)-t0,2)+' sec', /info

a = ahold

t0 = systime(1)
message, 'matrix_multipy(temporary(A),B,/atranspose)', /info
c = matrix_multiply(temporary(a),b,/atranspose)
message, 'took '+strtrim(systime(1)-t0,2)+' sec', /info

return
end
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: multislice
Next Topic: Catalyst Library Going Open Source

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sun Oct 12 05:41:26 PDT 2025

Total time taken to generate the page: 0.31958 seconds