x=
bicg (A,b)
¶
x=
bicg (A,b,tol)
¶
x=
bicg (A,b,tol,maxit)
¶
x=
bicg (A,b,tol,maxit,M)
¶
x=
bicg (A,b,tol,maxit,M1,M2)
¶
x=
bicg (A,b,tol,maxit,M, [],x0)
¶
x=
bicg (A,b,tol,maxit,M1,M2,x0)
¶
x=
bicg (A,b,tol,maxit,M, [],x0, …)
¶
x=
bicg (A,b,tol,maxit,M1,M2,x0, …)
¶
[x,flag,relres,iter,resvec] =
bicg (A,b, …)
¶
求解线性方程组A * x = b
采用双共轭梯度迭代法。
输入参数为:
Afcn
使得Afcn (x, "notransp") = A * x
和Afcn (x, "transp") = A' * x
。的附加参数Afcn
可能在之后通过x0.
b - A * x
。如果规范(b - A * x)
≤tol * norm (b)
如果tol则使用1e-6的误差范围。M = M1 * M2
二者都M1和M2可以作为矩阵或函数句柄或内联函数传递g
使得g (x, "notransp") = M1 \ x
或g (x, "notransp") = M2 \ x
和g (x, "transp") = M1' \ x
或g (x, "transp") = M2' \ x
如果M1省略或为空,则不应用预处理。预处理系统在理论上等效于应用bicg
线性系统的方法inv (M1) * A * inv (M2) * y = inv
(M1) * b
和inv (M2') * A' * inv (M1') * z =
inv (M2') * b
然后设置x = inv (M2) * y
.
以下任何参数x0被视为参数,并以适当的方式传递给任何函数(Afcn或Mfcn)或者已经给予bicg
.
输出参数为:
A * x = b
。如果算法没有收敛,那么x是具有最小残差的迭代。eps * norm (x,2)
.
length (resvec) - 1
.
考虑一个三对角矩阵的平凡问题
n = 20; A = toeplitz (sparse ([1, 1], [1, 2], [2, 1] * n ^ 2, 1, n)) + ... toeplitz (sparse (1, 2, -1, 1, n) * n / 2, ... sparse (1, 2, 1, 1, n) * n / 2); b = A * ones (n, 1); restart = 5; [M1, M2] = ilu (A); # in this tridiag case, it corresponds to lu (A) M = M1 * M2; Afcn = @(x, string) strcmp (string, "notransp") * (A * x) + ... strcmp (string, "transp") * (A' * x); Mfcn = @(x, string) strcmp (string, "notransp") * (M \ x) + ... strcmp (string, "transp") * (M' \ x); M1fcn = @(x, string) strcmp (string, "notransp") * (M1 \ x) + ... strcmp (string, "transp") * (M1' \ x); M2fcn = @(x, string) strcmp (string, "notransp") * (M2 \ x) + ... strcmp (string, "transp") * (M2' \ x);
示例1:的最简单用法bicg
x = bicg (A, b)
示例2: bicg
具有一个计算A*x
和A'*x
x = bicg (Afcn, b, [], n)
示例3: bicg
具有预处理矩阵M
x = bicg (A, b, 1e-6, n, M)
示例4: bicg
具有作为预处理器的函数
x = bicg (Afcn, b, 1e-6, n, Mfcn)
示例5: bicg
具有预处理矩阵M1和M2
x = bicg (A, b, 1e-6, n, M1, M2)
示例6: bicg
具有作为预处理器的函数
x = bicg (Afcn, b, 1e-6, n, M1fcn, M2fcn)
示例7: bicg
将需要参数的函数作为输入
function y = Ap (A, x, string, z) ## compute A^z * x or (A^z)' * x y = x; if (strcmp (string, "notransp")) for i = 1:z y = A * y; endfor elseif (strcmp (string, "transp")) for i = 1:z y = A' * y; endfor endif endfunction Apfcn = @(x, string, p) Ap (A, x, string, p); x = bicg (Apfcn, b, [], [], [], [], [], 2);
参考
Y.Saad,Iterative Methods for Sparse Linear Systems,2003年第二版,SIAM。
x=
bicgstab (A,b,tol,maxit,M1,M2,x0, …)
¶
x=
bicgstab (A,b,tol,maxit,M, [],x0, …)
¶
[x,flag,relres,iter,resvec] =
bicgstab (A,b, …)
¶
解决A x = b
使用稳定的双共轭梯度迭代方法。
输入参数为:
Afcn
使得Afcn(x) = A * x
。的附加参数Afcn
在之后通过x0.
b - A * x
。如果规范(b - A * x)
≤tol * norm (b)
如果tol则使用1e-6的误差范围。min (20, numel (b))
使用。M = M1 * M2
二者都M1和M2可以作为矩阵或函数句柄或内联函数传递g
使得g(x) = M1 \ x
或g(x) = M2 \ x
所使用的技术是正确的预处理,即它已被解决A * inv (M) * y = b
然后x = inv (M) * y
.
zeros (size (b))
使用。以下参数x0被视为参数,并以适当的方式传递给任何函数(A或M)传递给bicstab
.
输出参数为:
(A*x-b) / norm(b)
.
iter + 0.5
(length(resvec) - 1) / 2
可以看到执行的(总的)迭代的总数。让我们考虑一个三对角矩阵的平凡问题
n = 20; A = toeplitz (sparse ([1, 1], [1, 2], [2, 1] * n ^ 2, 1, n)) + ... toeplitz (sparse (1, 2, -1, 1, n) * n / 2, ... sparse (1, 2, 1, 1, n) * n / 2); b = A * ones (n, 1); restart = 5; [M1, M2] = ilu (A); # in this tridiag case, it corresponds to lu (A) M = M1 * M2; Afcn = @(x) A * x; Mfcn = @(x) M \ x; M1fcn = @(x) M1 \ x; M2fcn = @(x) M2 \ x;
示例1:的最简单用法bicgstab
x = bicgstab (A, b, [], n)
示例2: bicgstab
具有一个计算A * x
x = bicgstab (Afcn, b, [], n)
示例3: bicgstab
具有预处理矩阵M
x = bicgstab (A, b, [], 1e-06, n, M)
示例4: bicgstab
具有作为预处理器的函数
x = bicgstab (Afcn, b, 1e-6, n, Mfcn)
示例5: bicgstab
具有预处理矩阵M1和M2
x = bicgstab (A, b, [], 1e-6, n, M1, M2)
示例6: bicgstab
具有作为预处理器的函数
x = bicgstab (Afcn, b, 1e-6, n, M1fcn, M2fcn)
示例7: bicgstab
将一个需要参数的函数作为输入
function y = Ap (A, x, z) # compute A^z * x y = x; for i = 1:z y = A * y; endfor endfunction Apfcn = @(x, string, p) Ap (A, x, string, p); x = bicgstab (Apfcn, b, [], [], [], [], [], 2);
示例8:明确的例子表明bicgstab
使用正确的预处理器
[M1, M2] = ilu (A + 0.1 * eye (n)); # factorization of A perturbed M = M1 * M2; ## reference solution computed by bicgstab after one iteration [x_ref, fl] = bicgstab (A, b, [], 1, M) ## right preconditioning [y, fl] = bicgstab (A / M, b, [], 1) x = M \ y # compare x and x_ref
参考
Y.Saad,Iterative Methods for Sparse Linear Systems,2003年第二版,SIAM
x=
cgs (A,b,tol,maxit,M1,M2,x0, …)
¶
x=
cgs (A,b,tol,maxit,M, [],x0, …)
¶
[x,flag,relres,iter,resvec] =
cgs (A,b, …)
¶
解决A x = b
这里的A是一个正方阵,使用共轭梯度平方法。
输入参数为:
Afcn
使得Afcn(x) = A * x
。的附加参数Afcn
在之后通过x0.
min (20, numel (b))
使用。M = M1 * M2
二者都M1和M2可以作为矩阵或函数句柄或内联函数传递g
使得g(x) = M1 \ x
或g(x) = M2 \ x
如果M1为空或未通过,则不应用预处理器。所使用的技术是正确的预处理,即解决A*inv(M)*y = b
然后x = inv(M)*y
.
zeros (size (b))
使用。以下参数x0被视为参数,并以适当的方式传递给任何函数(A或P)传递给cgs
.
输出参数为:
(A*x-b) / norm(b)
.
length (resvec) - 1
可以看到执行的迭代总数。让我们考虑一个三对角矩阵的平凡问题
n = 20; A = toeplitz (sparse ([1, 1], [1, 2], [2, 1] * n ^ 2, 1, n)) + ... toeplitz (sparse (1, 2, -1, 1, n) * n / 2, ... sparse (1, 2, 1, 1, n) * n / 2); b = A * ones (n, 1); restart = 5; [M1, M2] = ilu (A); # in this tridiag case it corresponds to chol (A)' M = M1 * M2; Afcn = @(x) A * x; Mfcn = @(x) M \ x; M1fcn = @(x) M1 \ x; M2fcn = @(x) M2 \ x;
示例1:的最简单用法cgs
x = cgs (A, b, [], n)
示例2: cgs
具有一个计算A * x
x = cgs (Afcn, b, [], n)
示例3: cgs
具有预处理矩阵M
x = cgs (A, b, [], 1e-06, n, M)
示例4: cgs
具有作为预处理器的函数
x = cgs (Afcn, b, 1e-6, n, Mfcn)
示例5: cgs
具有预处理矩阵M1和M2
x = cgs (A, b, [], 1e-6, n, M1, M2)
示例6: cgs
具有作为预处理器的函数
x = cgs (Afcn, b, 1e-6, n, M1fcn, M2fcn)
示例7: cgs
将需要参数的函数作为输入
function y = Ap (A, x, z) # compute A^z * x y = x; for i = 1:z y = A * y; endfor endfunction Apfcn = @(x, string, p) Ap (A, x, string, p); x = cgs (Apfcn, b, [], [], [], [], [], 2);
示例8:明确的例子表明cgs
使用正确的预处理器
[M1, M2] = ilu (A + 0.3 * eye (n)); # factorization of A perturbed M = M1 * M2; ## reference solution computed by cgs after one iteration [x_ref, fl] = cgs (A, b, [], 1, M) ## right preconditioning [y, fl] = cgs (A / M, b, [], 1) x = M \ y # compare x and x_ref
参考文献:
Y.Saad,Iterative Methods for Sparse Linear Systems,2003年第二版,SIAM
x=
gmres (A,b,restart,tol,maxit,M1,M2,x0, …)
¶
x=
gmres (A,b,restart,tol,maxit,M, [],x0, …)
¶
[x,flag,relres,iter,resvec] =
gmres (A,b, …)
¶
解决A x = b
使用带重启的预处理GMRES迭代方法,也称为PGMRES(重启)。
输入参数为:
Afcn
使得Afcn(x) = A * x
。的附加参数Afcn
在之后通过x0.
inv (M) * (b - a * x)
。迭代操作如果标准(inv (M) * (b - a * x))≤tol*标准(inv(M) *B)
如果tol则使用1e-6的误差范围。min (10, N / restart)
使用。请注意,如果restart是空的,那么maxit是最大迭代次数。如果restart和maxit不为空,则最大迭代次数为restart * maxit
.如果两者都有restart和maxit为空,则最大迭代次数设置为min (10, N)
.
M = M1 * M2
二者都M1和M2可以作为矩阵、函数句柄或内联函数传递g
这样g(x) = M1 \ x
或g(x) = M2 \ x
如果M1是[]或未给定,则不应用预处理器。所使用的技术是左预处理,即解决inv(M) * A * x = inv(M) * b
而不是A * x = b
.
zeros (size (b))
使用。以下参数x0被视为参数,并以适当的方式传递给任何函数(A或M或M1或M2)传递到gmres
.
输出为:
连续迭代小于eps)
iter(2) = restart
如果restart为空或N,则1≤iter(2)≤maxit.
更清楚地说,近似x在迭代时计算(iter(1) - 1) * restart + iter(2)
。因为输出x对应于最小预处理边解,该方法执行的迭代总数从下式给出length (resvec) - 1
.
norm (A * x0 - b)
.
让我们考虑一个三对角矩阵的平凡问题
n = 20; A = toeplitz (sparse ([1, 1], [1, 2], [2, 1] * n ^ 2, 1, n)) + ... toeplitz (sparse (1, 2, -1, 1, n) * n / 2, ... sparse (1, 2, 1, 1, n) * n / 2); b = A * ones (n, 1); restart = 5; [M1, M2] = ilu (A); # in this tridiag case, it corresponds to lu (A) M = M1 * M2; Afcn = @(x) A * x; Mfcn = @(x) M \ x; M1fcn = @(x) M1 \ x; M2fcn = @(x) M2 \ x;
示例1:的最简单用法gmres
x = gmres (A, b, [], [], n)
示例2: gmres
具有一个计算A * x
x = gmres (Afcn, b, [], [], n)
示例3:的用法gmres
随着重新启动
x = gmres (A, b, restart);
示例4: gmres
具有预处理矩阵M有无重新启动
x = gmres (A, b, [], 1e-06, n, M) x = gmres (A, b, restart, 1e-06, n, M)
示例5: gmres
具有作为预处理器的函数
x = gmres (Afcn, b, [], 1e-6, n, Mfcn)
示例6: gmres
具有预处理矩阵M1和M2
x = gmres (A, b, [], 1e-6, n, M1, M2)
示例7: gmres
具有作为预处理器的函数
x = gmres (Afcn, b, 1e-6, n, M1fcn, M2fcn)
示例8: gmres
将需要参数的函数作为输入
function y = Ap (A, x, p) # compute A^p * x y = x; for i = 1:p y = A * y; endfor endfunction Apfcn = @(x, p) Ap (A, x, p); x = gmres (Apfcn, b, [], [], [], [], [], [], 2);
示例9:明确的例子表明gmres
使用aleft预处理器
[M1, M2] = ilu (A + 0.1 * eye (n)); # factorization of A perturbed M = M1 * M2; ## reference solution computed by gmres after two iterations [x_ref, fl] = gmres (A, b, [], [], 1, M) ## left preconditioning [x, fl] = gmres (M \ A, M \ b, [], [], 1) x # compare x and x_ref
参考
Y.Saad,Iterative Methods for Sparse Linear Systems,2003年第二版,SIAM
x=
qmr (A,b,rtol,maxit,M1,M2,x0)
¶
x=
qmr (A,b,rtol,maxit,P)
¶
[x,flag,relres,iter,resvec] =
qmr (A,b, …)
¶
解决A x = b
使用准最小残差迭代方法(无需前瞻)。
min (20, numel (b))
使用。zeros (size (b))
使用。A可以作为矩阵或函数句柄或内联函数传递f
使得f(x, "notransp") = A*x
和f(x, "transp") = A'*x
.
预处理器P给定为P = M1 * M2
二者都M1和M2可以作为矩阵或函数句柄或内联函数传递g
使得g(x, "notransp") = M1 \ x
或g(x, "notransp") = M2 \ x
和g(x, "transp") = M1' \ x
或g(x, "transp") = M2' \ x
.
如果使用多个输出参数调用
(值2未使用,但为了兼容性而跳过)。
参考文献:
x=
tfqmr (A,b,tol,maxit,M1,M2,x0, …)
¶
x=
tfqmr (A,b,tol,maxit,M, [],x0, …)
¶
[x,flag,relres,iter,resvec] =
tfqmr (A,b, …)
¶
解决A x = b
使用基于cgs的Transpose Tree qmr方法。
输入参数为:
Afcn
使得Afcn(x) = A * x
。的附加参数Afcn
在之后通过x0.
min (20, numel (b))
使用。为了兼容,因为方法在迭代次数中的不同行为是奇数或偶数,因此在中被视为迭代tfqmr
整个奇偶循环。也就是说,为了进行整个迭代,该算法执行两个子迭代:奇数迭代和偶数迭代。M = M1 * M2
二者都M1和M2可以作为矩阵或函数句柄或内联函数传递g
使得g(x) = M1 \ x
或g(x) = M2 \ x
所使用的技术是正确的预处理,即解决A*inv(M)*y = b
然后x = inv(M)*y
而不是A x = b
.
zeros (size (b))
使用。以下参数x0被视为参数,并以适当的方式传递给任何函数(A或M)传递给tfqmr
.
输出参数为:
(A*x-b) / norm(b)
.
norm (b - A x0)
).正在执行length (resvec) - 1
可以看到执行的迭代总数。让我们考虑一个三对角矩阵的平凡问题
n = 20; A = toeplitz (sparse ([1, 1], [1, 2], [2, 1] * n ^ 2, 1, n)) + ... toeplitz (sparse (1, 2, -1, 1, n) * n / 2, ... sparse (1, 2, 1, 1, n) * n / 2); b = A * ones (n, 1); restart = 5; [M1, M2] = ilu (A); # in this tridiag case it corresponds to chol (A)' M = M1 * M2; Afcn = @(x) A * x; Mfcn = @(x) M \ x; M1fcn = @(x) M1 \ x; M2fcn = @(x) M2 \ x;
示例1:的最简单用法tfqmr
x = tfqmr (A, b, [], n)
示例2: tfqmr
具有一个计算A * x
x = tfqmr (Afcn, b, [], n)
示例3: tfqmr
具有预处理矩阵M
x = tfqmr (A, b, [], 1e-06, n, M)
示例4: tfqmr
具有作为预处理器的函数
x = tfqmr (Afcn, b, 1e-6, n, Mfcn)
示例5: tfqmr
具有预处理矩阵M1和M2
x = tfqmr (A, b, [], 1e-6, n, M1, M2)
示例6: tfmqr
具有作为预处理器的函数
x = tfqmr (Afcn, b, 1e-6, n, M1fcn, M2fcn)
示例7: tfqmr
将需要参数的函数作为输入
function y = Ap (A, x, z) # compute A^z * x y = x; for i = 1:z y = A * y; endfor endfunction Apfcn = @(x, string, p) Ap (A, x, string, p); x = tfqmr (Apfcn, b, [], [], [], [], [], 2);
示例8:明确的例子表明tfqmr
使用正确的预处理器
[M1, M2] = ilu (A + 0.3 * eye (n)); # factorization of A perturbed M = M1 * M2; ## reference solution computed by tfqmr after one iteration [x_ref, fl] = tfqmr (A, b, [], 1, M) ## right preconditioning [y, fl] = tfqmr (A / M, b, [], 1) x = M \ y # compare x and x_ref
参考
Y.Saad,Iterative Methods for Sparse Linear Systems,2003年第二版,SIAM
版权所有 © 2024-2025 Octave中文网
ICP备案/许可证号:黑ICP备2024030411号-2