Mercurial > octave-antonio
comparison scripts/special-matrix/hilb.m @ 4:b4df021f796c
[project @ 1993-08-08 01:26:08 by jwe]
Initial revision
author | jwe |
---|---|
date | Sun, 08 Aug 1993 01:26:08 +0000 |
parents | |
children | 16a24e76d6e0 |
comparison
equal
deleted
inserted
replaced
3:9a4c07481e61 | 4:b4df021f796c |
---|---|
1 function retval = hilb (n) | |
2 | |
3 # usage: hilb (n) | |
4 # | |
5 # Return the Hilbert matrix of order n. The i, j element of a Hilbert | |
6 # matrix is defined as | |
7 # | |
8 # H (i, j) = 1 / (i + j - 1); | |
9 # | |
10 # See also: hankel, vander, hadamard, invhilb, toeplitz | |
11 | |
12 | |
13 if (nargin != 1) | |
14 error ("usage: hilb (n)"); | |
15 endif | |
16 | |
17 nmax = length (n); | |
18 if (nmax == 1) | |
19 retval = zeros (n); | |
20 for j = 1:n | |
21 for i = 1:n | |
22 retval (i, j) = 1 / (i + j - 1); | |
23 endfor | |
24 endfor | |
25 else | |
26 error ("hilb: expecting scalar argument, found something else"); | |
27 endif | |
28 | |
29 endfunction |