MCPcopy Create free account
hub / github.com/NGSolve/ngsolve / Arnoldi

Function Arnoldi

python/eigenvalues.py:169–189  ·  view source on GitHub ↗
(mat, tol=1e-10, maxiter=200)

Source from the content-addressed store, hash-verified

167
168
169def Arnoldi (mat, tol=1e-10, maxiter=200):
170 import scipy.linalg
171 H = Matrix(maxiter,maxiter, complex=mat.is_complex)
172 H[:,:] = 0
173 v = mat.CreateVector(colvector=False)
174 abv = MultiVector(v, 0)
175 v.SetRandom()
176 v /= Norm(v)
177
178 for i in range(maxiter):
179 abv.Append(v)
180 v = (mat*v).Evaluate()
181 for j in range(i+1):
182 H[j,i] = InnerProduct(v, abv[j])
183 v -= H[j,i]*abv[j]
184 if i+1 < maxiter:
185 H[i+1,i] = Norm(v)
186 v = 1/Norm(v)*v
187
188 lam,ev = scipy.linalg.eig(H)
189 return Vector(lam), (abv*Matrix(ev)).Evaluate()
190
191
192

Callers 1

arnoldi.hppFile · 0.85

Calls 8

AppendMethod · 0.95
NormFunction · 0.85
VectorClass · 0.85
MatrixClass · 0.50
MultiVectorClass · 0.50
InnerProductFunction · 0.50
CreateVectorMethod · 0.45
EvaluateMethod · 0.45

Tested by

no test coverage detected