<html lang="en"> <head> <title>Functions of a Matrix - 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="Matrix-Factorizations.html#Matrix-Factorizations" title="Matrix Factorizations"> <link rel="next" href="Specialized-Solvers.html#Specialized-Solvers" title="Specialized Solvers"> <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="Functions-of-a-Matrix"></a> <p> Next: <a rel="next" accesskey="n" href="Specialized-Solvers.html#Specialized-Solvers">Specialized Solvers</a>, Previous: <a rel="previous" accesskey="p" href="Matrix-Factorizations.html#Matrix-Factorizations">Matrix Factorizations</a>, Up: <a rel="up" accesskey="u" href="Linear-Algebra.html#Linear-Algebra">Linear Algebra</a> <hr> </div> <h3 class="section">18.4 Functions of a Matrix</h3> <!-- expm scripts/linear-algebra/expm.m --> <p><a name="doc_002dexpm"></a> <div class="defun"> — Function File: <b>expm</b> (<var>A</var>)<var><a name="index-expm-2101"></a></var><br> <blockquote><p>Return the exponential of a matrix, defined as the infinite Taylor series <pre class="example"> expm (A) = I + A + A^2/2! + A^3/3! + ... </pre> <p>The Taylor series is <em>not</em> the way to compute the matrix exponential; see Moler and Van Loan, <cite>Nineteen Dubious Ways to Compute the Exponential of a Matrix</cite>, SIAM Review, 1978. This routine uses Ward's diagonal Padé approximation method with three step preconditioning (SIAM Journal on Numerical Analysis, 1977). Diagonal Padé approximations are rational polynomials of matrices <pre class="example"> -1 D (A) N (A) </pre> <p>whose Taylor series matches the first <code>2q+1</code> terms of the Taylor series above; direct evaluation of the Taylor series (with the same preconditioning steps) may be desirable in lieu of the Padé approximation when <code>Dq(A)</code> is ill-conditioned. <!-- 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_002dlogm.html#doc_002dlogm">logm</a>, <a href="doc_002dsqrtm.html#doc_002dsqrtm">sqrtm</a>. </p></blockquote></div> <!-- logm scripts/linear-algebra/logm.m --> <p><a name="doc_002dlogm"></a> <div class="defun"> — Function File: <var>s</var> = <b>logm</b> (<var>A</var>)<var><a name="index-logm-2102"></a></var><br> — Function File: <var>s</var> = <b>logm</b> (<var>A, opt_iters</var>)<var><a name="index-logm-2103"></a></var><br> — Function File: [<var>s</var>, <var>iters</var>] = <b>logm</b> (<var><small class="dots">...</small></var>)<var><a name="index-logm-2104"></a></var><br> <blockquote><p>Compute the matrix logarithm of the square matrix <var>A</var>. The implementation utilizes a Padé approximant and the identity <pre class="example"> logm (<var>A</var>) = 2^k * logm (<var>A</var>^(1 / 2^k)) </pre> <p>The optional argument <var>opt_iters</var> is the maximum number of square roots to compute and defaults to 100. The optional output <var>iters</var> is the number of square roots actually computed. <!-- 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_002dexpm.html#doc_002dexpm">expm</a>, <a href="doc_002dsqrtm.html#doc_002dsqrtm">sqrtm</a>. </p></blockquote></div> <!-- sqrtm src/DLD-FUNCTIONS/sqrtm.cc --> <p><a name="doc_002dsqrtm"></a> <div class="defun"> — Loadable Function: <var>s</var> = <b>sqrtm</b> (<var>A</var>)<var><a name="index-sqrtm-2105"></a></var><br> — Loadable Function: [<var>s</var>, <var>error_estimate</var>] = <b>sqrtm</b> (<var>A</var>)<var><a name="index-sqrtm-2106"></a></var><br> <blockquote><p>Compute the matrix square root of the square matrix <var>A</var>. <p>Ref: N.J. Higham. <cite>A New sqrtm for </cite><span class="sc">matlab</span>. Numerical Analysis Report No. 336, Manchester Centre for Computational Mathematics, Manchester, England, January 1999. <!-- 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_002dexpm.html#doc_002dexpm">expm</a>, <a href="doc_002dlogm.html#doc_002dlogm">logm</a>. </p></blockquote></div> <!-- kron src/DLD-FUNCTIONS/kron.cc --> <p><a name="doc_002dkron"></a> <div class="defun"> — Loadable Function: <b>kron</b> (<var>A, B</var>)<var><a name="index-kron-2107"></a></var><br> — Loadable Function: <b>kron</b> (<var>A1, A2, <small class="dots">...</small></var>)<var><a name="index-kron-2108"></a></var><br> <blockquote><p>Form the Kronecker product of two or more matrices, defined block by block as <pre class="example"> x = [a(i, j) b] </pre> <p>For example: <pre class="example"> kron (1:4, ones (3, 1)) ⇒ 1 2 3 4 1 2 3 4 1 2 3 4 </pre> <p>If there are more than two input arguments <var>A1</var>, <var>A2</var>, <small class="dots">...</small>, <var>An</var> the Kronecker product is computed as <pre class="example"> kron (kron (<var>A1</var>, <var>A2</var>), ..., <var>An</var>) </pre> <p class="noindent">Since the Kronecker product is associative, this is well-defined. </p></blockquote></div> <!-- blkmm src/DLD-FUNCTIONS/dot.cc --> <p><a name="doc_002dblkmm"></a> <div class="defun"> — Loadable Function: <b>blkmm</b> (<var>A, B</var>)<var><a name="index-blkmm-2109"></a></var><br> <blockquote><p>Compute products of matrix blocks. The blocks are given as 2-dimensional subarrays of the arrays <var>A</var>, <var>B</var>. The size of <var>A</var> must have the form <code>[m,k,...]</code> and size of <var>B</var> must be <code>[k,n,...]</code>. The result is then of size <code>[m,n,...]</code> and is computed as follows: <pre class="example"> for i = 1:prod (size (<var>A</var>)(3:end)) <var>C</var>(:,:,i) = <var>A</var>(:,:,i) * <var>B</var>(:,:,i) endfor </pre> </blockquote></div> <!-- syl src/DLD-FUNCTIONS/syl.cc --> <p><a name="doc_002dsyl"></a> <div class="defun"> — Loadable Function: <var>x</var> = <b>syl</b> (<var>A, B, C</var>)<var><a name="index-syl-2110"></a></var><br> <blockquote><p>Solve the Sylvester equation <pre class="example"> A X + X B + C = 0 </pre> <p>using standard <span class="sc">lapack</span> subroutines. For example: <pre class="example"> syl ([1, 2; 3, 4], [5, 6; 7, 8], [9, 10; 11, 12]) ⇒ [ -0.50000, -0.66667; -0.66667, -0.50000 ] </pre> </blockquote></div> </body></html>