Sparse morphism versus sparse matrix

asked 2013-09-16 18:08:35 -0500

mmcconnell gravatar image

updated 2013-09-18 00:25:26 -0500

I would like to use VectorSpaceMorphism when the underlying domain, codomain and matrix are sparse. However, the morphism seems to convert everything to dense. The following is from Sage 5.9.

sage: V = VectorSpace(QQ, 2, sparse=True)
sage: V
Sparse vector space of dimension 2 over Rational Field
sage: A = matrix(QQ, 2, 2, [[5, 6], [7, 8]], sparse=True)
sage: type(A)
sage: f = V.hom(A, V)
sage: f.matrix()
[5 6]
[7 8]
sage: type(f.matrix())

V.hom doesn't take the keyword 'sparse'.

sage: g = V.hom(A, V, sparse=True)
TypeError: hom() got an unexpected keyword argument 'sparse'

Let v be a vector in V, which is sparse. Tests with pdb show that when we call f(v), it converts v to dense behind the scenes, multiplies by the dense matrix, and converts the dense vector result back to sparse. Of course this is slow. The more fundamental issue is that, in some of my applications, A will be too large to store densely.

edit retag flag offensive close merge delete


Looks like a bug to me. You should ask the question on!forum/sage-devel.

vdelecroix gravatar imagevdelecroix ( 2013-09-30 11:16:55 -0500 )edit