File: spqr_wrapper.m

package info (click to toggle)
suitesparse 1%3A7.10.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 254,920 kB
  • sloc: ansic: 1,134,743; cpp: 46,133; makefile: 4,875; fortran: 2,087; java: 1,826; sh: 996; ruby: 725; python: 495; asm: 371; sed: 166; awk: 44
file content (59 lines) | stat: -rw-r--r-- 1,491 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
function [Q,R,C,p,info] = spqr_wrapper (A, B, tol, Q_option, get_details)
%SPQR_WRAPPER wrapper around spqr to get additional statistics
%   Not user-callable.  Usage:
%
%   [Q,R,C,p,info] = spqr_wrapper (A, B, tol, Q_option, get_details) ;

% spqr_rank, Copyright (c) 2012, Leslie Foster and Timothy A Davis.
% All Rights Reserved.
% SPDX-License-Identifier: BSD-3-clause

if (get_details)
    % get detailed statistics for time and memory usage
    t = tic ;
end

% set the options
opts.econ = 0 ;                 % get the rank-sized factorization
opts.tol = tol ;                % columns with norm <= tol treated as zero
opts.permutation = 'vector' ;   % return permutation as a vector, not a matrix

if (~issparse (A))
    A = sparse (A) ;            % make sure A is sparse
end

m = size (A,1) ;

if (strcmp (Q_option, 'keep Q'))

    % compute Q*R = A(:,p) and keep Q in Householder form
    opts.Q = 'Householder' ;
    [Q,R,p,info] = spqr (A, opts) ;
    if (isempty (B))
        % C is empty
        C = zeros (m,0) ;
    else
        % also compute C = Q'*B if B is present
        C = spqr_qmult (Q, B, 0) ;
    end

else

    % compute Q*R = A(:,p), but discard Q
    opts.Q = 'discard' ;
    if (isempty (B))
        [Q,R,p,info] = spqr (A, opts) ;
        % C is empty
        C = zeros (m,0) ;
    else
        % also compute C = Q'*B if B is present
        [C,R,p,info] = spqr (A, B, opts) ;
        Q = [ ] ;
    end

end

if (get_details)
    info.time = toc (t) ;
end