1 <?xml version="1.0" encoding="UTF-8"?>
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) XXXX-2008 - INRIA
6 * This file must be used under the terms of the CeCILL.
7 * This source file is licensed as described in the file COPYING, which
8 * you should have received as part of this distribution. The terms
9 * are also available at
10 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
13 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:lang="en" xml:id="qmr">
15 <refname>qmr</refname>
16 <refpurpose>quasi minimal residual method with preconditioning </refpurpose>
19 <title>Calling Sequence</title>
20 <synopsis>[x,flag,err,iter,res] = qmr(A,Ap,b,x0,M1,M1p,M2,M2p,maxi,tol)
21 [x,flag,err,iter,res] = qmr(A,b,x0,M1,M2,maxi,tol)
25 <title>Arguments</title>
31 matrix of size n-by-n or function.
36 <literal>matrix.</literal>If A is a matrix, it can be
42 <literal>function.</literal>If A is a function which returns <literal>A*x</literal>, it must
43 have the following header :
45 <programlisting role=""><![CDATA[
49 If A is a function which returns <literal>A*x</literal> or <literal>A'*x</literal> depending t.
50 If <literal>t = "notransp"</literal>, the function returns <literal>A*x</literal>.
51 If <literal>t = "transp"</literal>, the function returns <literal>A'*x</literal>. It must
52 have the following header :
54 <programlisting role=""><![CDATA[
55 function y = A ( x, t )
65 function returning <literal>A'*x</literal>. It must have the followinf header :
67 <programlisting role=""><![CDATA[
75 <para>right hand side vector</para>
81 <para>initial guess vector (default: zeros(n,1))</para>
88 left preconditioner : matrix or function (In the first case, default: eye(n,n)). If <literal>M1</literal> is a function, she returns either,
93 only <literal>M1*x</literal>
100 <literal>M1*x</literal> or <literal>M1'*x</literal> depending <literal>t</literal>.
110 must only be provided when <literal>M1</literal> is a function returning <literal>M1*x</literal>.
111 In this case <literal>M1p</literal> is the function which returns <literal>M1'*x</literal>.
119 right preconditioner : matrix or function (In the first case, default: eye(n,n)). If <literal>M2</literal> is a function, she returns either
124 only <literal>M2*x</literal>
131 <literal>M2*x</literal> or <literal>M2'*x</literal> depending <literal>t</literal>.
141 must only be provided when <literal>M2</literal> is a function returning <literal>M2*x</literal>.
142 In this case <literal>M2p</literal> is the function which returns <literal>M2'*x</literal>
149 <para>maximum number of iterations (default: n)
156 <para>error tolerance (default: 1000*%eps)</para>
162 <para>solution vector</para>
170 <para><varname>flag</varname>=0: <code>qmr</code> converged to the desired tolerance within <varname>maxi</varname>
174 <para><varname>flag</varname>=1: no convergence given <varname>maxi</varname>,</para>
177 <para><literal>-7 < flag < 0</literal>: A breakdown occurred because one of the scalar quantities calculated during
178 <code>qmr</code> was equal to zero.</para>
186 <para>residual vector</para>
192 <para>final residual norm</para>
198 <para>number of iterations performed</para>
204 <title>Description</title>
206 Solves the linear system <literal>Ax=b</literal> using the Quasi Minimal Residual Method with preconditioning.
210 <title>Examples</title>
211 <programlisting role="example"><![CDATA[
213 A=[ 94 0 0 0 0 28 0 0 32 0
214 0 59 13 5 0 0 0 10 0 0
215 0 13 72 34 2 0 0 0 0 65
216 0 5 34 114 0 0 0 0 0 55
217 0 0 2 0 70 0 28 32 12 0
218 28 0 0 0 0 87 20 0 33 0
219 0 0 0 0 28 20 71 39 0 0
220 0 10 0 0 32 0 39 46 8 0
221 32 0 0 0 12 33 0 8 82 11
222 0 0 65 55 0 0 0 0 11 100];
224 [x,flag,err,iter,res] = qmr(A, b)
226 [x,flag,err,iter,res] = qmr(A, b, zeros(10,1), eye(10,10), eye(10,10), 10, 1d-12)
228 // If A is a function
229 function y = Atimesx(x,t)
230 A=[ 94 0 0 0 0 28 0 0 32 0
231 0 59 13 5 0 0 0 10 0 0
232 0 13 72 34 2 0 0 0 0 65
233 0 5 34 114 0 0 0 0 0 55
234 0 0 2 0 70 0 28 32 12 0
235 28 0 0 0 0 87 20 0 33 0
236 0 0 0 0 28 20 71 39 0 0
237 0 10 0 0 32 0 39 46 8 0
238 32 0 0 0 12 33 0 8 82 11
239 0 0 65 55 0 0 0 0 11 100];
240 if (t == 'notransp') then
242 elseif (t == 'transp') then
247 [x,flag,err,iter,res] = qmr(Atimesx, b)
249 [x,flag,err,iter,res] = qmr(Atimesx, b, zeros(10,1), eye(10,10), eye(10,10), 10, 1d-12)
254 A = [ 94 0 0 0 0 28 0 0 32 0
255 0 59 13 5 0 0 0 10 0 0
256 0 13 72 34 2 0 0 0 0 65
257 0 5 34 114 0 0 0 0 0 55
258 0 0 2 0 70 0 28 32 12 0
259 28 0 0 0 0 87 20 0 33 0
260 0 0 0 0 28 20 71 39 0 0
261 0 10 0 0 32 0 39 46 8 0
262 32 0 0 0 12 33 0 8 82 11
263 0 0 65 55 0 0 0 0 11 100];
267 function y = funAp(x)
268 A = [ 94 0 0 0 0 28 0 0 32 0
269 0 59 13 5 0 0 0 10 0 0
270 0 13 72 34 2 0 0 0 0 65
271 0 5 34 114 0 0 0 0 0 55
272 0 0 2 0 70 0 28 32 12 0
273 28 0 0 0 0 87 20 0 33 0
274 0 0 0 0 28 20 71 39 0 0
275 0 10 0 0 32 0 39 46 8 0
276 32 0 0 0 12 33 0 8 82 11
277 0 0 65 55 0 0 0 0 11 100];
281 [x,flag,err,iter,res] = qmr(funA, funAp, b)
283 [x,flag,err,iter,res] = qmr(funA, funAp, b, zeros(10,1), eye(10,10), eye(10,10), 10, 1d-12)
285 // If A is a matrix, M1 and M2 are functions
286 function y = M1timesx(x,t)
288 if(t=="notransp") then
290 elseif (t=="transp") then
295 function y = M2timesx(x,t)
297 if(t=="notransp") then
299 elseif (t=="transp") then
304 [x,flag,err,iter,res] = qmr(A, b, zeros(10,1), M1timesx, M2timesx, 10, 1d-12)
308 function y = funM1(x)
313 function y = funM1p(x)
318 function y = funM2(x)
323 function y = funM2p(x)
328 [x,flag,err,iter,res] = qmr(A, b, zeros(10,1), funM1, funM1p, funM2, funM2p, 10, 1d-12)
330 // If A, M1, M2 are functions
331 [x,flag,err,iter,res] = qmr(funA, funAp, b, zeros(10,1), funM1, funM1p, funM2, funM2p, 10, 1d-12)
332 [x,flag,err,iter,res] = qmr(Atimesx, b, zeros(10,1), M1timesx, M2timesx, 10, 1d-12)
336 <refsection role="see also">
337 <title>See Also</title>
338 <simplelist type="inline">
340 <link linkend="gmres">gmres</link>
343 <link linkend="pcg">pcg</link>
348 <title>History</title>
351 <revnumber>5.4.0</revnumber>
353 Calling qmr(A, Ap) is deprecated. qmr(A) should be used instead. The following function is an example :
354 <programlisting role=""><![CDATA[
355 function y = A ( x, t )
357 if ( t== "notransp") then
359 elseif (t == "transp") then