~ubuntu-branches/ubuntu/natty/suitesparse/natty

« back to all changes in this revision

Viewing changes to CXSparse/MATLAB/CSparse/cs_qleft.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 X = cs_qleft (V, Beta, p, Y)
 
2
%CS_QLEFT apply Householder vectors on the left.
 
3
%   X = cs_qleft(V,Beta,p,Y) computes X = Hn*...*H2*H1*P*Y = Q'*Y where Q is
 
4
%   represented by the Householder vectors V, coefficients Beta, and
 
5
%   permutation p.  p can be [], which denotes the identity permutation.
 
6
%
 
7
%   Example:
 
8
%       Prob = UFget ('HB/well1033') ; A = Prob.A ; [m n] = size (A) ;
 
9
%       b = rand (m,1) ;
 
10
%       [V,beta,p,R] = cs_qr (A) ; % QR factorization of A(p,:)
 
11
%       b1 = cs_qleft (V, beta, p, b) ;
 
12
%       x1 = R (1:n,1:n) \ b1 (1:n) ;
 
13
%       x2 = A\b ;
 
14
%       norm (x1-x2)
 
15
%      
 
16
%   See also CS_QR, CS_QRIGHT.
 
17
 
 
18
%   Copyright 2006-2007, Timothy A. Davis.
 
19
%   http://www.cise.ufl.edu/research/sparse
 
20
 
 
21
[m2 n] = size (V) ;
 
22
[m ny] = size (Y) ;
 
23
X = Y ;
 
24
if (m2 > m)
 
25
    if (issparse (Y))
 
26
        X = [X ; sparse(m2-m,ny)] ;
 
27
    else
 
28
        X = [X ; zeros(m2-m,ny)] ;
 
29
    end
 
30
end
 
31
if (~isempty (p))
 
32
    X = X (p,:) ;
 
33
end
 
34
for k = 1:n
 
35
    X = X - V (:,k) * (Beta (k) * (V (:,k)' * X)) ;
 
36
end