<html lang="en"> <head> <title>Specialized Solvers - GNU Octave</title> <meta http-equiv="Content-Type" content="text/html"> <meta name="description" content="GNU Octave"> <meta name="generator" content="makeinfo 4.13"> <link title="Top" rel="start" href="index.html#Top"> <link rel="up" href="Linear-Algebra.html#Linear-Algebra" title="Linear Algebra"> <link rel="prev" href="Functions-of-a-Matrix.html#Functions-of-a-Matrix" title="Functions of a Matrix"> <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> <meta http-equiv="Content-Style-Type" content="text/css"> <style type="text/css"><!-- pre.display { font-family:inherit } pre.format { font-family:inherit } pre.smalldisplay { font-family:inherit; font-size:smaller } pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller } span.sc { font-variant:small-caps } span.roman { font-family:serif; font-weight:normal; } span.sansserif { font-family:sans-serif; font-weight:normal; } --></style> </head> <body> <div class="node"> <a name="Specialized-Solvers"></a> <p> Previous: <a rel="previous" accesskey="p" href="Functions-of-a-Matrix.html#Functions-of-a-Matrix">Functions of a Matrix</a>, Up: <a rel="up" accesskey="u" href="Linear-Algebra.html#Linear-Algebra">Linear Algebra</a> <hr> </div> <h3 class="section">18.5 Specialized Solvers</h3> <!-- bicg scripts/sparse/bicg.m --> <p><a name="doc_002dbicg"></a> <div class="defun"> — Function File: <var>x</var> = <b>bicg</b> (<var>A, b, rtol, maxit, M1, M2, x0</var>)<var><a name="index-bicg-2111"></a></var><br> — Function File: <var>x</var> = <b>bicg</b> (<var>A, b, rtol, maxit, P</var>)<var><a name="index-bicg-2112"></a></var><br> — Function File: [<var>x</var>, <var>flag</var>, <var>relres</var>, <var>iter</var>, <var>resvec</var>] = <b>bicg</b> (<var>A, b, <small class="dots">...</small></var>)<var><a name="index-bicg-2113"></a></var><br> <blockquote><p>Solve <code>A x = b</code> using the Bi-conjugate gradient iterative method. <ul> <li><var>rtol</var> is the relative tolerance, if not given or set to [] the default value 1e-6 is used. <li><var>maxit</var> the maximum number of outer iterations, if not given or set to [] the default value <code>min (20, numel (b))</code> is used. <li><var>x0</var> the initial guess, if not given or set to [] the default value <code>zeros (size (b))</code> is used. </ul> <p><var>A</var> can be passed as a matrix or as a function handle or inline function <code>f</code> such that <code>f(x, "notransp") = A*x</code> and <code>f(x, "transp") = A'*x</code>. <p>The preconditioner <var>P</var> is given as <code>P = M1 * M2</code>. Both <var>M1</var> and <var>M2</var> can be passed as a matrix or as a function handle or inline function <code>g</code> such that <code>g(x, 'notransp') = M1 \ x</code> or <code>g(x, 'notransp') = M2 \ x</code> and <code>g(x, 'transp') = M1' \ x</code> or <code>g(x, 'transp') = M2' \ x</code>. <p>If called with more than one output parameter <ul> <li><var>flag</var> indicates the exit status: <ul> <li>0: iteration converged to the within the chosen tolerance <li>1: the maximum number of iterations was reached before convergence <li>3: the algorithm reached stagnation </ul> (the value 2 is unused but skipped for compatibility). <li><var>relres</var> is the final value of the relative residual. <li><var>iter</var> is the number of iterations performed. <li><var>resvec</var> is a vector containing the relative residual at each iteration. </ul> <!-- Texinfo @sp should work but in practice produces ugly results for HTML. --> <!-- A simple blank line produces the correct behavior. --> <!-- @sp 1 --> <p class="noindent"><strong>See also:</strong> <a href="doc_002dbicgstab.html#doc_002dbicgstab">bicgstab</a>, <a href="doc_002dcgs.html#doc_002dcgs">cgs</a>, <a href="doc_002dgmres.html#doc_002dgmres">gmres</a>, <a href="doc_002dpcg.html#doc_002dpcg">pcg</a>. </blockquote></div> <!-- bicgstab scripts/sparse/bicgstab.m --> <p><a name="doc_002dbicgstab"></a> <div class="defun"> — Function File: <var>x</var> = <b>bicgstab</b> (<var>A, b, rtol, maxit, M1, M2, x0</var>)<var><a name="index-bicgstab-2114"></a></var><br> — Function File: <var>x</var> = <b>bicgstab</b> (<var>A, b, rtol, maxit, P</var>)<var><a name="index-bicgstab-2115"></a></var><br> — Function File: [<var>x</var>, <var>flag</var>, <var>relres</var>, <var>iter</var>, <var>resvec</var>] = <b>bicgstab</b> (<var>A, b, <small class="dots">...</small></var>)<var><a name="index-bicgstab-2116"></a></var><br> <blockquote><p>Solve <code>A x = b</code> using the stabilizied Bi-conjugate gradient iterative method. <ul> <li><var>rtol</var> is the relative tolerance, if not given or set to [] the default value 1e-6 is used. <li><var>maxit</var> the maximum number of outer iterations, if not given or set to [] the default value <code>min (20, numel (b))</code> is used. <li><var>x0</var> the initial guess, if not given or set to [] the default value <code>zeros (size (b))</code> is used. </ul> <p><var>A</var> can be passed as a matrix or as a function handle or inline function <code>f</code> such that <code>f(x) = A*x</code>. <p>The preconditioner <var>P</var> is given as <code>P = M1 * M2</code>. Both <var>M1</var> and <var>M2</var> can be passed as a matrix or as a function handle or inline function <code>g</code> such that <code>g(x) = M1 \ x</code> or <code>g(x) = M2 \ x</code>. <p>If called with more than one output parameter <ul> <li><var>flag</var> indicates the exit status: <ul> <li>0: iteration converged to the within the chosen tolerance <li>1: the maximum number of iterations was reached before convergence <li>3: the algorithm reached stagnation </ul> (the value 2 is unused but skipped for compatibility). <li><var>relres</var> is the final value of the relative residual. <li><var>iter</var> is the number of iterations performed. <li><var>resvec</var> is a vector containing the relative residual at each iteration. </ul> <!-- Texinfo @sp should work but in practice produces ugly results for HTML. --> <!-- A simple blank line produces the correct behavior. --> <!-- @sp 1 --> <p class="noindent"><strong>See also:</strong> <a href="doc_002dbicg.html#doc_002dbicg">bicg</a>, <a href="doc_002dcgs.html#doc_002dcgs">cgs</a>, <a href="doc_002dgmres.html#doc_002dgmres">gmres</a>, <a href="doc_002dpcg.html#doc_002dpcg">pcg</a>. </blockquote></div> <!-- cgs scripts/sparse/cgs.m --> <p><a name="doc_002dcgs"></a> <div class="defun"> — Function File: <var>x</var> = <b>cgs</b> (<var>A, b, rtol, maxit, M1, M2, x0</var>)<var><a name="index-cgs-2117"></a></var><br> — Function File: <var>x</var> = <b>cgs</b> (<var>A, b, rtol, maxit, P</var>)<var><a name="index-cgs-2118"></a></var><br> — Function File: [<var>x</var>, <var>flag</var>, <var>relres</var>, <var>iter</var>, <var>resvec</var>] = <b>cgs</b> (<var>A, b, <small class="dots">...</small></var>)<var><a name="index-cgs-2119"></a></var><br> <blockquote><p>Solve <code>A x = b</code>, where <var>A</var> is a square matrix, using the Conjugate Gradients Squared method. <ul> <li><var>rtol</var> is the relative tolerance, if not given or set to [] the default value 1e-6 is used. <li><var>maxit</var> the maximum number of outer iterations, if not given or set to [] the default value <code>min (20, numel (b))</code> is used. <li><var>x0</var> the initial guess, if not given or set to [] the default value <code>zeros (size (b))</code> is used. </ul> <p><var>A</var> can be passed as a matrix or as a function handle or inline function <code>f</code> such that <code>f(x) = A*x</code>. <p>The preconditioner <var>P</var> is given as <code>P = M1 * M2</code>. Both <var>M1</var> and <var>M2</var> can be passed as a matrix or as a function handle or inline function <code>g</code> such that <code>g(x) = M1 \ x</code> or <code>g(x) = M2 \ x</code>. <p>If called with more than one output parameter <ul> <li><var>flag</var> indicates the exit status: <ul> <li>0: iteration converged to the within the chosen tolerance <li>1: the maximum number of iterations was reached before convergence <li>3: the algorithm reached stagnation </ul> (the value 2 is unused but skipped for compatibility). <li><var>relres</var> is the final value of the relative residual. <li><var>iter</var> is the number of iterations performed. <li><var>resvec</var> is a vector containing the relative residual at each iteration. </ul> <!-- Texinfo @sp should work but in practice produces ugly results for HTML. --> <!-- A simple blank line produces the correct behavior. --> <!-- @sp 1 --> <p class="noindent"><strong>See also:</strong> <a href="doc_002dpcg.html#doc_002dpcg">pcg</a>, <a href="doc_002dbicgstab.html#doc_002dbicgstab">bicgstab</a>, <a href="doc_002dbicg.html#doc_002dbicg">bicg</a>, <a href="doc_002dgmres.html#doc_002dgmres">gmres</a>. </p></blockquote></div> <!-- gmres scripts/sparse/gmres.m --> <p><a name="doc_002dgmres"></a> <div class="defun"> — Function File: <var>x</var> = <b>gmres</b> (<var>A, b, m, rtol, maxit, M1, M2, x0</var>)<var><a name="index-gmres-2120"></a></var><br> — Function File: <var>x</var> = <b>gmres</b> (<var>A, b, m, rtol, maxit, P</var>)<var><a name="index-gmres-2121"></a></var><br> — Function File: [<var>x</var>, <var>flag</var>, <var>relres</var>, <var>iter</var>, <var>resvec</var>] = <b>gmres</b> (<var><small class="dots">...</small></var>)<var><a name="index-gmres-2122"></a></var><br> <blockquote><p>Solve <code>A x = b</code> using the Preconditioned GMRES iterative method with restart, a.k.a. PGMRES(m). <ul> <li><var>rtol</var> is the relative tolerance, if not given or set to [] the default value 1e-6 is used. <li><var>maxit</var> is the maximum number of outer iterations, if not given or set to [] the default value <code>min (10, numel (b) / restart)</code> is used. <li><var>x0</var> is the initial guess, if not given or set to [] the default value <code>zeros(size (b))</code> is used. <li><var>m</var> is the restart parameter, if not given or set to [] the default value <code>numel (b)</code> is used. </ul> <p>Argument <var>A</var> can be passed as a matrix, function handle, or inline function <code>f</code> such that <code>f(x) = A*x</code>. <p>The preconditioner <var>P</var> is given as <code>P = M1 * M2</code>. Both <var>M1</var> and <var>M2</var> can be passed as a matrix, function handle, or inline function <code>g</code> such that <code>g(x) = M1\x</code> or <code>g(x) = M2\x</code>. <p>Besides the vector <var>x</var>, additional outputs are: <ul> <li><var>flag</var> indicates the exit status: <dl> <dt>0 : iteration converged to within the specified tolerance <br><dt>1 : maximum number of iterations exceeded <br><dt>2 : unused, but skipped for compatibility <br><dt>3 : algorithm reached stagnation<dd></dl> <li><var>relres</var> is the final value of the relative residual. <li><var>iter</var> is a vector containing the number of outer iterations and total iterations performed. <li><var>resvec</var> is a vector containing the relative residual at each iteration. </ul> <!-- Texinfo @sp should work but in practice produces ugly results for HTML. --> <!-- A simple blank line produces the correct behavior. --> <!-- @sp 1 --> <p class="noindent"><strong>See also:</strong> <a href="doc_002dbicg.html#doc_002dbicg">bicg</a>, <a href="doc_002dbicgstab.html#doc_002dbicgstab">bicgstab</a>, <a href="doc_002dcgs.html#doc_002dcgs">cgs</a>, <a href="doc_002dpcg.html#doc_002dpcg">pcg</a>. </p></blockquote></div> <!-- DO NOT EDIT! Generated automatically by munge-texi.pl. --> <!-- Copyright (C) 2012 Jordi GutiĆ©rrez Hermoso --> <!-- This file is part of Octave. --> <!-- Octave is free software; you can redistribute it and/or modify it --> <!-- under the terms of the GNU General Public License as published by the --> <!-- Free Software Foundation; either version 3 of the License, or (at --> <!-- your option) any later version. --> <!-- Octave is distributed in the hope that it will be useful, but WITHOUT --> <!-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or --> <!-- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --> <!-- for more details. --> <!-- You should have received a copy of the GNU General Public License --> <!-- along with Octave; see the file COPYING. If not, see --> <!-- <http://www.gnu.org/licenses/>. --> </body></html>