SPARSECLEAN - Efficiently cleans a sparse matrix of small values or nan

バージョン 1.2.0.0 (8.02 KB) 作成者: James Tursa
SPARSECLEAN cleans a double sparse matrix of small or nan values or values within a range.
ダウンロード: 446
更新 2013/3/14

ライセンスの表示

SPARSECLEAN is a mex function intended to clean (remove) small values or values within a range from sparse matrices. The operation can produce a newly allocated matrix or operate on the variable inplace.

Building:

SPARSECLEAN requires that a mex routine be built (one time only). This process is typically self-building the first time you call the function as long as you have the files sparseclean.m and sparseclean.c in the same directory somewhere on the MATLAB path. If you need to manually build the mex function, here are the commands:

>> mex -setup
(then follow instructions to select a C or C++ compiler of your choice)
>> mex sparseclean.c

The usage is as follows:

Syntax

B = sparseclean(A [,true])
Cleans a sparse matrix of 0's

B = sparseclean(A,tol [,true])
Cleans a sparse matrix of all abs(A(i)) <= tol

B = sparseclean(A,nan [,true])
Cleans a sparse matrix of all A(i) that are nan

B = sparseclean(A,nan,value [,true])
Replaces all A(i) that are nan with value
If value is complex, then A must also be complex

B = sparseclean(A,lower_tol,upper_tol [,true])
Cleans a real sparse matrix of all lower_tol <= A(i) <= upper_tol
Cleans a complex sparse matrix of all lower_tol <= abs(A(i)) <= upper_tol

Where A = A double sparse matrix
tol, value, lower_tol, and upper_tol = scalar numeric values
true = Forces in-place operation even if A is shared

If B is omitted, then A is cleaned in-place. If A is shared or potentially shared because it is a cell element or struct field element or class property, then an error will be thrown for this in-place case unless you add the true argument. That is, adding true at the end will force the in-place syntax to work regardless of whether A is shared or potentially shared. But doing so risks side effects of changing other variables that are sharing data memory with A!

引用

James Tursa (2024). SPARSECLEAN - Efficiently cleans a sparse matrix of small values or nan (https://www.mathworks.com/matlabcentral/fileexchange/40791-sparseclean-efficiently-cleans-a-sparse-matrix-of-small-values-or-nan), MATLAB Central File Exchange. 取得済み .

MATLAB リリースの互換性
作成: R2007b
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
カテゴリ
Help Center および MATLAB AnswersSparse Matrices についてさらに検索
タグ タグを追加

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
バージョン 公開済み リリース ノート
1.2.0.0

Fixed bug in complex case with real value.

1.1.0.0

Corrects bugs in some of the nan handling cases.

1.0.0.0