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

« back to all changes in this revision

Viewing changes to LDL/MATLAB/ldlrow.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 [L, D] = ldlrow (A)
 
2
%LDLROW an m-file description of the algorithm used by LDL
 
3
%
 
4
% Example:
 
5
%  [L, D] = ldlrow (A)
 
6
%
 
7
%  Compute the L*D*L' factorization of A, by rows.  Returns
 
8
%  full L and D matrices.  This routine serves as an outline
 
9
%  of the numerical factorization performed by ldl.c.
 
10
%
 
11
%  Here is a diagram of how L is computed.  "a" means an
 
12
%  entry that is accessed at the kth step, and "c" means an
 
13
%  entry that is computed.  A "-" means neither accessed nor
 
14
%  computed.  A "1" means the value of the entry is L (the
 
15
%  unit diagonal of L), and it is accessed at the kth step.
 
16
%  A "." means the value is zero.
 
17
%
 
18
%  The L matrix
 
19
%
 
20
%     1 . . . . . . .
 
21
%     a 1 . . . . . .
 
22
%     a a 1 . . . . .
 
23
%     a a a 1 . . . .
 
24
%     c c c c c . . .  <- kth row of L
 
25
%     - - - - - - . .
 
26
%     - - - - - - - .
 
27
%     - - - - - - - -
 
28
%
 
29
%  The A matrix:
 
30
%
 
31
%             the kth column of A
 
32
%             v
 
33
%     - - - - a - - -
 
34
%     - - - - a - - -
 
35
%     - - - - a - - -
 
36
%     - - - - a - - -
 
37
%     - - - - a - - -  <- kth row of A
 
38
%     - - - - - - - - 
 
39
%     - - - - - - - -
 
40
%     - - - - - - - -
 
41
%
 
42
%  The D matrix:
 
43
%
 
44
%             the kth column of D
 
45
%             v
 
46
%     a . . . . . . .
 
47
%     . a . . . . . .
 
48
%     . . a . . . . .
 
49
%     . . . a . . . .
 
50
%     . . . . c . . .  <- kth row of D
 
51
%     . . . . . . . . 
 
52
%     . . . . . . . .
 
53
%     . . . . . . . .
 
54
%
 
55
% See also ldlsparse.
 
56
 
 
57
% Copyright 2006-2007 by Timothy A. Davis, Univ. of Florida
 
58
 
 
59
[m n] = size (A) ;
 
60
L = zeros (n, n) ;
 
61
D = zeros (n, 1) ;
 
62
A = full (A) ;
 
63
 
 
64
L (1, 1) = 1 ;
 
65
D (1) = A (1,1) ;
 
66
 
 
67
for k = 2:n
 
68
 
 
69
    % note the sparse triangular solve.  For the sparse
 
70
    % case, the pattern of y is the same as the pattern of
 
71
    % the kth row of L.
 
72
    y = L (1:k-1, 1:k-1) \ A (1:k-1, k) ;
 
73
 
 
74
    % scale row k of L
 
75
    L (k, 1:k-1) = (y ./ D (1:k-1))' ;
 
76
    L (k, k) = 1 ;
 
77
 
 
78
    % compute the diagonal
 
79
    D (k) = A (k,k) - L (k, 1:k-1) * y ;
 
80
end
 
81
 
 
82
D = diag (D) ;