matrix
Creates a numerical matrix with real (matrix
) or complex (matrixC
) coefficients given an Op or OpSum on a certain block.
Sources
matrix.hpp
matrix.cpp
matrix.jl
Definition
A matrix can be created in two ways:
-
Only the input block on which the operator is defined is given. The output block is calculated and eventually created automatically.
-
The output block is also handed as an argument. The compatibility of quantum numbers is checked. This way the output block is not created automatically and, thus, can be used to save computation time if the output block appears repeatedly in the computation.
arma::mat matrix(Op const &op, Block const &block_in, Block const &block_out); arma::mat matrix(OpSum const &ops, Block const &block_in, Block const &block_out); arma::cx_mat matrixC(Op const &op, Block const &block_in, Block const &block_out); arma::cx_mat matrixC(OpSum const &ops, Block const &block_in, Block const &block_out);
Comment: In Julia, depending on whether a real/complex matrix is generated also a real/complex matrix is returned. The C++ version has to return a fixed type. If a real matrix is desired, use the function matrix
. If a complex matrix is desired, use the function matrixC
.
Parameters
Name | Description |
---|---|
ops | OpSum or Op defining the operator |
block / block_in | input block on which the operator is defined |
block_out | output block the operator maps the input block to |
Usage Example
// Creates matrix H_{k=2} in Eq (18.23) of https://link.springer.com/content/pdf/10.1007/978-3-540-74686-7_18.pdf
int N = 4;
int nup = 3;
int ndn = 2;
// Define a Hubbard chain model
auto ops = OpSum();
for (int i=0; i< N; ++i){
ops += "T" * Op("Hop", {i, (i+1) % N});
}
ops+= "U" * Op("HubbardU");
ops["T"] = 1.0;
ops["U"] = 5.0;
// Create the a permutation group
auto p1 = Permutation({0, 1, 2, 3});
auto p2 = Permutation({1, 2, 3, 0});
auto p3 = Permutation({2, 3, 0, 1});
auto p4 = Permutation({3, 0, 1, 2});
auto group = PermutationGroup({p1, p2, p3, p4});
auto irrep = Representation(group, arma::vec{1.0, -1.0, 1.0, -1.0});
auto block = Electron(N, nup, ndn, irrep);
auto H = matrix(ops, block);
H.print();
let
# Creates matrix H_{k=2} in Eq (18.23) of https://link.springer.com/content/pdf/10.1007/978-3-540-74686-7_18.pdf
N = 4
nup = 3
ndn = 2
# Define a Hubbard chain model
ops = OpSum()
for i in 1:N
ops += "T" * Op("Hop", [i, mod1(i+1, N)])
end
ops += "U" * Op("HubbardU")
ops["T"] = 1.0;
ops["U"] = 5.0;
# Create the a permutation group
p = Permutation([2, 3, 4, 1])
group = PermutationGroup([p^0, p^1, p^2, p^3])
irrep = Representation(group, [1.0, -1.0, 1.0, -1.0])
block = Electron(N, nup, ndn, irrep)
H = matrix(ops, block)
display(H)
end