Question

It seems to me that in Sage the only difference between creating a dense matrix and a sparse matrix is by the flag passed to the constructor ("sparse=True"). In particular, this means that if I want to create a sparse matrix of size 200,000 x 200,000 but only 500,000 nonzero entries I need first to create a list of size 40,000,000,000, which is absurd. Is there a better way?

Also, as I'm only interested in solving a linear equation system defined by the matrix, I can be satisfied with using a "black box" representation (i.e. give a function g such that g(v)=Av with A being the matrix). This is supported in the underlying LinBox library, but I have no idea what the corresponding Sage interface is.

Was it helpful?

Solution

Use a dictionary to specify sparse matrices

matrix(5000,5000,{(1,2): 1})

OTHER TIPS

And see the Sage reference manual for lots more examples of matrix constructors.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top