symop.ccr.algebra.density.inner

Hilbert–Schmidt inner product for symbolic density polynomials.

A density polynomial is represented as a finite sum of rank-1 outer products

\[A \sim \sum_i c_i \, |L_i\rangle \langle R_i|,\]

with complex coefficients c_i and normally-ordered monomials L_i, R_i. This module evaluates the symbolic Hilbert–Schmidt inner product

\[\langle A, B \rangle = \mathrm{Tr}(A^\dagger B),\]

without constructing any explicit matrix representations.

Functions

density_inner(a, b)

Compute the Hilbert--Schmidt inner product between two density polynomials.

density_inner(a: tuple[DensityTerm, ...], b: tuple[DensityTerm, ...]) complex

Compute the Hilbert–Schmidt inner product between two density polynomials.

This function evaluates the symbolic Hilbert–Schmidt inner product

\[\langle A, B \rangle = \mathrm{Tr}(A^\dagger B)\]

by expanding density terms of both operands. Each density term is of the form

\[t_i = c_i \, |L_i\rangle \langle R_i|,\]

where \(c_i\) is a complex coefficient. The total inner product is

\[\langle A, B \rangle = \sum_{i \in A} \sum_{j \in B} c_i^* c_j \, \langle L_i | L_j \rangle \, \langle R_j | R_i \rangle.\]

The bra–ket overlaps are evaluated symbolically using overlap_right_left().

Parameters:
  • a (tuple[DensityTerm, ...]) – Left operand (bra side) of the inner product, corresponding to \(A^\dagger\).

  • b (tuple[DensityTerm, ...]) – Right operand (ket side) of the inner product, corresponding to \(B\).

Returns:

The Hilbert–Schmidt inner product \(\mathrm{Tr}(A^\dagger B)\).

Return type:

complex

Notes

  • The coefficients of the left operand a are conjugated to form \(A^\dagger\).

  • Overlaps between left and right monomials are computed symbolically via commutation rules, without explicit matrix representations.

  • This inner product is Hermitian: \(\langle A, B \rangle = \langle B, A \rangle^*\).