1
function [C, sym] = get_problem (name, tol)
2
% [C, sym] = get_problem(name,tol)
3
% read a problem from a file, drop entries with abs value < tol
4
% tol defaults to zero if not present
7
% [C, sym] = get_problem ('HB/west0067') ;
10
% Copyright 2006, Timothy A. Davis.
11
% http://www.cise.ufl.edu/research/sparse
13
fprintf ('\n------------------- Matrix: %s\n', name) ;
19
s = find (name == '/') ;
23
f = sprintf ('..%s..%sMatrix%s%s', ...
24
filesep, filesep, filesep, name (s+1:end)) ;
26
% load the triplet version of the matrix
29
% convert into a sparse matrix and compare with cs_sparse
30
A = sparse (T (:,1)+1, T (:,2)+1, T (:,3)) ;
31
A2 = cs_sparse (T (:,1)+1, T (:,2)+1, T (:,3)) ;
34
fprintf ('A difference: %g\n', err) ;
41
A = cs_droptol (A, tol) ;
44
% assume A is symmetric if it is upper or lower triangular
47
C = A + (A' - diag (diag (A))) ;
52
fprintf ('--- Matrix: %d-by-%d, nnz: %d (sym: %d nnz %d), norm: %8.2e\n', ...
53
m, n, nnz(A), sym, abs(sym)*nnz(C), norm (C,1)) ;
56
fprintf ('tiny entries dropped: %d\n', nz2 - nnz(A))