Registered Member
|
Hi
Thanks a million to all the developers and people answering questions. I had a small question. How would we do a DenseMatrix = SparseMatrix*SparseMatrix operation? I am sure such situation arises in many cases, where we know the product is going to be dense, and storing it in sparse form will be very wasteful and cumbersome. Can it be done or is someone thinking of implementing it? Thanks!! |
Registered Member
|
Also, can we do SparseMatrix = DenseMatrix * SparseMatrix?
I would assume people want to use a mix of sparse and dense matrix in many applications. How are people actually using the sparse matrix functionality? Any help would be appreciated. Thanks! |
Moderator
|
About DenseMatrix = SparseMatrix * SparseMatrix, this is currently not supported without evaluating the product to a sparse matrix. However, our sparse matrix product is very good at doing such sparse time sparse products. Basically, you would "only" save memory and two extra copies which have a negligible overhead. Furthermore, sparse matrices are mainly used for very large matrices that you cannot store as a dense one. So all in all, such an optimization is a low priority.
About Sparse = Dense * Sparse, I have to say that I don't see any use case. Indeed, the product of a dense and a sparse matrix can be sparse only if the sparse matrix contains some completely empty columns... Note that Dense = Dense * Sparse is supported though. Finally, I would say that sparse matrices are mainly used to solve very large Ax=b problems where A is sparse, and x and b are dense (or other more complicated equations which boil done to that one). |
Registered Member
|
Hi
hmm... so may be we could use Vector = DenseMatrix * SparseVector on the non-zero columns and then manually assemble the sparse matrix. Can we assemble a sparse matrix from a small number of column vectors? For my case, I think I only have two non-zero columns in my sparse matrix, so the product will be sparse and the vector multiplication should work. Do you think that will work? |
Registered Member
|
So is there a way to convert the resulting sparse matrix to a dense one? By casting, or a dense constructor that takes in a sparse matrix, or a .todense() function on the sparse matrix, or some other method? There must be a way to convert sparse matrice to dense ones. |
Registered Member
|
Yes, it's called .toDense() |
Registered Member
|
Thanks!! That helps a lot. |
Registered users: abc72656, Bing [Bot], daret, Google [Bot], Sogou [Bot], Yahoo [Bot]