In [23]:
from arnoldi import arnoldi
import numpy as np
np.set_printoptions(precision=1)
In [24]:
A = np.random.rand(5,5)
B = A.T.dot(A)
In [25]:
V, H = arnoldi(A, 4)
print(np.around(H, decimals=1))
[[ 2.5  0.  -0.3  0.9]
 [ 0.8 -0.2 -0.   0.2]
 [ 0.   0.1 -0.7  0.4]
 [ 0.   0.   0.1 -0.4]]
In [26]:
V, H = arnoldi(B, 4)
print(np.around(H, decimals=1))
[[ 6.7  3.1 -0.   0. ]
 [ 3.1  1.7  0.4  0. ]
 [ 0.   0.4  0.6  0.2]
 [ 0.   0.   0.2  0.1]]
In [27]:
V.T.dot(V)
Out[27]:
array([[  1.0e+00,   4.0e-16,  -5.1e-17,  -5.7e-16],
       [  4.0e-16,   1.0e+00,  -1.1e-15,   4.4e-15],
       [ -5.1e-17,  -1.1e-15,   1.0e+00,  -1.8e-17],
       [ -5.7e-16,   4.4e-15,  -1.8e-17,   1.0e+00]])
In [18]:
A = np.array([[1,0,0],[2,1,0],[0,3,1]])