Mercurial > octave-libtiff
comparison scripts/sparse/bicgstab.m @ 21178:3be6a07e8bad
maint: Periodic merge of stable to default.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 02 Feb 2016 17:06:11 -0500 |
parents | 516bb87ea72e 2935d56203a4 |
children | c53bfd6d8e08 |
comparison
equal
deleted
inserted
replaced
21177:a10f60e13243 | 21178:3be6a07e8bad |
---|---|
74 | 74 |
75 if (nargin >= 2 && nargin <= 7 && isvector (full (b))) | 75 if (nargin >= 2 && nargin <= 7 && isvector (full (b))) |
76 | 76 |
77 if (ischar (A)) | 77 if (ischar (A)) |
78 A = str2func (A); | 78 A = str2func (A); |
79 elseif (isnumeric(A) && ismatrix (A)) | 79 elseif (isnumeric(A) && issquare (A)) |
80 Ax = @(x) A * x; | 80 Ax = @(x) A * x; |
81 elseif (isa (A, "function_handle")) | 81 elseif (isa (A, "function_handle")) |
82 Ax = @(x) feval (A, x); | 82 Ax = @(x) feval (A, x); |
83 else | 83 else |
84 error ("bicgstab: A must be a square matrix or function"); | 84 error ("bicgstab: A must be a square matrix or function"); |
99 elseif (isnumeric(M1) && ismatrix (M1)) | 99 elseif (isnumeric(M1) && ismatrix (M1)) |
100 M1m1x = @(x) M1 \ x; | 100 M1m1x = @(x) M1 \ x; |
101 elseif (isa (M1, "function_handle")) | 101 elseif (isa (M1, "function_handle")) |
102 M1m1x = @(x) feval (M1, x); | 102 M1m1x = @(x) feval (M1, x); |
103 else | 103 else |
104 error ("bicgstab: preconditioner must be a function or matrix"); | 104 error ("bicgstab: preconditioner M1 must be a function or matrix"); |
105 endif | 105 endif |
106 | 106 |
107 if (nargin < 6 || isempty (M2)) | 107 if (nargin < 6 || isempty (M2)) |
108 M2m1x = @(x) x; | 108 M2m1x = @(x) x; |
109 elseif (ischar (M2)) | 109 elseif (ischar (M2)) |
111 elseif (isnumeric(M2) && ismatrix (M2)) | 111 elseif (isnumeric(M2) && ismatrix (M2)) |
112 M2m1x = @(x) M2 \ x; | 112 M2m1x = @(x) M2 \ x; |
113 elseif (isa (M2, "function_handle")) | 113 elseif (isa (M2, "function_handle")) |
114 M2m1x = @(x) feval (M2, x); | 114 M2m1x = @(x) feval (M2, x); |
115 else | 115 else |
116 error ("bicgstab: preconditioner must be a function or matrix"); | 116 error ("bicgstab: preconditioner M2 must be a function or matrix"); |
117 endif | 117 endif |
118 | 118 |
119 precon = @(x) M2m1x (M1m1x (x)); | 119 precon = @(x) M2m1x (M1m1x (x)); |
120 | 120 |
121 if (nargin < 7 || isempty (x0)) | 121 if (nargin < 7 || isempty (x0)) |