Mercurial > matrix-functions
diff toolbox/fiedler.m @ 0:8f23314345f4 draft
Create local repository for matrix toolboxes. Step #0 done.
author | Antonio Pino Robles <data.script93@gmail.com> |
---|---|
date | Wed, 06 May 2015 14:56:53 +0200 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/toolbox/fiedler.m Wed May 06 14:56:53 2015 +0200 @@ -0,0 +1,33 @@ +function A = fiedler(c) +%FIEDLER Fiedler matrix - symmetric. +% A = FIEDLER(C), where C is an n-vector, is the n-by-n symmetric +% matrix with elements ABS(C(i)-C(j)). +% Special case: if C is a scalar, then A = FIEDLER(1:C) +% (i.e. A(i,j) = ABS(i-j)). +% Properties: +% FIEDLER(N) has a dominant positive eigenvalue and all the other +% eigenvalues are negative (Szego, 1936). +% Explicit formulas for INV(A) and DET(A) are given by Todd (1977) +% and attributed to Fiedler. These indicate that INV(A) is +% tridiagonal except for nonzero (1,n) and (n,1) elements. +% [I think these formulas are valid only if the elements of +% C are in increasing or decreasing order---NJH.] + +% References: +% G. Szego, Solution to problem 3705, Amer. Math. Monthly, +% 43 (1936), pp. 246-259. +% J. Todd, Basic Numerical Mathematics, Vol. 2: Numerical Algebra, +% Birkhauser, Basel, and Academic Press, New York, 1977, p. 159. + +n = max(size(c)); + +% Handle scalar c. +if n == 1 + n = c; + c = 1:n; +end + +c = c(:).'; % Ensure c is a row vector. + +A = ones(n,1)*c; +A = abs(A - A.'); % NB. array transpose.