Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use eig with the nobalance option as in MATLAB?

In MATLAB I can issue the command:

[X,L] = eig(A,'nobalance'); 

In order to compute the eigenvalues without the balance option.

What is the equivalent command in NumPy? When I run the NumPy version of eig, it does not produce the same result as the MATLAB result with nobalance turned on.

like image 848
Isopycnal Oscillation Avatar asked Dec 17 '13 03:12

Isopycnal Oscillation


2 Answers

You can also consider installing GNU Octave and embed it in Python using oct2py. For example, to determine the eigenvalue of matrix A without balancing,

from oct2py import octave
...
[X,L] = octave.eig(A)

The function eig in Octave does not perform balancing of matrix A.

If you want to balance the matrix A, you can go ahead and write:

from oct2py import octave
...
A = octave.balance(A)
[X,L] = octave.eig(A)

oct2py can be downloaded from this website: https://pypi.python.org/pypi/oct2py

Before you install oct2py, you need to make sure SciPy and GNU Octave have been already installed. Good luck!

like image 92
Jeremy Wong Avatar answered Oct 09 '22 17:10

Jeremy Wong


NumPy can't currently do this. As horchler said, there has been an open ticket open for this for a while now. It is, however, possible to do it using external libraries. Here I write up how to do it using the Python bindings to the NAG library

http://www.walkingrandomly.com/?p=5303

It should be possible to do something similar using any interface to LAPACK such as the Intel MKL etc.

like image 41
WalkingRandomly Avatar answered Oct 09 '22 18:10

WalkingRandomly