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

« back to all changes in this revision

Viewing changes to CXSparse/MATLAB/Test/lu_rightpr.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,U,P] = lu_rightpr (A)
 
2
%LU_RIGHTPR recursive right-looking LU, with partial pivoting.
 
3
%
 
4
% Example:
 
5
%   [L,U,P] = lu_rightpr (A)
 
6
% See also: cs_demo
 
7
 
 
8
%   Copyright 2006-2007, Timothy A. Davis.
 
9
%   http://www.cise.ufl.edu/research/sparse
 
10
 
 
11
n = size (A,1) ;
 
12
if (n == 1)
 
13
    P = 1 ;
 
14
    L = 1 ;
 
15
    U = A ;
 
16
else
 
17
    [x,i] = max (abs (A (1:n,1))) ;                           % partial pivoting
 
18
    P1 = eye (n) ;
 
19
    P1 ([1 i],:) = P1 ([i 1], :) ;
 
20
    A = P1*A ;
 
21
    u11 = A (1,1) ;                                           % (6.10)
 
22
    u12 = A (1,2:n) ;                                         % (6.11)
 
23
    l21 = A (2:n,1) / u11 ;                                   % (6.12)
 
24
    [L22,U22,P2] = lu_rightpr (A (2:n,2:n) - l21*u12) ;       % (6.9) or (6.13)
 
25
    o = zeros(1,n-1) ;
 
26
    L = [ 1 o ; P2*l21 L22 ] ;                                % (6.14)
 
27
    U = [ u11 u12 ; o' U22 ] ;
 
28
    P = [ 1 o ; o' P2] * P1 ;
 
29
end