Looking for a gmic + python scripter to help me out here.

So… I’ve added a command meigen in the stdlib, that approximates the m largest eigenvalues of a square matrix (passed as a selection of the command). It’s really faster than computing all the eigenvalues, but it computes only an approximation of the eigenvalues (the bigger ‘m’, the better approximation). Also, it does not return the associated eigenvectors.

Some examples of timing on my machine:

  • Approximation of the 64 largest eigenvalues for a 1024x1024 matrix takes 0.181 seconds (while eigen takes 36.09 seconds).
  • Approximation of the 32 largest eigenvalues for a 9000x9000 matrix takes 9.288 seconds.

I’ve also added a new equivalent math function meig(A,m,n) that returns a vector(#m) of the approximated eigenvalues from the square matrix A (with size n x n). Include math_lib in your expression to be able to use it.

At this point, I want to say that:

  • I’ve not tested it thoroughly (just on random matrices). Not sure how it behaves with ill-conditionned matrices.
  • I hope this will be useful for you, to solve the OP initial problem. I haven’t followed all the discussion, so I can’t really tell. Let me know if you succeed in using it.
  • If you’re interested by how I did it : https://github.com/dtschump/gmic/commit/178a52a6bd1fde6c0eda58d6939fc3e97a83498f

And of course, as always, a $ gmic update will be necessary to get this new command.

4 Likes