| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 
 | <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: <a rel="previous" accesskey="p" href="Special-Utility-Matrices.html#Special-Utility-Matrices">Special Utility Matrices</a>,
Up: <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">
— 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) == 1</code><!-- /@w --> and <code>Hn(1,:) == 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>) <= abs (det (Hn))</code> for all <var>A</var> with
<code>abs (</code><var>A</var><code>(i, j)) <= 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">
— Function File:  <b>hankel</b> (<var>c</var>)<var><a name="index-hankel-1762"></a></var><br>
— 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 <= 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">
— 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))
             ⇒ 14.392
          cond (hilb (5))
             ⇒ 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">
— 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">
— 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">
— Function File:  <b>pascal</b> (<var>n</var>)<var><a name="index-pascal-1767"></a></var><br>
— 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 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 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">
— 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">
— Function File:  <b>toeplitz</b> (<var>c</var>)<var><a name="index-toeplitz-1770"></a></var><br>
— 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">
— Function File:  <b>vander</b> (<var>c</var>)<var><a name="index-vander-1772"></a></var><br>
— 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">
— 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. -->
<!-- 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>
 |