Eigenvector routine....

Discussion in 'C Programming' started by Rob McDonald, Jul 11, 2005.

  1. Rob McDonald

    Rob McDonald Guest

    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
    Rob McDonald, Jul 11, 2005
    #1
    1. Advertising

  2. Rob McDonald

    Sensei Guest

    Rob McDonald wrote:
    > 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.
    Sensei, Jul 12, 2005
    #2
    1. Advertising

  3. Rob McDonald

    Rob Guest

    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


    Sensei wrote:
    > Rob McDonald wrote:
    > > 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.
    Rob, Jul 12, 2005
    #3
  4. Rob McDonald

    jburgy Guest

    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

    Rob McDonald wrote:
    > 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
    jburgy, Jul 12, 2005
    #4
  5. Rob McDonald

    Sensei Guest

    Rob wrote:
    > 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.
    Sensei, Jul 12, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. D. Shane Fowlkes

    just tinkering with a Sub Routine in ASP.NET

    D. Shane Fowlkes, Nov 12, 2003, in forum: ASP .Net
    Replies:
    5
    Views:
    427
    Scott M.
    Nov 13, 2003
  2. =?Utf-8?B?QmlsbCBCb3Jn?=

    Easiest way to get page name from error routine?

    =?Utf-8?B?QmlsbCBCb3Jn?=, Mar 2, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    436
    Tommy
    Mar 3, 2004
  3. =?Utf-8?B?SGVscCE=?=
    Replies:
    0
    Views:
    6,155
    =?Utf-8?B?SGVscCE=?=
    Sep 9, 2004
  4. =?Utf-8?B?S2VubnkgTS4=?=

    coming up with a routine

    =?Utf-8?B?S2VubnkgTS4=?=, Jan 1, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    321
    Jeff Louie
    Jan 1, 2005
  5. drife
    Replies:
    0
    Views:
    454
    drife
    Jan 11, 2005
Loading...

Share This Page