~ubuntu-branches/ubuntu/hardy/suitesparse/hardy

« back to all changes in this revision

Viewing changes to UMFPACK/MATLAB/umfpack_solve.m

  • Committer: Bazaar Package Importer
  • Author(s): Rafael Laboissiere, Rafael Laboissiere, Ondrej Certik
  • Date: 2008-02-21 14:46:50 UTC
  • mfrom: (1.1.2 upstream) (5.1.1 hardy)
  • Revision ID: james.westby@ubuntu.com-20080221144650-tgeppgj0t7s759i8
Tags: 3.1.0-3
[ Rafael Laboissiere ]
* Upload to unstable

[ Ondrej Certik ]
* XS-DM-Upload-Allowed: yes field added
* Ondrej Certik added to uploaders

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
function x = umfpack_solve (arg1, op, arg2, Control)
 
1
function [x, info] = umfpack_solve (arg1, op, arg2, Control)
2
2
%UMFPACK_SOLVE x = A\b or x = b/A
3
3
%
4
4
% Example:
44
44
    Control = umfpack2 ;
45
45
end
46
46
 
 
47
info = [0 0 0] ; % [nnz(L), nnz(U), 0], optional 2nd output
 
48
 
47
49
%-------------------------------------------------------------------------------
48
50
% solve the system
49
51
%-------------------------------------------------------------------------------
58
60
    elseif (n1 == 1 & ~issparse (b))                                        %#ok
59
61
 
60
62
        % the UMFPACK '\' requires b to be a dense column vector
61
 
        x = umfpack2 (A, '\', b, Control) ;
 
63
        [x info] = umfpack2 (A, '\', b, Control) ;
 
64
        info = [info(78) info(79) 0] ;
62
65
 
63
66
    else
64
67
 
65
68
        % factorize with UMFPACK and do the forward/back solves in MATLAB
66
 
        [L, U, P, Q, R] = umfpack2 (A, Control) ;
 
69
        [L, U, P, Q, R, info] = umfpack2 (A, Control) ;
67
70
        x = Q * (U \ (L \ (P * (R \ b)))) ;
 
71
        info = [info(78) info(79) 0] ;
68
72
 
69
73
    end
70
74
 
78
82
    elseif (m1 == 1 & ~issparse (b))                                        %#ok
79
83
 
80
84
        % the UMFPACK '\' requires b to be a dense column vector
81
 
        x = umfpack2 (b, '/', A, Control) ;
 
85
        [x info] = umfpack2 (b, '/', A, Control) ;
 
86
        info = [info(78) info(79) 0] ;
82
87
 
83
88
    else
84
89
 
85
90
        % factorize with UMFPACK and do the forward/back solves in MATLAB
86
91
        % this mimics the behavior of x = b/A, except for the row scaling
87
 
        [L, U, P, Q, R] = umfpack2 (A.', Control) ;
 
92
        [L, U, P, Q, R, info] = umfpack2 (A.', Control) ;
88
93
        x = (Q * (U \ (L \ (P * (R \ (b.')))))).' ;
 
94
        info = [info(78) info(79) 0] ;
89
95
 
90
96
        % an alternative method:
91
97
        % [L, U, P, Q, r] = umfpack2 (A, Control) ;