Skip to content

Commit 3538330

Browse files
committed
Initial commit
1 parent 6c46e22 commit 3538330

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

SparseArrayToolbox.pdf

-852 Bytes
Binary file not shown.

spTol.m

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
function spC = spTol(spA,tol)
2+
%SPTOL Remove all entries with magnitudes smaller than 'tol'.
3+
% spC = spTol(spA,tol): Remove all entries from a full array -- represented
4+
% as a sparse array structure or a full array -- with magnitudes smaller than
5+
% 'tol'. The output is a sparse array structure
6+
%
7+
% Version 1.0 by Andrew J. Milne, The MARCS Institute, Western Sydney
8+
% University, 2018-01-16
9+
%
10+
% See also SPTRUNC.
11+
12+
% If full array, convert to sparse array structure
13+
if ~isstruct(spA)
14+
spA = array2spArray(spA);
15+
end
16+
17+
indA = spA.Ind(abs(spA.Val-0)>tol);
18+
valA = spA.Val(abs(spA.Val-0)>tol);
19+
20+
% Make the sparse aray structure
21+
spC = struct('Size',spA.Size,'Ind',indA,'Val',valA);
22+
23+
end
24+

0 commit comments

Comments
 (0)