1
function rho = lu_normest (A, L, U)
2
% LU_NORMEST: estimate the 1-norm of A-L*U without computing L*U
6
% rho = lu_normest (A, L, U)
8
% which estimates the computation of the 1-norm:
10
% rho = norm (A-L*U, 1)
12
% Authors: William W. Hager, Math Dept., Univ. of Florida
13
% Timothy A. Davis, CISE Dept., Univ. of Florida
14
% Gainesville, FL, 32611, USA.
15
% based on normest1, contributed on November, 1997
17
% This code can be quite easily adapted to estimate the 1-norm of any
18
% matrix E, where E itself is dense or not explicitly represented, but the
19
% computation of E (and E') times a vector is easy. In this case, our matrix
24
% That is, L*U is the LU factorization of A, where A, L and U
25
% are sparse. This code works for dense matrices A and L too,
26
% but it would not be needed in that case, since E is easy to compute
27
% explicitly. For sparse A, L, and U, computing E explicitly would be quite
28
% expensive, and thus normest (A-L*U) would be prohibitive.
30
% For a detailed description, see Davis, T. A. and Hager, W. W.,
31
% Modifying a sparse Cholesky factorization, SIAM J. Matrix Analysis and
32
% Applications, 1999, vol. 20, no. 3, 606-627.
34
% Copyright 2006, William W. Hager and Timothy A. Davis
35
% http://www.cise.ufl.edu/research/sparse
37
% The three places that the matrix-vector multiply E*x is used are
38
% highlighted. Note that E is never formed explicitly.
43
% pad A, L, and U with zeros so that they are all square
45
U = [ U ; (sparse (n-m,n)) ] ;
46
L = [ L , (sparse (m,n-m)) ; (sparse (n-m,n)) ] ;
47
A = [ A ; (sparse (n-m,n)) ] ;
49
U = [ U , (sparse (n,m-n)) ; (sparse (m-n,m)) ] ;
50
L = [ L , (sparse (m,m-n)) ] ;
51
A = [ A , (sparse (m,m-n)) ] ;
57
notvisited = ones (m, 1) ; % nonvisited(j) is zero if j is visited, 1 otherwise
58
rho = 0 ; % the global rho
65
x = notvisited ./ sum (notvisited) ;
66
rho1 = 0 ; % the current rho for this trial
68
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
69
%%% COMPUTE Ex1 = E*x EFFICIENTL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