1function [Q,R,C,p,info] = spqr_wrapper (A, B, tol, Q_option, get_details) 2%SPQR_WRAPPER wrapper around spqr to get additional statistics 3% Not user-callable. Usage: 4% 5% [Q,R,C,p,info] = spqr_wrapper (A, B, tol, Q_option, get_details) ; 6 7% Copyright 2012, Leslie Foster and Timothy A Davis. 8 9if (get_details) 10 % get detailed statistics for time and memory usage 11 t = tic ; 12end 13 14% set the options 15opts.econ = 0 ; % get the rank-sized factorization 16opts.tol = tol ; % columns with norm <= tol treated as zero 17opts.permutation = 'vector' ; % return permutation as a vector, not a matrix 18 19if (~issparse (A)) 20 A = sparse (A) ; % make sure A is sparse 21end 22 23m = size (A,1) ; 24 25if (strcmp (Q_option, 'keep Q')) 26 27 % compute Q*R = A(:,p) and keep Q in Householder form 28 opts.Q = 'Householder' ; 29 [Q,R,p,info] = spqr (A, opts) ; 30 if (isempty (B)) 31 % C is empty 32 C = zeros (m,0) ; 33 else 34 % also compute C = Q'*B if B is present 35 C = spqr_qmult (Q, B, 0) ; 36 end 37 38else 39 40 % compute Q*R = A(:,p), but discard Q 41 opts.Q = 'discard' ; 42 if (isempty (B)) 43 [Q,R,p,info] = spqr (A, opts) ; 44 % C is empty 45 C = zeros (m,0) ; 46 else 47 % also compute C = Q'*B if B is present 48 [C,R,p,info] = spqr (A, B, opts) ; 49 Q = [ ] ; 50 end 51 52end 53 54if (get_details) 55 info.time = toc (t) ; 56end 57 58