change_of_basis
¶
Change of basis that Hermitizes a quadratic shadow Hamiltonian.
Somma et al. (arXiv:2407.21775, Sec. 2) write H = (1/2) Y^T Γ Y for
operators with [Y_j, Y_k] = i Ω_jk. In that basis the shadow matrix is
i Ω Γ, which is not Hermitian in general. A factor Γ = B B† with
A = B† produces H_S = i B† Ω B, which is Hermitian when Ω is real
and skew-symmetric. Canonical oscillator quadratures are the default Ω.
ChangeOfBasis
dataclass
¶
Factors and shadow matrices for a quadratic change of basis.
Attributes:
-
A(NDArray[complexfloating]) –Change-of-basis matrix
A = B†. New operators areO = A Y. -
B(NDArray[complexfloating]) –Factor with
Γ = B B†. -
H_S(NDArray[complexfloating]) –Shadow matrix
i B† Ω Bin the new basis. -
quadrature_H_S(NDArray[complexfloating]) –Shadow matrix
i Ω Γbefore the change of basis. -
omega(NDArray[floating]) –Commutator matrix used, with
[Y_j, Y_k] = i Ω_jk.
Source code in shadowsim/shadow/change_of_basis.py
change_of_basis
¶
change_of_basis(
gamma: ArrayLike, omega: ArrayLike | None = None
) -> ChangeOfBasis
Return a change of basis that Hermitizes a quadratic shadow matrix.
gamma is the real symmetric positive-semidefinite matrix Γ in
H = (1/2) Y^T Γ Y. omega is the real skew-symmetric commutator
matrix in [Y_j, Y_k] = i Ω_jk. When omega is omitted it is the
canonical quadrature matrix for n oscillators,
Ω = [[0, -I], [I, 0]],
and Γ must have even shape (2n, 2n). The factor B comes from
the symmetric eigendecomposition, so a singular Γ is allowed.
Parameters:
-
gamma(ArrayLike) –Real symmetric positive-semidefinite matrix
Γ. -
omega(ArrayLike | None, default:None) –Real skew-symmetric commutator matrix. Defaults to the canonical quadrature matrix of matching even dimension.
Returns:
-
ChangeOfBasis–Factors
A = B†andB, the Hermitian shadow matrix -
ChangeOfBasis–H_S = i B† Ω B, the quadrature shadow matrixi Ω Γ, and the -
ChangeOfBasis–Ωthat was used.
Raises:
-
ValueError–If
gammais not real symmetric or not positive semidefinite, ifomegais omitted andgammahas odd dimension, or ifomegais not real, skew-symmetric, and the same shape asgamma.
Examples:
One oscillator with mass m = 1 and spring κ = 2 has
Γ = diag(1, 2). The quadrature shadow matrix is not Hermitian;
the returned H_S is:
import numpy as np
from shadowsim.shadow import change_of_basis
from shadowsim.utils.hermitian import hermitian
basis = change_of_basis(np.diag([1.0, 2.0]))
print(hermitian(basis.quadrature_H_S), hermitian(basis.H_S))