Sparse matrix vector product returns null.

4 ビュー (過去 30 日間)
cTroels
cTroels 2024 年 3 月 25 日
コメント済み: John D'Errico 2024 年 3 月 25 日
Hi.
I am computing a sparse matrix vector product.
The product is between a NXN matrix, M, and Nx1 vector, V. When computing the product for a sparse matrix M, matlab returns a empty Nx0 vector. When computing the same product, but using full(M), it returns a non-zero Nx1 vector.
  2 件のコメント
John D'Errico
John D'Errico 2024 年 3 月 25 日
編集済み: John D'Errico 2024 年 3 月 25 日
As is so often the case, probable user error. Almost certainly you have made a mistake. One of your matrices or vectors is not what you think it is.
So IF you really want a useful answer, then post the matrix and the vector, in a .mat file. Without that, we cannot verify that what you say happens, and then we are left with only the obvious conclusion: PROBABLE USER ERROR.
Along the way, if I were you, I would verify that the sparse and full versions of the matrix really are the same things, and that they have the shape and sizes you think they have. Then I would verify the same for the vector. Are you POSITIVE the vector is not a Nx0 vector, thus an empty vector? For example, it is quite easy to create an nx0 vector.
V = zeros(10,0)
V = 10x0 empty double matrix
whos V
Name Size Bytes Class Attributes V 10x0 0 double
It really is far too common here that someone sees something they do not expect, then jumps to the conclusion the problem MUST be in the software, since the user could not possibly have made a mistake.
John D'Errico
John D'Errico 2024 年 3 月 25 日
Looks like I was commenting at the same time as Bruno.

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

採用された回答

Bruno Luong
Bruno Luong 2024 年 3 月 25 日
編集済み: Bruno Luong 2024 年 3 月 25 日
"What can cause this issue?"
Nothing. What you claim likely would not happen.
Unless if you show an example.
  1 件のコメント
cTroels
cTroels 2024 年 3 月 25 日
Well, you were right. Couldnt figure out the issue untill i went to show an example. I accidentally transposed the index instead of the full matrix.

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

その他の回答 (0 件)

カテゴリ

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