1
function rho = lu_normest (A, L, U)
2
%LU_NORMEST estimates norm (L*U-A, 1) without forming L*U-A
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.
36
% The three places that the matrix-vector multiply E*x is used are highlighted.
37
% Note that E is never formed explicity.
39
% Copyright 1995-2007 by William W. Hager and Timothy A. Davis
44
% pad A, L, and U with zeros so that they are all square
46
U = [ U ; (sparse (n-m,n)) ] ;
47
L = [ L , (sparse (m,n-m)) ; (sparse (n-m,n)) ] ;
48
A = [ A ; (sparse (n-m,n)) ] ;
50
U = [ U , (sparse (n,m-n)) ; (sparse (m-n,m)) ] ;
51
L = [ L , (sparse (m,m-n)) ] ;
52
A = [ A , (sparse (m,m-n)) ] ;
56
[m n] = size (A) ; %#ok
58
notvisited = ones (m, 1) ; % nonvisited(j) is zero if j is visited, 1 otherwise
59
rho = 0 ; % the global rho
63
x = notvisited ./ sum (notvisited) ;
64
rho1 = 0 ; % the current rho for this trial
66
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
67
%%% COMPUTE Ex1 = E*x EFFICIENTLY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