Multiplication of sparse matrix and a normal matrix

49 ビュー (過去 30 日間)
Amit Chakraborty
Amit Chakraborty 2021 年 9 月 25 日
回答済み: Amit Chakraborty 2021 年 9 月 25 日
I have a Sparse Matrix : S
The size of S is : 196608x4096 sparse double
and the normal (Non Sparse) matrix : D
The size of D is : 196608x1 single
Matrix D is full of one . [ means : D= ones(196608,1 )]
I want to multiply them both >> transpose(S)* D;
But showing me some error :
  1. " Error using .* Sparse single array arithmetic operations are not supported."
  2. " Error using * MTIMES (*) is not supported for one sparse argument and one single argument "
Even I tried to convert the matrix D into sparse but showing me following error :
" Error using sparse Input matrix must be double or logical".
Any kind of suggestions to solve this problem will be appreciated.
Thank You !!!
Happy Weekend !!!

採用された回答

Walter Roberson
Walter Roberson 2021 年 9 月 25 日
You are trying to multiply a sparse double precision matrix by a non-sparse single precision matrix.
If you are expecting:
  • sparse double result: use S.' * double(D)
  • sparse single result: not permitted. sparse matrices can only be double precision or logical
  • full double result: use full(S.' * double(D))
  • full single result: use full(S.' * D)

その他の回答 (2 件)

David Goodmanson
David Goodmanson 2021 年 9 月 25 日
Hi Amit,
sum(S)'
where the result is still sparse, or
full(sum(S)')
if you want a regular vector at that point.
  1 件のコメント
Amit Chakraborty
Amit Chakraborty 2021 年 9 月 25 日
I do not want to convert into "full". Because above matrix is just example. Converting into "full" will takes lot of memory.

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


Amit Chakraborty
Amit Chakraborty 2021 年 9 月 25 日
Thank you Both. I have learnt a new thing from you guys.

カテゴリ

Help Center および File ExchangeSparse Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by