dq.set_layout
set_layout(layout: Literal['dense', 'dia'])
Configure the default matrix layout for operators supporting this option.
Two layouts are supported by most operators (see the list of available operators in the Python API)):
'dense'
: JAX native dense layout,'dia'
: dynamiqs sparse diagonal layout, only non-zero diagonals are stored.
Note
The default layout upon importing dynamiqs is 'dia'
.
Parameters
-
layout
(string 'dense' or 'dia')
–
Default matrix layout for operators.
Examples
>>> dq.eye(4)
QArray: shape=(4, 4), dims=(4,), dtype=complex64, layout=dia, ndiags=1
[[1.+0.j â‹… â‹… â‹… ]
[ â‹… 1.+0.j â‹… â‹… ]
[ â‹… â‹… 1.+0.j â‹… ]
[ â‹… â‹… â‹… 1.+0.j]]
>>> dq.set_layout('dense')
>>> dq.eye(4)
QArray: shape=(4, 4), dims=(4,), dtype=complex64, layout=dense
[[1.+0.j 0.+0.j 0.+0.j 0.+0.j]
[0.+0.j 1.+0.j 0.+0.j 0.+0.j]
[0.+0.j 0.+0.j 1.+0.j 0.+0.j]
[0.+0.j 0.+0.j 0.+0.j 1.+0.j]]
>>> dq.set_layout('dia') # back to default layout