comparison main/special-matrix/wilkinson.m @ 0:6b33357c7561 octave-forge

Initial revision
author pkienzle
date Wed, 10 Oct 2001 19:54:49 +0000
parents
children 2ac2777b30bc
comparison
equal deleted inserted replaced
-1:000000000000 0:6b33357c7561
1 ## Copyright (C) 1999 Peter Ekberg
2 ##
3 ## This program is free software; you can redistribute it and/or modify it
4 ## under the terms of the GNU General Public License as published by
5 ## the Free Software Foundation; either version 2, or (at your option)
6 ## any later version.
7 ##
8 ## This program is distributed in the hope that it will be useful, but
9 ## WITHOUT ANY WARRANTY; without even the implied warranty of
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 ## General Public License for more details.
12 ##
13 ## You should have received a copy of the GNU General Public License
14 ## along with this program; see the file COPYING. If not, write to the Free
15 ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA
16 ## 02111-1307, USA.
17
18 ## usage: wilkinson (n)
19 ##
20 ## Return the Wilkinson matrix of order n.
21 ##
22 ## See also: hankel, vander, sylvester_matrix, hilb, invhilb, toeplitz
23 ## hadamard, rosser, compan, pascal
24
25 ## Author: peda
26
27 function retval = wilkinson (n)
28
29 if (nargin != 1)
30 usage ("wilkinson (n)");
31 endif
32
33 nmax = length (n);
34 if ~(nmax == 1)
35 error ("wilkinson: expecting scalar argument, found something else");
36 endif
37
38 side = ones(n-1,1);
39 center = abs(-(n-1)/2:(n-1)/2);
40 retval = diag(side, -1) + diag(center) + diag(side, 1);
41
42 endfunction