eigenshuffle
Adapted from code by bmachiel, which in turn was based on matlab eigenshuffle.
Consistently sort eigenvalues and eigenvectors of a series of matrices based on initial ordering from low to high.
Includes eigenshuffle_eig and eigenshuffle_eigh for non-hermitian and hermitian matrices, respectively.
Installation
Install from pypi with:
pip install eigenshuffle
or clone repo and install with pip or directly install from GitHub with:
pip install git+https://github.com/ograsdijk/eigenshuffle
Example
import numpy as np
import numpy.typing as npt
import matplotlib.pyplot as plt
from eigenshuffle import eigenshuffle_eig
def eigenvalue_function(
t: float,
) -> npt.NDArray[np.floating]:
return np.array(
[
[1, 2 * t + 1, t**2, t**3],
[2 * t + 1, 2 - t, t**2, 1 - t**3],
[t**2, t**2, 3 - 2 * t, t**2],
[t**3, 1 - t**3, t**2, 4 - 3 * t],
]
)
tseq = np.arange(-1, 1.1, 0.1)
Aseq = np.array([eigenvalue_function(ti) for ti in tseq])
e, v = np.linalg.eig(Aseq)
es, vs = eigenshuffle_eig(Aseq)
# sorting original eig result from low to high
v[np.argsort(e)]
e = np.sort(e)
fig, ax = plt.subplots()
lines = ax.plot(tseq, e)
for i in range(es.shape[-1]):
ax.plot(tseq, es.real[:, i], "--", color=lines[i].get_color())
# for generating the legend
line1 = plt.Line2D([0, 1], [0, 1], linestyle="-", color="black")
line2 = plt.Line2D([0, 1], [0, 1], linestyle="--", color="black")
ax.set_xlabel("t")
ax.set_ylabel("eigenvalue")
ax.legend([line1, line2], ["sorted", "eigenshuffle"])
ax.grid()
Here the eigenvalues are consistently ordered, and are not switching positions after a level crossing (around t=0.3) when using eigenshuffle.
Metadata
Release files for eigenshuffle 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| eigenshuffle-0.1.3.tar.gz | 411.4 kB | Without provenance | Details for eigenshuffle-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| eigenshuffle-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for eigenshuffle-0.1.3-py3-none-any.whl |
Total release size: 417.1 kB
Release files / eigenshuffle-0.1.3.tar.gz
| Download URL | eigenshuffle-0.1.3.tar.gz |
|---|---|
| Size | 411.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e1265b44ca1cfd0d8018ca31cba4021503a65ea0834f11ec785016f472921349
|
|
BLAKE2b-256 checksum How to use checksums |
7071f27df9d959c43f9ad6c6f2d47517f662d84b58d9816a141e3096faf7b33b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.6
|
Release files / eigenshuffle-0.1.3-py3-none-any.whl
| Download URL | eigenshuffle-0.1.3-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
966e16c738816321f6ff795697a11bcd6a8d3fe1a10b96137de5da9ae6f125da
|
|
BLAKE2b-256 checksum How to use checksums |
c1a1fe9d10b04032a771d5b1ff2864ef7e7db805481424cc53ac76ad0f6025b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.6
|
Security for eigenshuffle 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.