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

« back to all changes in this revision

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