Eigenvector routine....

R

Rob McDonald

Does anyone know of a small, simple, freely available Eigenvector routine?

My application has been developed using jacobi.c (and eigsrt.c) from
Numerical Recipes. This works well for me, but the application will soon be
released under the GPL, and the nice folks at NR don't want their source
distributed around. I could just leave stubs in place and require people to
get the routines themselves, but I'd rather replace the routines with
something more available.

I don't really want to introduce a dependency on a large numerical toolkit,
instead, I'd like to just pull in the relevant code. Something small and
simple is preferred over the latest & greatest.

In fact, the problem is nearly trivial. Find the eigenvectors & eigenvalues
of a real, symmetric, 3x3 matrix. Then, all I need is the eigenvector with
the smallest eigenvalue.

With such a small problem, I'm surprised there isn't an even simpler
approach...

Any help will be appreciated,

Rob
 
S

Sensei

Rob said:
Does anyone know of a small, simple, freely available Eigenvector routine?

CBLAS, GSL? Get the source and modify it freely as long as you keep it GPL.
 
R

Rob

Well, in the case of GSL...

http://www.gnu.org/software/gsl/manual/gsl-ref_14.html#SEC233

It isn't exactly what I would call small or simple. It requires the
manual, dynamic allocation & destruction of some bizarre 'workspace'
memory, as well as the use of custom data structures to store matrices
and vectors, instead of plain C arrays.

Large libraries, like these two, use custom data structures to gain
flexibility and performance (sparse matrices, etc.). Consequently, you
can't just sneak in and slip out a simple routine. NR also has this
problem, it wraps arrays such that they are 1-indexed. That way, their
translated FORTRAN looks better...

Besides, the algorithm used by GSL is a bit of a 1000lb gorilla for
this problem.

Maybe I'm asking for too much, but there ought to be a simple
eigenvalue routine laying around somewhere.

Rob
 
J

jburgy

Hi Rob,
even for a 3x3 matrix, finding the lowest eigenvalue is not entirely
trivial. It amounts to finding the zeros of the characteristic equation
which is obviously cubic. Google for Vieta equation (mathworld.com has
a nice explanation)

Good luck,

Jan
 
S

Sensei

Rob said:
Well, in the case of GSL...

http://www.gnu.org/software/gsl/manual/gsl-ref_14.html#SEC233

It isn't exactly what I would call small or simple. It requires the
manual, dynamic allocation & destruction of some bizarre 'workspace'
memory, as well as the use of custom data structures to store matrices
and vectors, instead of plain C arrays.

In fact, I said modify the code :) Get the algorithm and use it. NR is
just the same as gsl, less complicated, with more problems (allocation
and deallocation still are there, as NR use float[] and co, WITHOUT any
particular check)... NR is less sophisticated.

Still, as suggested, check for other available algorithms (Wolfram math
is good).
Maybe I'm asking for too much, but there ought to be a simple
eigenvalue routine laying around somewhere.

No. *IF* the problem is *JUST* 3x3, then you can solve it by hand, and
implement it, just in this case, and in no other.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top