[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
unexpected behavior when multiplying large matrices
From: |
E. Joshua Rigler |
Subject: |
unexpected behavior when multiplying large matrices |
Date: |
01 Dec 2002 12:17:08 -0700 |
I have a rather complicated operation I want to perform with some large
matrices. This is part of an adaptive optimization algorithm that I
seed with the identity matrix, then update with each time-step. That
really isn't important though.
My question is why is there such a huge difference in the processing
time required if, for example:
octave:29> x = eye(1000);
octave:30> y = [1:1000]' * [1:1000];
octave:31> z = [1:1000]'
octave:32> tic; a = 2 * (x - ((x * z * z' * x)/((1/2) + z' * x * z) ) ); toc
ans = 0.59119
octave:33> tic; b = 2 * (y - ((y * z * z' * y)/((1/2) + z' * y * z) ) ); toc
ans = 42.064
octave:34> whos
...
*** local user variables:
prot type rows cols name
==== ==== ==== ==== ====
rwd matrix 1000 1000 a
rwd matrix 1000 1000 b
rwd matrix 1000 1000 x
rwd matrix 1000 1000 y
rwd matrix 1000 1 z
octave:35>
It almost seems like there must be some sort of 'sparse' optimization
involved that knows that x is a diagonal matrix, and avoids the element
by element multiplication when it isn't necessary. I'm using 2.1.35
with all _but_ the most recent octave-forge package installed. Thanks.
--
E. Joshua Rigler <address@hidden>
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
- unexpected behavior when multiplying large matrices,
E. Joshua Rigler <=