<html lang="en"> <head> <title>Techniques used for Linear Algebra - Untitled</title> <meta http-equiv="Content-Type" content="text/html"> <meta name="description" content="Untitled"> <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="next" href="Basic-Matrix-Functions.html#Basic-Matrix-Functions" title="Basic Matrix Functions"> <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="Techniques-used-for-Linear-Algebra"></a> <p> Next: <a rel="next" accesskey="n" href="Basic-Matrix-Functions.html#Basic-Matrix-Functions">Basic Matrix Functions</a>, Up: <a rel="up" accesskey="u" href="Linear-Algebra.html#Linear-Algebra">Linear Algebra</a> <hr> </div> <h3 class="section">18.1 Techniques used for Linear Algebra</h3> <p>Octave includes a polymorphic solver, that selects an appropriate matrix factorization depending on the properties of the matrix itself. Generally, the cost of determining the matrix type is small relative to the cost of factorizing the matrix itself, but in any case the matrix type is cached once it is calculated, so that it is not re-determined each time it is used in a linear equation. <p>The selection tree for how the linear equation is solve or a matrix inverse is form is given by <ol type=1 start=1> <li>If the matrix is upper or lower triangular sparse a forward or backward substitution using the <span class="sc">lapack</span> xTRTRS function, and goto 4. <!-- Permuted triangular matrices currently disabled in the code --> <!-- @item If the matrix is a upper triangular matrix with column permutations --> <!-- or lower triangular matrix with row permutations, perform a forward or --> <!-- backward substitution, and goto 5. --> <li>If the matrix is square, hermitian with a real positive diagonal, attempt Cholesky factorization using the <span class="sc">lapack</span> xPOTRF function. <li>If the Cholesky factorization failed or the matrix is not hermitian with a real positive diagonal, and the matrix is square, factorize using the <span class="sc">lapack</span> xGETRF function. <li>If the matrix is not square, or any of the previous solvers flags a singular or near singular matrix, find a least squares solution using the <span class="sc">lapack</span> xGELSD function. </ol> <p>The user can force the type of the matrix with the <code>matrix_type</code> function. This overcomes the cost of discovering the type of the matrix. However, it should be noted that identifying the type of the matrix incorrectly will lead to unpredictable results, and so <code>matrix_type</code> should be used with care. <p>It should be noted that the test for whether a matrix is a candidate for Cholesky factorization, performed above and by the <code>matrix_type</code> function, does not give a certainty that the matrix is Hermitian. However, the attempt to factorize the matrix will quickly flag a non-Hermitian matrix. </body></html>