This forum has been archived. All content is frozen. Please use KDE Discuss instead.

dense = sparse * sparse

Tags: None
(comma "," separated)
baltcode
Registered Member
Posts
12
Karma
0

dense = sparse * sparse

Mon Jan 18, 2010 2:16 pm
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!!
baltcode
Registered Member
Posts
12
Karma
0

Re: dense = sparse * sparse

Tue Jan 19, 2010 2:12 am
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!
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: dense = sparse * sparse

Tue Jan 19, 2010 11:56 am
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).
baltcode
Registered Member
Posts
12
Karma
0

Re: dense = sparse * sparse

Tue Jan 19, 2010 12:32 pm
Hi

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...


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?
baltcode
Registered Member
Posts
12
Karma
0

Re: dense = sparse * sparse

Tue Jan 19, 2010 5:38 pm
About DenseMatrix = SparseMatrix * SparseMatrix, this is currently not supported without evaluating the product to a sparse matrix.
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.
phr
Registered Member
Posts
7
Karma
1

Re: dense = sparse * sparse  Topic is solved

Tue Jan 19, 2010 5:46 pm
baltcode wrote: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.


Yes, it's called .toDense()
baltcode
Registered Member
Posts
12
Karma
0

Re: dense = sparse * sparse

Tue Jan 19, 2010 5:50 pm
phr wrote:Yes, it's called .toDense()


Thanks!! That helps a lot.


Bookmarks



Who is online

Registered users: abc72656, Bing [Bot], daret, Google [Bot], Sogou [Bot], Yahoo [Bot]