Mercurial > matrix-functions
comparison toolbox/cauchy.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 C = cauchy(x, y) | |
2 %CAUCHY Cauchy matrix. | |
3 % C = CAUCHY(X, Y), where X, Y are N-vectors, is the N-by-N matrix | |
4 % with C(i,j) = 1/(X(i)+Y(j)). By default, Y = X. | |
5 % Special case: if X is a scalar CAUCHY(X) is the same as CAUCHY(1:X). | |
6 % Explicit formulas are known for DET(C) (which is nonzero if X and Y | |
7 % both have distinct elements) and the elements of INV(C). | |
8 % C is totally positive if 0 < X(1) < ... < X(N) and | |
9 % 0 < Y(1) < ... < Y(N). | |
10 | |
11 % References: | |
12 % N.J. Higham, Accuracy and Stability of Numerical Algorithms, | |
13 % Society for Industrial and Applied Mathematics, Philadelphia, PA, | |
14 % USA, 1996; sec. 26.1. | |
15 % D.E. Knuth, The Art of Computer Programming, Volume 1, | |
16 % Fundamental Algorithms, second edition, Addison-Wesley, Reading, | |
17 % Massachusetts, 1973, p. 36. | |
18 % E.E. Tyrtyshnikov, Cauchy-Toeplitz matrices and some applications, | |
19 % Linear Algebra and Appl., 149 (1991), pp. 1-18. | |
20 % O. Taussky and M. Marcus, Eigenvalues of finite matrices, in | |
21 % Survey of Numerical Analysis, J. Todd, ed., McGraw-Hill, New York, | |
22 % pp. 279-313, 1962. (States the totally positive property on p. 295.) | |
23 | |
24 n = max(size(x)); | |
25 % Handle scalar x. | |
26 if n == 1 | |
27 n = x; | |
28 x = 1:n; | |
29 end | |
30 | |
31 if nargin == 1, y = x; end | |
32 | |
33 x = x(:); y = y(:); % Ensure x and y are column vectors. | |
34 if any(size(x) ~= size(y)) | |
35 error('Parameter vectors must be of same dimension.') | |
36 end | |
37 | |
38 C = x*ones(1,n) + ones(n,1)*y.'; | |
39 C = ones(n) ./ C; |