Mercurial > hg > octave-nkf
comparison scripts/special-matrix/wilkinson.m @ 5827:1fe78adb91bc
[project @ 2006-05-22 06:25:14 by jwe]
author | jwe |
---|---|
date | Mon, 22 May 2006 06:25:14 +0000 |
parents | |
children | 93c65f2a5668 |
comparison
equal
deleted
inserted
replaced
5826:6c6ff9b82577 | 5827:1fe78adb91bc |
---|---|
1 ## Copyright (C) 1999 Peter Ekberg | |
2 ## | |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7 ## the Free Software Foundation; either version 2, or (at your option) | |
8 ## any later version. | |
9 ## | |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
16 ## along with Octave; see the file COPYING. If not, write to the Free | |
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | |
18 ## 02110-1301, USA. | |
19 | |
20 ## -*- texinfo -*- | |
21 ## @deftypefn {Function File} {} wilkinson (@var{n}) | |
22 ## | |
23 ## Return the Wilkinson matrix of order @var{n}. | |
24 ## | |
25 ## @seealso{hankel, vander, sylvester_matrix, hilb, invhilb, toeplitz | |
26 ## hadamard, rosser, compan, pascal} | |
27 ## @end deftypefn | |
28 | |
29 ## Author: Peter Ekberg | |
30 ## (peda) | |
31 | |
32 function retval = wilkinson (n) | |
33 | |
34 if (nargin != 1) | |
35 print_usage (); | |
36 endif | |
37 | |
38 nmax = length (n); | |
39 if (! (nmax == 1)) | |
40 error ("wilkinson: expecting scalar argument, found something else"); | |
41 endif | |
42 | |
43 side = ones (n-1, 1); | |
44 center = abs (-(n-1)/2:(n-1)/2); | |
45 retval = diag (side, -1) + diag (center) + diag (side, 1); | |
46 | |
47 endfunction |