Skip to content

cysparse_implementation_overview

Nikolaj edited this page Jul 11, 2015 · 160 revisions

CySparse completion

This is a quick overview of what has already been implemented in the CySparse library (and what is missing).

Two remarks:

  • please, don't edit this page;
  • tested means a full scale test with near 100% coverage. New code is systematically tested but with short tests and for some types, not all of them. Beside, many properties must/should be transferred for some operations (copy, sub matrix, views, etc.). This transfer has not been tested yet.

Class specific implementations

Content

Legend

Sign Sigification
OK.
🔴 Not done.
On hold.
Doesn't apply.
🚫 Could be done... one day but... .

Read-only attributes

Attributes ll_mat csr_mat csc_mat Tested
nrow, ncol 🔴
shape 🔴
nnz 🔴
is_symmetric 🔴
is_hermitian 🚫 🚫 🚫 🚫
store_zeros 🔴
type_name 🔴
type 🔴
dtype, itype 🔴

Note about is_hermitian

I guess the idea is to have the same behavior as for is_symmetric but that would be lots of work. For the moment, symmetric matrices can be constructed by storing only half of their elements. This requires dedicated code all the time (don't forget that our code is quite fine-tuned). Doing the same for hermitian matrices would require lots of work. Maybe later, if the need is real. For the moment, hermitian matrices are stored like normal matrices.

Common operations

Operation ll_mat csr_mat csc_mat Tested Comments
copy 🔴
diag 🔴
diags 🔴
to_ndarray 🔴 Return NumPy equivalent full ndarray matrix.
take_triplet 🔴 🔴 🔴 take
put_triplet 🔴 put: CSR and CSC are immutable matrix types.
find 🔴
tril See note.
triu See note.
get_c_pointers 🔴 C pointers to internal arrays.
get_numpy_arrays 🔴 NumPy arrays to internal arrays (no copy).

Note about tril and triu

Create CSC and CSR with bigger vectors than needed. This doesn't really hurt... LLSparseMatrix versions must be rewritten (with the k parameter).

Proxies in general

Proxy State Tested Comment
.T 🔴
.H 🔴 Only for complex matrices.
.conj 🔴 Only for complex matrices.
LLSparseMatrixView 🔴 Need rewriting now that we decided to drop masks.

Matrix Multiplications

LLSparseMatrix

With Numpy vectors

Operation State Tested Comment
matvec All cases done and optimized. Tests done by comparing results with CSC- and CSRSparseMatrix matrices.
matvec_transp All cases done and optimized. Tests done by comparing results with CSC- and CSRSparseMatrix matrices.
matvec_htransp All cases done and optimized. Tests done by comparing results with CSC- and CSRSparseMatrix matrices.
matvec_conj All cases done and optimized. Tests done by comparing results with CSC- and CSRSparseMatrix matrices.

With 2d matrices

Operation State Tested Comment
matdot 🔴 Done for LLSparseMatrix and NumPy matrices. Not optimized (use of memory views). A * B.
matdot_transp 🔴 Done for LLSparseMatrix and NumPy matrices. Not optimized (use of memory views). A^t * B or A.T * B.
matdot_transp_self 🔴 A^t * A or A.T * A. And the scaled version A^T * D * A with D=diag(d). Only for LLSparseMatrix.

Syntactic sugar

Nothing really stable for the moment.

CSCSparseMatrix

With NumPy vectors

Operation State Tested Comment
matvec All cases done and optimized.Tests done by comparing results with LLSparseMatrix matrices.
matvec_transp All cases done and optimized. Tests done by comparing results with LLSparseMatrix matrices.
matvec_htransp All cases done and optimized. Tests done by comparing results with LLSparseMatrix matrices.
matvec_conj All cases done and optimized. Tests done by comparing results with LLSparseMatrix matrices.

With 2d matrices

Operation State Tested Comment
matdot 🔴 🔴 Nothing done
matdot_transp 🔴 🔴 Nothing done

Syntactic sugar

None

CSRSparseMatrix

With NumPy vectors

Operation State Tested Comment
matvec All cases done and optimized. Tests done by comparing results with LLSparseMatrix matrices.
matvec_transp All cases done and optimized. Tests done by comparing results with LLSparseMatrix matrices.
matvec_htransp All cases done and optimized. Tests done by comparing results with LLSparseMatrix matrices.
matvec_conj All cases done and optimized. Tests done by comparing results with LLSparseMatrix matrices.

With 2d matrices

Operation State Tested Comment
matdot 🔴 🔴 Nothing done
matdot_transp 🔴 🔴 Nothing done

Syntactic sugar

None

LLSparseMatrixView

Nothing!

Syntactic sugar

None

Sparse Matrix proxies

All operations depend on the above implementations... Hooks exist but if above operation is not defined, it will not work...

.T

With NumPy vectors
Operation State Tested Comment
matvec 🔴
matvec_transp 🔴
matvec_htransp 🔴
matvec_conj 🔴

.H

With NumPy vectors
Operation State Tested Comment
matvec 🔴
matvec_transp 🔴
matvec_htransp 🔴
matvec_conj 🔴

.conj

With NumPy vectors
Operation State Tested Comment
matvec 🔴
matvec_transp 🔴
matvec_htransp 🔴
matvec_conj 🔴

Matrix translations

LLSparseMatrix

Operation State Tested Comment
to_ndarray 🔴
to_csc 🔴
to_csr 🔴

CSCSparseMatrix

Operation State Tested Comment
to_ndarray 🔴
to_csc 🚫 🚫
to_csr 🔴

CSRSparseMatrix

Operation State Tested Comment
to_ndarray 🔴
to_csc 🔴
to_csr 🚫 🚫

Special matrices

Matrix State Tested Comment
NewUnityLLSparseMatrix 🔴 speye
spzeros 🆗 🆗 Needed??? By default a sparse matrix is zero.
NewDiagonalLLSparseMatrix 🔴 spdiag
NewBandLLSparseMatrix 🔴 spdiags but more general.
NewArrowheadLLSparseMatrix 🔴 Mainly for testing purpose
NewLinearFillLLSparseMatrix 🔴 Only for testing purpose

Matrix IO (serialization)

To be done.

Matrix printing

Object State Tested Comment
LLSparseMatrix 🔴
LLSparseMatrix.T 🔴
LLSparseMatrix.H 🔴
LLSparseMatrix.conj 🔴
LLSparseMatrixView 🔴
CSCSparseMatrix 🔴
CSCSparseMatrix.T 🔴
CSCSparseMatrix.H 🔴
CSCSparseMatrix.conj 🔴
CSRSparseMatrix 🔴
CSRSparseMatrix.T 🔴
CSRSparseMatrix.H 🔴
CSRSparseMatrix.conj 🔴

Syntactic sugar

Operation State Tested Comment
LLSparseMatrix.__str__ 🔴
LLSparseMatrix.__repr__ 🔴
LLSparseMatrixView.__str__ 🔴
LLSparseMatrixView.__repr__ 🔴
CSCSparseMatrix.__str__ 🔴
CSCSparseMatrix.__repr__ 🔴
CSRSparseMatrix.__str__ 🔴
CSRSparseMatrix.__repr__ 🔴
LLSparseMatrix.T.__str__ 🔴
LLSparseMatrix.T.__repr__ 🔴
LLSparseMatrix.H.__str__ 🔴
LLSparseMatrix.H.__repr__ 🔴
LLSparseMatrix.conj.__str__ 🔴
LLSparseMatrix.conj.__repr__ 🔴

Clone this wiki locally