Skip to content

[feat] Adding support for complex correlation matrices to GEVP routines - #302

Open
s-kuberski wants to merge 2 commits into
fjosw:developfrom
s-kuberski:feat/complex-hermitian-gevp
Open

s-kuberski wants to merge 2 commits into
fjosw:developfrom
s-kuberski:feat/complex-hermitian-gevp

Conversation

@s-kuberski

Copy link
Copy Markdown
Collaborator

This extends the existing GEVP functionality to complex Hermitian correlation matrices. With vector_obs=True one can also propagates the uncertainties of eigenvectors.

For $A=C(t)$ and $B=C(t_0)$, we solve

$$ Av_n=\lambda_n Bv_n,\qquad v_m^\dagger Bv_n=\delta_{mn}, $$

with positive-definite $B$. Error propagation uses the derivatives

$$ \begin{aligned} d\lambda_n &= v_n^\dagger(dA-\lambda_n dB)v_n,\\ dv_n &= \sum_{m\ne n}v_m \frac{v_m^\dagger(dA-\lambda_n dB)v_n}{\lambda_n-\lambda_m} -\frac12v_n(v_n^\dagger dBv_n). \end{aligned} $$

The crucial piece for the error propagation of the eigenvectors is the choice of the phase convention is $\mathrm{Im}(v_n^\dagger B,dv_n)=0$.

These derivatives are passed to derived_observable as a real-coordinate Jacobian, including uncertainties in both matrices and their correlations. Working directly with the complex eigensystem avoids the doubled eigenvalues of the real block representation discussed in #255. Genuine degeneracies still prevent the determination of the derivatives of the eigenvectors.

The existing real-matrix GEVP options are supported for complex input. Complex vector uncertainties use the derivatives above rather than differentiating the Cholesky decomposition. Projections use $v_l^\dagger C v_r$ (before we did not have to worry about the exact definition).

The many tests include matrices with prescribed eigenvalues and eigenvectors, checking their values, errors and correlations.

For now, this draft is intended for testing on the matrices motivating #255.

@s-kuberski
s-kuberski requested a balanced review from Copilot November 10, 2026 10:45
@s-kuberski
s-kuberski requested a review from fjosw as a code owner November 10, 2026 10:45
@s-kuberski s-kuberski added the enhancement New feature or request label Nov 10, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The real and imaginary component checks mishandle fixed complex entries in matrices containing CObs, leaving imaginary values unchanged in corr.real and returning zeros in corr.imag.

1 open issue
What changed in this PR

Extends the existing generalized eigenvalue routines to complex Hermitian correlation matrices, including optional propagation of eigenvector uncertainties.

Changes:

  • Adds complex eigensystem derivatives with a defined local phase convention.
  • Updates projections, pruning, and matrix helpers for complex input, and clarifies solver-failure handling.
  • Adds tests for covariance propagation, normalization, sorting, and prescribed eigensystems.
File Description
tests/​linalg_test.py Tests complex eigenvector values and propagated covariance.
tests/​correlators_test.py Tests complex GEVP modes, projections, uncertainties, and failures.
pyerrors/​linalg.py Implements complex Hermitian eigensystem error propagation.
pyerrors/​correlators.py Integrates complex GEVP support and conjugated projections.

Review effort: Balanced

Comment thread pyerrors/correlators.py Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Active issues can discard complex eigenvector components during sorting and raise AttributeError for mixed Obs/complex64 matrices, breaking supported GEVP and eigensolver inputs.

No open issues 🎉

2 previously missed issues

In code that hasn't changed since last review

Medium severity Promote eigenvector sorting reference to complex

pyerrors/​correlators.py:1503

When C(t0) and C(ts) are real but another timeslice is complex, the sorting reference has a float dtype, so replacing its rows with complex vectors discards their imaginary components. This corrupts the determinant scores and can leave best_perm unassigned, causing GEVP(sort='Eigenvector') to fail. Promote the sorting reference to complex before replacing its rows.

Medium severity Convert complex64 coordinates before derived-observable processing

pyerrors/​linalg.py:418

A Hermitian object matrix mixing Obs entries with np.complex64 constants leaves np.float32 real and imaginary coordinates here. derived_observable only wraps Python int/float constants before accessing .cov_names, so eigh, eigv, and complex GEVPs with vector_obs=True raise AttributeError for this input. Preserve Obs components and convert the remaining coordinates to Python floats.

1 resolved since last review

Review effort: Balanced

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants