pointwise multiplication of sparse matrix with full array
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Sandra Martinez
le 12 Déc 2022
Commenté : Sandra Martinez
le 13 Déc 2022
How can I do this operation?
A=sparse([1 0;0 0]);
B=rand(2,2,2,2);
C=A.*B;
the only way is converting B into a sparse array with this function?
remark: A is sparse but B is not.
0 commentaires
Réponse acceptée
Torsten
le 12 Déc 2022
Modifié(e) : Torsten
le 12 Déc 2022
rand(2,2,2,2) generates a (2x2x2x2) array for B. You cannot multiply A with such a B elementwise because the array sizes don't match.
A=sparse([1 0;0 0]);
B=rand(2,2);
C=A.*B
Or what do you expect as result for B being (2x2x2x2) ?
2 commentaires
Torsten
le 12 Déc 2022
@Sandra Martinez comment moved here:
Yes, I know. But if A is a full matrix this is possible ( in that case matlab makes the pointwisemultiplicación of B(: , : , i,j) with A, for each i,j) The problem here is with a sparse matix and pointwise multiplication
Plus de réponses (1)
Sandra Martinez
le 13 Déc 2022
2 commentaires
Torsten
le 13 Déc 2022
The author of ndSparse (Matt J) is active in this forum.
Maybe you should open a new question where ndSparse is part of the title and ask him directly.
Voir également
Catégories
En savoir plus sur Language Fundamentals dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!