Move HilbertIndex to AbstractHilbert
Created by: femtobit
This PR contains the first step towards getting rid of the DirectMatrixWrapper
by removing the need of creating HilbertIndex
objects outside AbstractHilbert
.
With the changes in this PR, only one HilbertIndex
per Hilbert space is created. This happens when AbstractHilbert::GetIndex()
is first called. For non-indexable Hilbert spaces (users can check this by calling AbstractHilbert::IsIndexable()
) this will throw an exeption, which I think is appropriate.
In Python, the Hilbert index can be accessed via the index
property (e.g. dim = hi.index.n_states
).
Note that, due to the way GetIndex()
is implemented, calling to_dense
/to_sparse
on an operator of a non-indexable Hilbert space will also throw an exeption.
The next step is to implement the linear operator functions for AbstractOperator
directly. Let me know what you think of the PR so far, then I'll continue with that part.