Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change removes all the
similarmatrix
API. Having to allocate a matrix before being able to have a reusablebloch!
is cumbersome. This PR partially restores the older design changed in pablosanjose/Elsa.jl#28The
similarmatrix
is allocated upon creating ahamiltonian
and its type can now be controlled with the keywordblochtype
. We can thus have a multiorbitalh::Hamiltonian
that carries inside a flatblochmatrix
to be returned when callingbloch!(h, ...)
. To avoid allocating such a matrix at each step of any transformation, we carry over the same matrix at any transformation step that preserves its size and eltype.We can then now do
We have also the special syntax
Together with this we can also change the
blochtype
of aHamiltonian
orParametricHamiltonian
h
withAnother benefit is that we get rid of the pesky
optimize!
function. The (Parametric)Hamiltonian harmonics don't need to pre-store any structural zeros to avoid sparse splicing. We just optimize the internalizedblochmatrix
upon creation, in accordance with the elements of all harmonics (function_similar_merged_sparse
now).This opens the door to having
h(ϕs; params...)
as a shorthand forbloch(h(; params...), ϕs)
, or evenbloch!(h(; params...), ϕs)
. This is not implemented here yet, but could be used to even stop exportingbloch
andbloch!
. Even further,h(not_all_phis; params...)
could even replacewrap
, but that's another issue.