Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > b38d2da330d1936e5ab1307c039c4941 > files > 251

octave-doc-3.6.4-3.mga4.noarch.rpm

<html lang="en">
<head>
<title>Famous Matrices - 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="Matrix-Manipulation.html#Matrix-Manipulation" title="Matrix Manipulation">
<link rel="prev" href="Special-Utility-Matrices.html#Special-Utility-Matrices" title="Special Utility Matrices">
<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="Famous-Matrices"></a>
<p>
Previous:&nbsp;<a rel="previous" accesskey="p" href="Special-Utility-Matrices.html#Special-Utility-Matrices">Special Utility Matrices</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Matrix-Manipulation.html#Matrix-Manipulation">Matrix Manipulation</a>
<hr>
</div>

<h3 class="section">16.4 Famous Matrices</h3>

<p>The following functions return famous matrix forms.

<!-- hadamard scripts/special-matrix/hadamard.m -->
   <p><a name="doc_002dhadamard"></a>

<div class="defun">
&mdash; Function File:  <b>hadamard</b> (<var>n</var>)<var><a name="index-hadamard-1761"></a></var><br>
<blockquote><p>Construct a Hadamard matrix (Hn) of size <var>n</var>-by-<var>n</var>.  The
size <var>n</var> must be of the form 2^k * p in which
p is one of 1, 12, 20 or 28.  The returned matrix is normalized,
meaning <code>Hn(:,1)&nbsp;==&nbsp;1</code><!-- /@w --> and <code>Hn(1,:)&nbsp;==&nbsp;1</code><!-- /@w -->.

        <p>Some of the properties of Hadamard matrices are:

          <ul>
<li><code>kron (Hm, Hn)</code> is a Hadamard matrix of size <var>m</var>-by-<var>n</var>.

          <li><code>Hn * Hn' = </code><var>n</var><code> * eye (</code><var>n</var><code>)</code>.

          <li>The rows of Hn are orthogonal.

          <li><code>det (</code><var>A</var><code>) &lt;= abs (det (Hn))</code> for all <var>A</var> with
<code>abs&nbsp;(</code><var>A</var><code>(i,&nbsp;j))&nbsp;&lt;=&nbsp;1</code><!-- /@w -->.

          <li>Multiplying any row or column by -1 and the matrix will remain a Hadamard
matrix. 
</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_002dcompan.html#doc_002dcompan">compan</a>, <a href="doc_002dhankel.html#doc_002dhankel">hankel</a>, <a href="doc_002dtoeplitz.html#doc_002dtoeplitz">toeplitz</a>. 
</p></blockquote></div>

<!-- hankel scripts/special-matrix/hankel.m -->
   <p><a name="doc_002dhankel"></a>

<div class="defun">
&mdash; Function File:  <b>hankel</b> (<var>c</var>)<var><a name="index-hankel-1762"></a></var><br>
&mdash; Function File:  <b>hankel</b> (<var>c, r</var>)<var><a name="index-hankel-1763"></a></var><br>
<blockquote><p>Return the Hankel matrix constructed from the first column <var>c</var>, and
(optionally) the last row <var>r</var>.  If the last element of <var>c</var> is
not the same as the first element of <var>r</var>, the last element of
<var>c</var> is used.  If the second argument is omitted, it is assumed to
be a vector of zeros with the same size as <var>c</var>.

        <p>A Hankel matrix formed from an m-vector <var>c</var>, and an n-vector
<var>r</var>, has the elements

     <pre class="example">          H(i,j) = c(i+j-1),  i+j-1 &lt;= m;
          H(i,j) = r(i+j-m),  otherwise
</pre>
        <!-- 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_002dhadamard.html#doc_002dhadamard">hadamard</a>, <a href="doc_002dtoeplitz.html#doc_002dtoeplitz">toeplitz</a>. 
</p></blockquote></div>

<!-- hilb scripts/special-matrix/hilb.m -->
   <p><a name="doc_002dhilb"></a>

<div class="defun">
&mdash; Function File:  <b>hilb</b> (<var>n</var>)<var><a name="index-hilb-1764"></a></var><br>
<blockquote><p>Return the Hilbert matrix of order <var>n</var>.  The i,j element
of a Hilbert matrix is defined as

     <pre class="example">          H(i, j) = 1 / (i + j - 1)
</pre>
        <p>Hilbert matrices are close to being singular which make them difficult to
invert with numerical routines. 
Comparing the condition number of a random matrix 5x5 matrix with that of
a Hilbert matrix of order 5 reveals just how difficult the problem is.

     <pre class="example">          cond (rand (5))
             &rArr; 14.392
          cond (hilb (5))
             &rArr; 4.7661e+05
</pre>
        <!-- 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_002dinvhilb.html#doc_002dinvhilb">invhilb</a>. 
</p></blockquote></div>

<!-- invhilb scripts/special-matrix/invhilb.m -->
   <p><a name="doc_002dinvhilb"></a>

<div class="defun">
&mdash; Function File:  <b>invhilb</b> (<var>n</var>)<var><a name="index-invhilb-1765"></a></var><br>
<blockquote><p>Return the inverse of the Hilbert matrix of order <var>n</var>.  This can be
computed exactly using

     <pre class="example">          
                      (i+j)         /n+i-1\  /n+j-1\   /i+j-2\ 2
           A(i,j) = -1      (i+j-1)(       )(       ) (       )
                                    \ n-j /  \ n-i /   \ i-2 /
          
                  = p(i) p(j) / (i+j-1)
</pre>
        <p class="noindent">where

     <pre class="example">                       k  /k+n-1\   /n\
              p(k) = -1  (       ) (   )
                          \ k-1 /   \k/
</pre>
        <p>The validity of this formula can easily be checked by expanding
the binomial coefficients in both formulas as factorials.  It can
be derived more directly via the theory of Cauchy matrices. 
See J. W. Demmel, <cite>Applied Numerical Linear Algebra</cite>, p. 92.

        <p>Compare this with the numerical calculation of <code>inverse (hilb (n))</code>,
which suffers from the ill-conditioning of the Hilbert matrix, and the
finite precision of your computer's floating point arithmetic. 
<!-- 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_002dhilb.html#doc_002dhilb">hilb</a>. 
</p></blockquote></div>

<!-- magic scripts/special-matrix/magic.m -->
   <p><a name="doc_002dmagic"></a>

<div class="defun">
&mdash; Function File:  <b>magic</b> (<var>n</var>)<var><a name="index-magic-1766"></a></var><br>
<blockquote>
        <p>Create an <var>n</var>-by-<var>n</var> magic square.  A magic square is an arrangement
of the integers <code>1:n^2</code> such that the row sums, column sums, and
diagonal sums are all equal to the same value.

        <p>Note: <var>n</var> must be greater than 2 for the magic square to exist. 
</p></blockquote></div>

<!-- pascal scripts/special-matrix/pascal.m -->
   <p><a name="doc_002dpascal"></a>

<div class="defun">
&mdash; Function File:  <b>pascal</b> (<var>n</var>)<var><a name="index-pascal-1767"></a></var><br>
&mdash; Function File:  <b>pascal</b> (<var>n, t</var>)<var><a name="index-pascal-1768"></a></var><br>
<blockquote><p>Return the Pascal matrix of order <var>n</var> if <var>t</var><code> = 0</code>.  <var>t</var>
defaults to 0.  Return the pseudo-lower triangular Cholesky&nbsp;factor of
the Pascal matrix if <var>t</var><code> = 1</code> (The sign of some columns may be
negative).  This matrix is its own inverse, that is <code>pascal (</code><var>n</var><code>,
1) ^ 2 == eye (</code><var>n</var><code>)</code>.  If <var>t</var><code> = -1</code>, return the true
Cholesky&nbsp;factor with strictly positive values on the diagonal.  If
<var>t</var><code> = 2</code>, return a transposed and permuted version of <code>pascal
(</code><var>n</var><code>, 1)</code>, which is the cube root of the identity matrix.  That is,
<code>pascal (</code><var>n</var><code>, 2) ^ 3 == eye (</code><var>n</var><code>)</code>.

     <!-- 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_002dchol.html#doc_002dchol">chol</a>. 
</p></blockquote></div>

<!-- rosser scripts/special-matrix/rosser.m -->
   <p><a name="doc_002drosser"></a>

<div class="defun">
&mdash; Function File:  <b>rosser</b> ()<var><a name="index-rosser-1769"></a></var><br>
<blockquote><p>Return the Rosser matrix.  This is a difficult test case used to evaluate
eigenvalue algorithms.

     <!-- 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_002dwilkinson.html#doc_002dwilkinson">wilkinson</a>, <a href="doc_002deig.html#doc_002deig">eig</a>. 
</p></blockquote></div>

<!-- toeplitz scripts/special-matrix/toeplitz.m -->
   <p><a name="doc_002dtoeplitz"></a>

<div class="defun">
&mdash; Function File:  <b>toeplitz</b> (<var>c</var>)<var><a name="index-toeplitz-1770"></a></var><br>
&mdash; Function File:  <b>toeplitz</b> (<var>c, r</var>)<var><a name="index-toeplitz-1771"></a></var><br>
<blockquote><p>Return the Toeplitz matrix constructed from the first column <var>c</var>,
and (optionally) the first row <var>r</var>.  If the first element of <var>r</var>
is not the same as the first element of <var>c</var>, the first element of
<var>c</var> is used.  If the second argument is omitted, the first row is
taken to be the same as the first column.

        <p>A square Toeplitz matrix has the form:

     <pre class="example">          c(0)  r(1)   r(2)  ...  r(n)
          c(1)  c(0)   r(1)  ... r(n-1)
          c(2)  c(1)   c(0)  ... r(n-2)
           .     .      .   .      .
           .     .      .     .    .
           .     .      .       .  .
          c(n) c(n-1) c(n-2) ...  c(0)
</pre>
        <!-- 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_002dhankel.html#doc_002dhankel">hankel</a>. 
</p></blockquote></div>

<!-- vander scripts/special-matrix/vander.m -->
   <p><a name="doc_002dvander"></a>

<div class="defun">
&mdash; Function File:  <b>vander</b> (<var>c</var>)<var><a name="index-vander-1772"></a></var><br>
&mdash; Function File:  <b>vander</b> (<var>c, n</var>)<var><a name="index-vander-1773"></a></var><br>
<blockquote><p>Return the Vandermonde matrix whose next to last column is <var>c</var>. 
If <var>n</var> is specified, it determines the number of columns;
otherwise, <var>n</var> is taken to be equal to the length of <var>c</var>.

        <p>A Vandermonde matrix has the form:

     <pre class="example">          c(1)^(n-1) ... c(1)^2  c(1)  1
          c(2)^(n-1) ... c(2)^2  c(2)  1
              .     .      .      .    .
              .       .    .      .    .
              .         .  .      .    .
          c(n)^(n-1) ... c(n)^2  c(n)  1
</pre>
        <!-- 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_002dpolyfit.html#doc_002dpolyfit">polyfit</a>. 
</p></blockquote></div>

<!-- wilkinson scripts/special-matrix/wilkinson.m -->
   <p><a name="doc_002dwilkinson"></a>

<div class="defun">
&mdash; Function File:  <b>wilkinson</b> (<var>n</var>)<var><a name="index-wilkinson-1774"></a></var><br>
<blockquote><p>Return the Wilkinson matrix of order <var>n</var>.  Wilkinson matrices are
symmetric and tridiagonal with pairs of nearly, but not exactly, equal
eigenvalues.  They are useful in testing the behavior and performance
of eigenvalue solvers.

     <!-- 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_002drosser.html#doc_002drosser">rosser</a>, <a href="doc_002deig.html#doc_002deig">eig</a>. 
</p></blockquote></div>

<!-- DO NOT EDIT!  Generated automatically by munge-texi.pl. -->
<!-- Copyright (C) 1996-2012 John W. Eaton -->
<!-- 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>