簡單的求eigenvalues範例:
- #-*-coding:utf-8-*-
- '''
- Created on 2011/4/15
- @author: Hung-Hsin Chen
- simple example for solving eigenvalues
- '''
- import numpy as np
- from scipy import linalg
- #A=[[1 2 3] [4 5 6] [7 8 9]]
- A = np.arange(1,10).reshape(3,3)
- eigvals, eigvecs = linalg.eig(A)
- #eigen vector is column vector
- for i in range(0,3):
- print eigvals[i], eigvecs[:,i]
- #A*X = lambda * X
- print np.dot(A, eigvecs[:,0].transpose())
- print eigvals[0]*eigvecs[:, 0]