Move expect_and_grad (and expect) to dispatch mechanism.
Created by: PhilipVinc
It will now be possible to declare expecT_and_grad implementations for arbitrary operators by declaring, for exmaple
@nk.utils.dispatch.dispatch
def expect_and_grad(vstate: MCState, operator: MyOperatorT, covariance_formula: bool, mutable : Any):
....
covariance_formula
specifies whever the covariance formula, as described in #803 (closed), should be used.
By default this value is True/False depending on whever the operator is hermitian/nonhermitian.
It is possible to dispatch on True/False by using the types nk.utils.disaptch.TrueT
and nk.utils.dispatch.FalseT
.