Skip to content

State

A generic state describing a quantum wave function

Source state.hpp

Constructors

State(block::Block; real::Bool = true, n_cols::Int64 = 1)
State(block::Block, vec::Vector{Float64})
State(block::Block, vec::Vector{ComplexF64})
State(block::Block, mat::Matrix{Float64})
State(block::Block, mat::Matrix{ComplexF64})
State(Block const &block, bool real = true, int64_t n_cols = 1);

template <typename block_t, typename coeff_t>
State(block_t const &block, arma::Col<coeff_t> const &vector);

template <typename block_t, typename coeff_t>
State(block_t const &block, arma::Mat<coeff_t> const &matrix);
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.

n_sites(state::State)
int64_t n_sites() const

isreal

Returns whether the state is real.

isreal(state::State)
int64_t isreal() const;

real

Returns whether the real part of the State.

real(state::State)
State real() const;

imag

Returns whether the imaginary part of the State.

imag(state::State)
State imag() const;

make_complex! / make_complex

Turns a real State into a complex State. Does nothing if the state is already complex

make_complex!(state::State)
void make_complex();

dim

Returns the dimension of the block the state is defined on.

dim(block::Spinhalf)
int64_t dim() const;

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.

size(block::Spinhalf)
int64_t size() const;

n_rows

Returns number of rows of the local storage. Same as "size"

n_rows(block::Spinhalf)
int64_t n_rows() const;

n_cols

Returns number of columns of the local storage.

n_cols(block::Spinhalf)
int64_t n_cols() const;

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".

col(state::State, n::Int64 = 1; copy::Bool = true)
State col(int64_t n, bool copy = true) const;

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.

vector(state::State; n::Int64 = 1)
# no vectorC method in julia
arma::vec vector(int64_t n = 0, bool copy = true) const;
arma::cx_vec vectorC(int64_t n = 0, bool copy = true) const;

matrix/matrixC

Returns matrix representing the storage. In C++ use "matrix"/"matrixC" to either get a real or complex matrix.

matrix(state::State)
# no matrixC method in julia
arma::vec matrix(bool copy = true) const;
arma::cx_vec matrixC(bool copy = true) const;

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());