Skip to content

Compute jordan canonical (normal) form of (nonlinear / generalized) eigenvalue problem

License

Notifications You must be signed in to change notification settings

34j/jordan-form

Jordan Form

CI Status Documentation Status Test coverage percentage

uv Ruff pre-commit

PyPI Version Supported Python versions License


Documentation: https://jordan-form.readthedocs.io

Source Code: https://github.com/34j/jordan-form


Compute jordan canonical (normal) form of (nonlinear / generalized) eigenvalue problem

Installation

Install this via pip (or your favourite package manager):

pip install jordan-form

Usage

Consider a function

$$ T(\lambda) = \begin{pmatrix} \lambda^2 & -\lambda \\ 0 & \lambda^2 \end{pmatrix} $$

which eigenvalue is 0. (Example 1. from Nonlinear Eivenvalue Problems which is from Matrix Polynomials (Computer Science and Applied Mathematics). (1982). Academic Press.)

import numpy as np

from jordan_form import canonical_jordan_chains


def f(
    eigval: float, derv: int
) -> np.ndarray[tuple[int, int], np.dtype[np.number]] | None:
    if derv == 0:
        return np.array([[eigval**2, -eigval], [0, eigval**2]])
    elif derv == 1:
        return np.array([[2 * eigval, -1], [0, 2 * eigval]])
    elif derv == 2:
        return np.array([[2, 0], [0, 2]])
    else:
        return np.zeros((2, 2))


chains = canonical_jordan_chains(
    f, 0, atol_rank=1e-3, rtol_rank=1e-3, atol_norm=1e-3, rtol_norm=1e-3
)
print(chains)
CanonicalJordanChains(eigval=0, chains=[array([[1., 0.],
       [0., 1.],
       [0., 0.]]), array([[0., 1.]])])

CLI Usage

> jordan-form "{{x^2,-x},{0,x^2}}" 0
Algebraic multiplicity: 4
Geometric multiplicity: 2
Dimension of generalized eigenspace: [2 3 4]
Dimension of ith generalized eigenvectors: [2 1 1]
Chain lengths: [3 1]
Chain 0:
[[1. 0.]
 [0. 1.]
 [0. 0.]]
Chain 1:
[[0. 1.]]

References

Contributors ✨

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

Credits

Copier

This package was created with Copier and the browniebroke/pypackage-template project template.

About

Compute jordan canonical (normal) form of (nonlinear / generalized) eigenvalue problem

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Contributors 2

  •  
  •