State
A generic state describing a quantum wave function
Source state.hpp
Constructors
Parameter | Description | |
---|---|---|
block | The block of a Hilbertspace on which the state is defined | |
real | Flag whether or not the state has real coefficients | |
n_cols | Number of columns of the state (default 1) | |
vector | A vector containing the coefficients of the state. Must be same size as block. | |
matrix | A matrix containing the coefficients of the state. Number of rows must be same as block size . |
Methods
n_sites
Returns the number of sites of the block the state is defined on.
make_complex! / make_complex
Turns a real State into a complex State. Does nothing if the state is already complex
dim
Returns the dimension of the block the state is defined on.
size
Returns the size of the block the state is defined on. locally. Same as "dim" for non-distributed Blocks but different for distributed blocks.
n_rows
Returns number of rows of the local storage. Same as "size"
n_cols
Returns number of columns of the local storage.
col
Returns a state created from the n-th column of the storage. Whether or not the storage is copied can be specified by setting the flag "copy".
vector/vectorC
Returns a vector from the n-th column of the storage. In C++ use "vector"/"vectorC" to either get a real or complex vector.
matrix/matrixC
Returns matrix representing the storage. In C++ use "matrix"/"matrixC" to either get a real or complex matrix.
Usage Example
block = Spinhalf(2)
psi1 = State(block, [1.0, 2.0, 3.0, 4.0])
@show psi1
display(vector(psi1))
make_complex!(psi1)
display(vector(psi1))
psi2 = State(block, real=false, n_cols=3)
@show psi2
display(matrix(psi2))
psi3 = State(block, [1.0+4.0im, 2.0+3.0im, 3.0+2.0im, 4.0+1.0im])
display(vector(psi3))
display(vector(real(psi3)))
display(vector(imag(psi3)))
auto block = Spinhalf(2);
auto psi1 = State(block, arma::vec("1.0 2.0 3.0 4.0"));
XDIAG_SHOW(psi1);
XDIAG_SHOW(psi1.vector());
psi1.make_complex();
XDIAG_SHOW(psi1.vectorC());
auto psi2 = State(block, false, 3);
XDIAG_SHOW(psi2);
XDIAG_SHOW(psi2.matrixC());
auto psi3 = State(block, arma::cx_vec(arma::vec("1.0 2.0 3.0 4.0"),
arma::vec("4.0 3.0 2.0 1.0")));
XDIAG_SHOW(psi3.vectorC());
XDIAG_SHOW(psi3.real().vector());
XDIAG_SHOW(psi3.imag().vector());