Jack Twain
Jack Twain

Reputation: 6372

Left principal eigenvector in scipy or numpy

I need to find the principal left eigenvector of a matrix. How can I do this with numpy or scipy?

Upvotes: 0

Views: 1774

Answers (2)

eickenberg
eickenberg

Reputation: 14377

Using the eigendecomposition of the transpose for example.

import numpy as np
A = np.random.randn(10, 10)
v, V = np.linalg.eig(A.T)

Then left_vec = V[:, 0].T is your vector. Test it by evaluating

print left_vec.dot(A)
print left_vec * v[0]

Upvotes: 2

chthonicdaemon
chthonicdaemon

Reputation: 19760

Use scipy.linalg.eig with left=True and right=False.

Upvotes: 2

Related Questions