Re: How to vectorize functions like eig()



This is exactly the "for loop" I wish to avoid. I am not
talking about only 4 matrices. Actually the problem I have
involves about 2e6 matrices. I had a similar problem with
2x2 matrices, but luckily I can derive an analytical
solution for eigenvalues for 2x2 matrices. The speed
improvement of my analytical solution vs eig() loop is about
60x faster. For 3x3 matrices, the analytical solution is
still possible. But before I invest all the time in coding
those fairly complicated equations, I wish to know if the
numerical method can be faster than the analytical method.

i could very well be wrong, but i think eig() only takes 2-
d matrices. i'd like to think, though, that the optimizer
should make a for-loop fairly quick if you just indexed the
big array and called eig on its sections:

% 4 3x3 matrices
mat=rand([12 3]);
for i = 1:3:length(mat)
eig(mat(i:i+2,:))
end

something in that form shouldn't be too taxing although
it's not "vectorized"...

.



Relevant Pages

  • Re: How to vectorize functions like eig()
    ... For 3x3 matrices, the analytical solution is ... numerical method can be faster than the analytical method. ... i'd like to think, though, that the optimizer ... If you're only concern is calculating eigenvalues as fast as possible, you probably need to switch to a lower level language, and use libraries that are optimized for your processor (e.g. the Intel Math Kernel Library for Intel processors). ...
    (comp.soft-sys.matlab)
  • Re: Help for a basic problem
    ... If no analytical solution is available, how can I get it, by numerical method? ... by using solveand rectform() in Macsyma. ...
    (sci.math.symbolic)

Loading