apply
Applies an operator to a state \(\vert w \rangle = O \vert v\rangle\) or block of states \(\left( \vert w_1 \rangle \dots \vert w_M \rangle \right) = O \left( \vert v_1 \rangle \dots \vert v_M \rangle \right)\).
Source apply.hpp
The resulting state is handed as the third argument and is overwritten upon exit.
Parameters
Name | Description | |
---|---|---|
ops / op | OpSum or Op defining the operator | |
v | input state $\vert v\rangle $ | |
w | output state \(\vert w \rangle = O \vert v\rangle\) | |
precision | precision with which checks for zero are performed (default \(10^{-12}\)) |
Usage Example
int N = 8;
auto block = Spinhalf(N, N / 2);
auto ops = OpSum();
for (int i=0; i<N; ++i){
ops += Op("HB", 1.0, {i, (i+1)%N});
}
auto [e0, psi] = eig0(ops, block);
auto blockp = Spinhalf(N, N / 2 + 1);
auto phi = zeros(blockp);
apply(Op("S+", 1.0, 2), psi, phi);
XDIAG_SHOW(inner(ops, psi));
XDIAG_SHOW(inner(ops, phi));