Re: How to vectorize functions like eig()
- From: "Arthur G" <gorramfreak+news@xxxxxxxxx>
- Date: Thu, 07 Feb 2008 16:19:09 -0500
On Thu, 07 Feb 2008 12:10:03 -0500, Stephane Carlier <youfellow@xxxxxxxxxxx> wrote:
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"...
If you have access to Maple, you might be able to automatically generate the analytical solution and the corresponding Matlab code, using its CodeGeneration package. However, the analytical roots to the 3rd order polynomials are so complex that I'm guessing you won't gain that much benefit over an iterative approximation.
If you're only concern is calculating eigenvalues as fast as possible, you probably need to switch to a lower level language (C or Fortran), and use libraries that are optimized for your processor (e.g. the Intel Math Kernel Library for Intel processors).
--Arthur
.
- Follow-Ups:
- Re: How to vectorize functions like eig()
- From: Walter Roberson
- Re: How to vectorize functions like eig()
- References:
- How to vectorize functions like eig()
- From: Stephane Carlier
- Re: How to vectorize functions like eig()
- From: Ian Clarkson
- Re: How to vectorize functions like eig()
- From: Stephane Carlier
- How to vectorize functions like eig()
- Prev by Date: Is there such a children?
- Next by Date: Re: Is there such a children?
- Previous by thread: Re: How to vectorize functions like eig()
- Next by thread: Re: How to vectorize functions like eig()
- Index(es):
Relevant Pages
|
Loading