Skip to content

Implement the sparse diagonal format #47

@albertomercurio

Description

@albertomercurio

SciPy has the scipy.sparse.diags format, that stores the sparse matrix by its nonzero diagonals. In this way we collect a list of diagonals (vectors that might have different lengths) and their corresponding offsets to the center.

I think this is the same format used in packages for quantum like QuTiP or dynamiqs. Something similar seems to be implemented in SparseBandedMatrices.jl, but only for CPU arrays, and I don’t know if it is the same as the other cases.

I don’t know what is the best name for this format. GenericSparseBandedMatrix or GenericSparseDiagMatrix, or others?

It would be good to implement such format, introducing all the methods defined for the other formats, like:

  • mul!(y::DenseVecOrMat, A:: GenericSparseDiagMatrix, x::DenseVecOrMat)
  • tr(A:: GenericSparseDiagMatrix)
  • +(A::AbstractGenericSparseMatrix, B:: AbstractGenericSparseMatrix)
  • *(A:: AbstractGenericSparseMatrix, B:: AbstractGenericSparseMatrix)
  • +(A:: AbstractGenericSparseMatrix, B::DenseMatrix)
  • *(A:: AbstractGenericSparseMatrix, B::DenseMatrix)
  • kron(A:: GenericSparseDiagMatrix, B:: GenericSparseDiagMatrix)
  • dot(x::DenseVector, A:: GenericSparseDiagMatrix, y::DenseVector)
  • Conversion to the other formats
  • Other operations not listed because but that are already implemented for the other formats.

Of course including also the combinations for Transpose and Adjoint.

I don’t know what is the best method to store the list of diagonals. Should we store them in a simple vector? But then do the custo GPU kernels support it? Should we define them in a Tuple? But then this needs to be known at compile time. I don’t know if there are other options.

Everything should be defined without converting to CPU, as for the other formats.

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions