sparse matrix with data type as 'single'

Dear all:
I have a very large sparse matrix that I hope to reduce the size further more. I noticed that in full matrix, one could cast a matrix to a different data type, e.g., from double to single.
A = eye(100);
S = sparse(A);
B = single(eye(100));
S = sparse(B); % error: Undefined function 'sparse' for input arguments of type 'single'.
whos
I am wondering if there is any way to turn non-zero part of a sparse matrix into a data type of single so that I could save half of the space.
Thank you, and I look forward to hearing from you!
Best,
Long

 採用された回答

Mike Croucher
Mike Croucher 2025 年 8 月 13 日

1 投票

This is now supported, starting from MATLAB R2025a. A detailed write up can be found at New in MATLAB: Single precision sparse matrices » The MATLAB Blog - MATLAB & Simulink

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2020 年 6 月 18 日

1 投票

No, that is not supported. sparse() is only supported for double and logical.

5 件のコメント

Long Hong
Long Hong 2020 年 6 月 19 日
Thank you, Walter! Do you happen to know any alternative way to make the storage smaller for sparse matrices?
Walter Roberson
Walter Roberson 2020 年 6 月 19 日
Not while using the defined sparse functions.
What operations are you doing with the matrices? For some restricted operations it might be practical to write replacement sparse routines. However if you are doing something like eigs() or using sparse \ (matrix division) then enough would have to be reimplemented to make it questionable as to whether it is worth doing.
Long Hong
Long Hong 2020 年 6 月 19 日
Thank you for your reply, Walter!
I am using the large sparse matrix to do some basic operations, and two advanced ones - Incomplete Cholesky factorization (ichol) and use preconditioned conjugate gradients method to solve system of linear equations (pcg).
Could you please explain a bit more on the "replacement sparse routines"? I am quite new to the sparse world. Thank you!
Long Hong
Long Hong 2020 年 6 月 19 日
Thank you, Walter! I will check this post out!

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeSparse Matrices についてさらに検索

質問済み:

2020 年 6 月 18 日

回答済み:

2025 年 8 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by