Skip to content

Commit 0a750b2

Browse files
committed
new_gmres: fix description again
1 parent c94867d commit 0a750b2

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

tt/solvers.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
# TT-GMRES
88

99

10-
def GMRES(A, x, b, eps=1e-6, maxit=100, m=20, _iteration=0, callback=None, verbose=0):
10+
def GMRES(A, u_0, b, eps=1e-6, maxit=100, m=20, _iteration=0, callback=None, verbose=0):
1111
"""
1212
Flexible TT GMRES
1313
:param A: matvec(x[, eps])
14-
:param x: initial vector
15-
:param b: ansert
16-
:param maxit: max numbr of iterations
14+
:param u_0: initial vector
15+
:param b: answer
16+
:param maxit: max number of iterations
1717
:param eps: required accuracy
1818
:param m: number of iteration without restart
1919
:param _iteration: iteration counter
@@ -24,7 +24,7 @@ def GMRES(A, x, b, eps=1e-6, maxit=100, m=20, _iteration=0, callback=None, verbo
2424
>>> from tt import GMRES
2525
>>> def matvec(x, eps):
2626
>>> return tt.matvec(S, x).round(eps)
27-
>>> answer, res = GMRES(matvec, x_0, b, eps=1e-8)
27+
>>> answer, res = GMRES(matvec, u_0, b, eps=1e-8)
2828
"""
2929
maxitexceeded = False
3030
converged = False
@@ -36,7 +36,7 @@ def GMRES(A, x, b, eps=1e-6, maxit=100, m=20, _iteration=0, callback=None, verbo
3636
g = np.zeros(m)
3737
s = np.ones(m) * np.nan
3838
c = np.ones(m) * np.nan
39-
v[0] = b - A(x, eps=eps)
39+
v[0] = b - A(u_0, eps=eps)
4040
v[0] = v[0].round(eps)
4141
resnorm = v[0].norm()
4242
curr_beta = resnorm
@@ -83,13 +83,13 @@ def GMRES(A, x, b, eps=1e-6, maxit=100, m=20, _iteration=0, callback=None, verbo
8383

8484
y = la.solve_triangular(R[:q, :q], g[:q], check_finite=False)
8585
for idx in range(q):
86-
x += v[idx] * y[idx]
86+
u_0 += v[idx] * y[idx]
8787

88-
x = x.round(eps)
88+
u_0 = u_0.round(eps)
8989

9090
if callback is not None:
91-
callback(x)
91+
callback(u_0)
9292

9393
if converged or maxitexceeded:
94-
return x, resnorm / bnorm
95-
return GMRES(A, x, b, eps, maxit, m, _iteration, callback=callback, verbose=verbose)
94+
return u_0, resnorm / bnorm
95+
return GMRES(A, u_0, b, eps, maxit, m, _iteration, callback=callback, verbose=verbose)

0 commit comments

Comments
 (0)