Skip to content

matrix

matrix(ops, block; force_complex=false)
matrixC(ops, block)  # c++ only

Creates the full matrix representation of a given OpSum on a block.

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.

Source matrix.hpp

Parameters

Name Description
ops OpSum defining the operator
block block on which the operator is defined
force_complex flag to determine if returned matrix is forced to be complex (Julia only)

Returns

Type Description
matrix matrix representation of opsum on block

Definition

matrix(ops::Opsum, block::Block; force_complex::Bool=false)
template <typename block_t>
arma::mat matrix(OpSum const &ops, block_t const &block);

template <typename block_t>
arma::cx_mat matrixC(OpSum const &ops, block_t const &block);

Usage Example

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 += Op("HOP", "T", [i, mod1(i+1, N)])
    end
    ops["T"] = 1.0;
    ops["U"] = 5.0;

    # Create the a permutation group
    p1 = Permutation([1, 2, 3, 4])
    p2 = Permutation([2, 3, 4, 1])
    p3 = Permutation([3, 4, 1, 2])
    p4 = Permutation([4, 1, 2, 3])
    group = PermutationGroup([p1, p2, p3, p4])
    irrep = Representation([1, -1, 1, -1])
    block = Electron(N, nup, ndn, group, irrep)

    H = matrix(ops, block)
    display(H)
end
// 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 += Op("HOP", "T", {i, (i+1) % N});
}
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({1, -1, 1, -1});
auto block = Electron(N, nup, ndn, group, irrep);

auto H = matrix(ops, block);
H.print();