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

Function SOAR

python/eigenvalues.py:201–239  ·  view source on GitHub ↗
(A, B, maxiter=200)

Source from the content-addressed store, hash-verified

199# author: A. Schoefl
200
201def SOAR (A, B, maxiter=200):
202# first version without memory saving and breakdown
203
204 q = A.CreateVector()
205 p = A.CreateVector()
206 s = A.CreateVector()
207 r = A.CreateVector()
208
209 Q = MultiVector(q,0)
210 P = MultiVector(p,0)
211 p[:] = 0
212 q.SetRandom()
213 q.FV().imag = 0
214 q /= Norm(q)
215 T = Matrix(maxiter, complex=A.is_complex)
216 T[:,:] = 0
217
218 for j in range(maxiter):
219 Q.Append(q)
220 P.Append(p)
221 r.data = A*q + B*p
222 s.data = q
223
224 for i in range(j+1):
225
226 T[i,j] = InnerProduct(r, Q[i])
227 r -= T[i,j]*Q[i]
228 s -= T[i,j]*P[i]
229
230 if j+1 < maxiter:
231 T[j+1,j] = Norm(r)
232 if T[j+1,j] == 0:
233 print("SOAR stopped at iteration j = ", j)
234 break
235
236 q.data = 1/T[j+1,j]*r
237 p.data = 1/T[j+1,j]*s
238
239 return Q
240
241
242

Callers

nothing calls this directly

Calls 7

AppendMethod · 0.95
NormFunction · 0.85
MultiVectorClass · 0.50
MatrixClass · 0.50
InnerProductFunction · 0.50
CreateVectorMethod · 0.45
FVMethod · 0.45

Tested by

no test coverage detected