Skip to content

Op

A local operator acting on several lattice sites.

Source op.hpp

Constructors

Op(type::String, coupling::String, sites::Vector{Int64})
Op(type::String, coupling::String, site::Int64)

Op(type::String, coupling::Float64, sites::Vector{Int64})
Op(type::String, coupling::Float64, site::Int64)

Op(type::String, coupling::ComplexF64, sites::Vector{Int64})
Op(type::String, coupling::ComplexF64, site::Int64)

Op(type::String, coupling::Matrix{Float64}, sites::Vector{Int64})
Op(type::String, coupling::Matrix{Float64}, site::Int64)

Op(type::String, coupling::Matrix{ComplexF64}, sites::Vector{Int64})
Op(type::String, coupling::Matrix{ComplexF64}, site::Int64)
Op(std::string type, std::string coupling, std::vector<int64_t> const &sites)
Op(std::string type, std::string coupling, int64_t site)

Op(std::string type, double coupling, std::vector<int64_t> const &sites)
Op(std::string type, double coupling, int64_t site)

Op(std::string type, complex coupling, std::vector<int64_t> const &sites)
Op(std::string type, complex coupling, int64_t site)

Op(std::string type, arma::mat const &coupling, std::vector<int64_t> const &sites)
Op(std::string type, arma::mat const &coupling, int64_t site)

Op(std::string type, arma::cx_mat const &coupling, std::vector<int64_t> const &sites)
Op(std::string type, arma::cx_mat const &coupling, int64_t site)
Parameter Description
type a string which denotes what kind of operator is represented
coupling sets the coefficients neded to specify the coupling. Further details below
sites defines on which site(s) of the lattice the operator acts on.

1-indexing in Julia / 0-indexing in C++

To enumerate the sites of an Op, we start counting at 1 in Julia and 0 in C++.

The coupling can take on several types and allow some flexibility in defining operators.

type Description
string the coupling is represented as a string, e.g. "\(t\)" or "\(J\)" in a \(t-J\) model
real/cplx number the actual numerical value of the coupling
real/cplx matrix more generic interactions can be specified as matrices

Methods

type

Returns the type of the operator

type(op::Op)
std::string type() const;

coupling

Returns the coupling of the operator

coupling(op::Op)
Coupling const &coupling() const;

This returns an object of type Coupling, which can then be converted to an appropriate type.

size

Returns how many sites the operator is defined on

size(op::Op)
int64_t size() const;

getindex / operator[]

Returns the site with the given index.

getindex(op::Op, idx::Int64)
int64_t operator[](int64_t idx) const;

sites

Returns all the sites the operator is defined on

sites(op::Op)
std::vector<int64_t> const &sites() 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(op::Op)
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(op::Op)
bool ismatrix() const;

isexplicit

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

isexplicit(op::Op)
bool isexplicit() const;

Usage Example

op = Op("HOP", "T", [1, 2])
@show op
@show type(op)
@show convert(String, coupling(op))
@show size(op), op[1], op[2]
@show sites(op) == [1, 2]
@show isexplicit(op)

op = Op("HOP", 1.23, [1, 2])
@show op
@show isreal(op)
@show ismatrix(op)
@show isexplicit(op)

op = Op("SY", [0 -im; im 0], 1)
@show op
@show isreal(op)
@show ismatrix(op)
@show isexplicit(op)
auto op = Op("HOP", "T", {0, 1});
XDIAG_SHOW(op);
XDIAG_SHOW(op.type());
XDIAG_SHOW(op.coupling().as<std::string>());
XDIAG_SHOW(op.size());
XDIAG_SHOW(op[0]);
XDIAG_SHOW(op[1]);
XDIAG_SHOW(op.isexplicit());

 op = Op("HOP", 1.23, {0, 1});
XDIAG_SHOW(op);
XDIAG_SHOW(op.isreal());
XDIAG_SHOW(op.ismatrix());
XDIAG_SHOW(op.isexplicit());

arma::cx_mat m(arma::mat("0 0; 0 0"), arma::mat("0 -1; 1 0"));
op = Op("SY", m, 0);
XDIAG_SHOW(op);
XDIAG_SHOW(op.isreal());
XDIAG_SHOW(op.ismatrix());
XDIAG_SHOW(op.isexplicit());