cppqed-multidiagonal 0.4.0
Multidiagonal sparse operator algebra for C++QED
Loading...
Searching...
No Matches
quantumoperator Namespace Reference

Comprises modules representing operators of special structure (multidiagonal, sparse) over Hilbert spaces of arbitrary arity. More...

Namespaces

namespace  multidiagonal
 

Classes

struct  MultiDiagonal
 A sparse matrix storing an arbitrary set of diagonals, closed under composition, direct product, and Hermitian conjugation. More...
 

Functions

template<size_t RANK>
MultiDiagonal< RANK > operator| (const MultiDiagonal< RANK > &a, const MultiDiagonal< RANK > &b)
 Composition (matrix product) of two MultiDiagonal operators of arbitrary rank: \((A|B)_{rc} = \sum_m A_{rm} B_{mc}\).
 

Detailed Description

Comprises modules representing operators of special structure (multidiagonal, sparse) over Hilbert spaces of arbitrary arity.

Function Documentation

◆ operator|()

template<size_t RANK>
MultiDiagonal< RANK > quantumoperator::operator| ( const MultiDiagonal< RANK > &  a,
const MultiDiagonal< RANK > &  b 
)

Composition (matrix product) of two MultiDiagonal operators of arbitrary rank: \((A|B)_{rc} = \sum_m A_{rm} B_{mc}\).

For each pair of diagonals — \(A\) at signed offsets \(p\), \(B\) at \(q\) (per axis, dimension \(D\)) — the contribution lands on the result diagonal at

\[ s = p + q \qquad\text{(the quanta moved add up).} \]

With the storage convention \(d[k]=M_{k+o^-,k+o^+}\), entry \(k\) of the result receives

\[ r[k] \mathrel{+}= d_A[k+i_A]\, d_B[k+i_B], \qquad i_A = s^--p^-, \quad i_B = s^-+p-q^-, \]

valid on the window

\[ k \in \bigl[\, \max(0,-i_A,-i_B),\ \min(D-|s|,\,D-|p|-i_A,\,D-|q|-i_B) \,\bigr). \]

Entries of the result diagonal outside the window are structural zeros, stored explicitly so that the invariant \(\text{extent}+|s|=D\) holds. Pairs with \(|s_i|\ge D_i\) or an empty window on any axis are structurally zero and skipped. **Contributions from different \((p,q)\) pairs to the same \(s\) accumulate** — this is essential for correctness, not an optimization (e.g. \(\sigma_x|\sigma_x\) assembles its main diagonal from two complementary pairs).

Complexity: \(O(d_A\, d_B)\) diagonal pairs, each linear in the window volume.

Note
operator* has higher precedence than operator| in C++; use parentheses in mixed expressions.