~logan/ubuntu/trusty/suitesparse/4.2.1-3ubuntu1

« back to all changes in this revision

Viewing changes to COLAMD/luflops.m

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Prud'homme
  • Date: 2007-05-29 09:36:29 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070529093629-zowquo0b7slkk6nc
Tags: 3.0.0-2
* suitesparse builds properly twice in a row
* Bug fix: "suitesparse - FTBFS: Broken build depens: libgfortran1-dev",
  thanks to Bastian Blank (Closes: #426349).
* Bug fix: "suitesparse_3.0.0-1: FTBFS: build-depends on
  libgfortran1-dev", thanks to Steve Langasek (Closes: #426354).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
function fl = luflops (L, U)
2
 
%
3
 
%  fl = luflops (L,U)
4
 
%
5
 
%  Given a sparse LU factorization (L and U), return the flop count required
6
 
%  by a conventional LU factorization algorithm to compute it.   L and U can
7
 
%  be either sparse or full matrices.  L must be lower triangular and U must
8
 
%  be upper triangular.  Do not attempt to use this on the permuted L from
9
 
%  [L,U] = lu (A).  Instead, use [L,U,P] = lu (A) or [L,U,P,Q] = lu (A).
10
 
%
11
 
%  Note that there is a subtle undercount in this estimate.  Suppose A is
12
 
%  completely dense, but during LU factorization exact cancellation occurs,
13
 
%  causing some of the entries in L and U to become identically zero.  The
14
 
%  flop count returned by this routine is an undercount.  There is a simple
15
 
%  way to fix this (L = spones (L) + spones (tril (A))), but the fix is partial.
16
 
%  It can also occur that some entry in L is a "symbolic" fill-in (zero in
17
 
%  A, but a fill-in entry and thus must be computed), but numerically
18
 
%  zero.  The only way to get a reliable LU factorization would be to do a
19
 
%  purely symbolic factorization of A.  This cannot be done with
20
 
%  symbfact (A, 'col').
21
 
%
22
 
%  See NA Digest, Vol 00, #50, Tuesday, Dec. 5, 2000
23
 
%
24
 
%  Tim Davis, Sept. 23, 2002.  Written for MATLAB 6.5.
25
 
 
26
 
Lnz = full (sum (spones (L))) - 1 ;     % off diagonal nz in cols of L
27
 
Unz = full (sum (spones (U')))' - 1 ;   % off diagonal nz in rows of U
28
 
fl = 2*Lnz*Unz + sum (Lnz) ;
29