Skip to content

Coupling

Describes the coupling of a local operator. A coupling can either be a string, a real/complex number or even a real/complex matrix. It allows for converting to real/complex numbers or matrices as well as strings, whenever this conversion is sensible.

Source coupling.hpp

Constructors

Coupling(name::String)
Coupling(val::Float64)
Coupling(val::ComplexF64)
Coupling(mat::Matrix{Float64})
Coupling(mat::Matrix{ComplexF64})
Coupling(std::string value);
Coupling(double value);
Coupling(complex value);
Coupling(arma::mat const &value);
Coupling(arma::cx_mat const &value);

Methods

type

Returns the type of the Coupling, i.e. a string which either reads "string", "double", "complex", "mat", or "cx_mat"

type(cpl::Coupling)
std::string type() const;

isreal

Returns whether or not the coupling is real. Throws an error if the coupling is given as a string, since then it cannot be determined whether the operator is real.

isreal(cpl::Coupling)
bool isreal() const;

ismatrix

Returns whether or not the coupling is defined as a matrix. Throws an error if the coupling is given as a string, since then it cannot be determined whether the operator is real.

ismatrix(cpl::Coupling)
bool ismatrix() const;

isexplicit

Returns false if the coupling is defined as a string, otherwise true

isexplicit(cpl::Coupling)
bool isexplicit() const;

Conversions

A Coupling can be converted to the values it represents, so a string, real/complex number or a real/complex matrix. Initially real values can be cast to complex.

convert(::Type{String}, cpl::Coupling)
convert(::Type{Float64}, cpl::Coupling)
convert(::Type{ComplexF64}, cpl::Coupling)
convert(::Type{Matrix{Float64}}, cpl::Coupling)
convert(::Type{Matrix{ComplexF64}}, cpl::Coupling)
template <typename coeff_t> coeff_t as() const;

Usage Example

cpl = Coupling("J")
@show type(cpl)
@show isexplicit(cpl)

cpl = Coupling(1.23)
@show ismatrix(cpl)
@show convert(Float64, cpl)
@show convert(ComplexF64, cpl)

cpl = Coupling([1 2; -2 1])
@show ismatrix(cpl)
@show isreal(cpl)
@show convert(Matrix{Float64}, cpl)
@show convert(Matrix{ComplexF64}, cpl)
auto cpl = Coupling("J");
XDIAG_SHOW(cpl.type());
XDIAG_SHOW(cpl.isexplicit());

cpl = Coupling(1.23);
XDIAG_SHOW(cpl.ismatrix());
XDIAG_SHOW(cpl.as<double>());
XDIAG_SHOW(cpl.as<complex>());

cpl = Coupling(arma::mat("1 2; -2 1"));
XDIAG_SHOW(cpl.ismatrix());
XDIAG_SHOW(cpl.isreal());
XDIAG_SHOW(cpl.as<arma::mat>());
XDIAG_SHOW(cpl.as<arma::cx_mat>());