Documentation: https://jordan-form.readthedocs.io
Source Code: https://github.com/34j/jordan-form
Compute jordan canonical (normal) form of (nonlinear / generalized) eigenvalue problem
Install this via pip (or your favourite package manager):
pip install jordan-form
Consider a function
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.]])])
> 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.]]
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
This package was created with Copier and the browniebroke/pypackage-template project template.