Mercurial > matrix-functions
comparison toolbox/augment.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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:8f23314345f4 |
---|---|
1 function C = augment(A, alpha) | |
2 %AUGMENT Augmented system matrix. | |
3 % AUGMENT(A, ALPHA) is the square matrix | |
4 % [ALPHA*EYE(m) A; A' ZEROS(n)] of dimension m+n, where A is m-by-n. | |
5 % It is the symmetric and indefinite coefficient matrix of the | |
6 % augmented system associated with a least squares problem | |
7 % minimize NORM(A*x-b). ALPHA defaults to 1. | |
8 % Special case: if A is a scalar, n say, then AUGMENT(A) is the | |
9 % same as AUGMENT(RANDN(p,q)) where n = p+q and | |
10 % p = ROUND(n/2), that is, a random augmented matrix | |
11 % of dimension n is produced. | |
12 % The eigenvalues of AUGMENT(A) are given in terms of the singular | |
13 % values s(i) of A (where m>n) by | |
14 % 1/2 +/- SQRT( s(i)^2 + 1/4 ), i=1:n (2n eigenvalues), | |
15 % 1, (m-n eigenvalues). | |
16 % If m < n then the first expression provides 2m eigenvalues and the | |
17 % remaining n-m eigenvalues are zero. | |
18 % | |
19 % See also SPAUGMENT. | |
20 | |
21 % Reference: | |
22 % G.H. Golub and C.F. Van Loan, Matrix Computations, Second | |
23 % Edition, Johns Hopkins University Press, Baltimore, Maryland, | |
24 % 1989, sec. 5.6.4. | |
25 | |
26 [m, n] = size(A); | |
27 if nargin < 2, alpha = 1; end | |
28 | |
29 if max(m,n) == 1 | |
30 n = A; | |
31 p = round(n/2); | |
32 q = n - p; | |
33 A = randn(p,q); | |
34 m = p; n = q; | |
35 end | |
36 | |
37 C = [alpha*eye(m) A; A' zeros(n)]; |