Mercurial > matrix-functions
comparison toolbox/fiedler.m @ 2:c124219d7bfa draft
Re-add the 1995 toolbox after noticing the statement in the ~higham/mctoolbox/ webpage.
author | Antonio Pino Robles <data.script93@gmail.com> |
---|---|
date | Thu, 07 May 2015 18:36:24 +0200 |
parents | 8f23314345f4 |
children |
comparison
equal
deleted
inserted
replaced
1:e471a92d17be | 2:c124219d7bfa |
---|---|
1 function A = fiedler(c) | |
2 %FIEDLER Fiedler matrix - symmetric. | |
3 % A = FIEDLER(C), where C is an n-vector, is the n-by-n symmetric | |
4 % matrix with elements ABS(C(i)-C(j)). | |
5 % Special case: if C is a scalar, then A = FIEDLER(1:C) | |
6 % (i.e. A(i,j) = ABS(i-j)). | |
7 % Properties: | |
8 % FIEDLER(N) has a dominant positive eigenvalue and all the other | |
9 % eigenvalues are negative (Szego, 1936). | |
10 % Explicit formulas for INV(A) and DET(A) are given by Todd (1977) | |
11 % and attributed to Fiedler. These indicate that INV(A) is | |
12 % tridiagonal except for nonzero (1,n) and (n,1) elements. | |
13 % [I think these formulas are valid only if the elements of | |
14 % C are in increasing or decreasing order---NJH.] | |
15 | |
16 % References: | |
17 % G. Szego, Solution to problem 3705, Amer. Math. Monthly, | |
18 % 43 (1936), pp. 246-259. | |
19 % J. Todd, Basic Numerical Mathematics, Vol. 2: Numerical Algebra, | |
20 % Birkhauser, Basel, and Academic Press, New York, 1977, p. 159. | |
21 | |
22 n = max(size(c)); | |
23 | |
24 % Handle scalar c. | |
25 if n == 1 | |
26 n = c; | |
27 c = 1:n; | |
28 end | |
29 | |
30 c = c(:).'; % Ensure c is a row vector. | |
31 | |
32 A = ones(n,1)*c; | |
33 A = abs(A - A.'); % NB. array transpose. |