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

« back to all changes in this revision

Viewing changes to UMFPACK/MATLAB/umfpack_solve.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
1
function x = umfpack_solve (arg1, op, arg2, Control)
2
 
% UMFPACK_SOLVE
 
2
%UMFPACK_SOLVE x = A\b or x = b/A
3
3
%
4
 
% x = umfpack_solve (A, '\', b, Control)
5
 
% x = umfpack_solve (b, '/', A, Control)
 
4
% Example:
 
5
%   x = umfpack_solve (A, '\', b, Control)
 
6
%   x = umfpack_solve (b, '/', A, Control)
6
7
%
7
8
% Computes x = A\b, or b/A, where A is square.  Uses UMFPACK if A is sparse.
8
9
% The Control argument is optional.
9
10
%
10
 
% See also umfpack, umfpack_make, umfpack_details, umfpack_report,
 
11
% See also umfpack, umfpack2, umfpack_make, umfpack_details, umfpack_report,
11
12
% and umfpack_simple.
12
13
 
13
 
% UMFPACK Version 5.0, Copyright (c) 1995-2006 by Timothy A. Davis.
14
 
% All Rights Reserved.  Type umfpack_details for License.
 
14
% Copyright 1995-2007 by Timothy A. Davis.
15
15
 
16
16
%-------------------------------------------------------------------------------
17
17
% check inputs and get default control parameters
35
35
end
36
36
 
37
37
[m1 n1] = size (b) ;
38
 
if ((op == '\' & n ~= m1) | (op == '/' & n1 ~= m))
 
38
if ((op == '\' & n ~= m1) | (op == '/' & n1 ~= m))                          %#ok
39
39
    help umfpack_solve
40
40
    error ('umfpack_solve:  b has the wrong dimensions') ;
41
41
end
42
42
 
43
43
if (nargin < 4)
44
 
    Control = umfpack ;
 
44
    Control = umfpack2 ;
45
45
end
46
46
 
47
47
%-------------------------------------------------------------------------------
55
55
        % A is not sparse, so just use MATLAB
56
56
        x = A\b ;
57
57
 
58
 
    elseif (n1 == 1 & ~issparse (b))
 
58
    elseif (n1 == 1 & ~issparse (b))                                        %#ok
59
59
 
60
60
        % the UMFPACK '\' requires b to be a dense column vector
61
 
        x = umfpack (A, '\', b, Control) ;
 
61
        x = umfpack2 (A, '\', b, Control) ;
62
62
 
63
63
    else
64
64
 
65
65
        % factorize with UMFPACK and do the forward/back solves in MATLAB
66
 
        [L, U, P, Q, R] = umfpack (A, Control) ;
 
66
        [L, U, P, Q, R] = umfpack2 (A, Control) ;
67
67
        x = Q * (U \ (L \ (P * (R \ b)))) ;
68
68
 
69
69
    end
75
75
        % A is not sparse, so just use MATLAB
76
76
        x = b/A ;
77
77
 
78
 
    elseif (m1 == 1 & ~issparse (b))
 
78
    elseif (m1 == 1 & ~issparse (b))                                        %#ok
79
79
 
80
80
        % the UMFPACK '\' requires b to be a dense column vector
81
 
        x = umfpack (b, '/', A, Control) ;
 
81
        x = umfpack2 (b, '/', A, Control) ;
82
82
 
83
83
    else
84
84
 
85
85
        % factorize with UMFPACK and do the forward/back solves in MATLAB
86
86
        % this mimics the behavior of x = b/A, except for the row scaling
87
 
        [L, U, P, Q, R] = umfpack (A.', Control) ;
 
87
        [L, U, P, Q, R] = umfpack2 (A.', Control) ;
88
88
        x = (Q * (U \ (L \ (P * (R \ (b.')))))).' ;
89
89
 
90
90
        % an alternative method:
91
 
        % [L, U, P, Q, r] = umfpack (A, Control) ;
 
91
        % [L, U, P, Q, r] = umfpack2 (A, Control) ;
92
92
        % x = (R \ (P' * (L.' \ (U.' \ (Q' * b.'))))).' ;
93
93
 
94
94
    end