New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dia
data layer
#2196
Dia
data layer
#2196
Conversation
Here are some timing: Sparse matrices composed of one diagonal:
Here for matrices with 5 diagonals:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't do a thorough review, but we have lots of tests for the data layer and I can see you extended them to the new dia
layer.
Happy for this to be merged.
Should we add it to the QuTiP benchmarking suite?
Co-authored-by: Simon Cross <hodgestar+github@gmail.com>
Yes, let's add it to the benchmarks. |
Description
New sparse type:
Dia
.Optimal for diagonal operators such as
qeye
,destroy
. But it's quite bad for vectors ('bra', 'ket').For a tri-diagonal matrix, it's about 25% faster than
CSR
foroper @ dense
.It can do an very efficient
dense @ dia
, whileCSR
is only efficientcsr @ dense
, not the opposite.This include most specializations, change the default in operators, add tests.
The implementation mostly match the one in scipy.
The matrices are stored in two arrays, the diagonals offsets
shape=num_offsets
and the datashape=[num_offsets, ncols]
. The diagonals are lined so that for each entry, the column in the data array match the matrix column.The main differences with scipy's implementation are fixed dtype and the shape of the data array being fixed. (scipy accept longer diagonals and ignore entries outside the matrix.)