Skip to content

[General]: Use np.linalg.eigh instead of np.linalg.eig for symmetric matrices #439

Closed

Description

@harryswift01

Feedback or Inquiry

CodeEntropy uses np.linalg.eig on matrices that are always symmetric: the moment of inertia tensors used for principal axes, and the force/torque covariance matrices. eig is the general-purpose solver, and for symmetric input it is the wrong tool. In particular, for (near-)degenerate eigenvalues it does not guarantee orthogonal eigenvectors, so the "principal axes" can be skewed, and the result can differ between machines and LAPACK builds.

Proposal: use np.linalg.eigh wherever the input is symmetric, including in place of MDAnalysis's principal_axes() (which also uses eig in 2.10) until we depend on a version that uses eigh.

Activity

  1. added this to the 2.5.0 milestone on Oct 7, 2026
  2. self-assigned this
    on Oct 7, 2026
  3. added theissue type on Oct 7, 2026
  4. changed the title [-][General]: Use np.linalg.eigh instead of np.linalg.eig for symmetric matrices[/-] [+][General]: Use `np.linalg.eigh` instead of `np.linalg.eig` for symmetric matrices[/+] on Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions