A wrapper for the MEPACK (Matrix Equation Package) library
Project description
python-mepack (pyMEPACK)
Version: 1.1.1
Copyright 2023-2024 by Martin Köhler, MPI-Magdeburg
Description
Python Interface for MEPACK
- a Fortran software library for the solution of dense Sylvester-like matrix equations.
The pyMEPACK interfaces routines solving the following equations:
- Standard Lyapunov equations (
gelyap
) $AX + XA^T = Y
$ - Standard Stein (Discrete-Time Lyapunov) equations (
gestein
)$AXA^T - X = Y
$ - Generalized Lyapunov equations (
gglyap
) $AXB^T + BXA^T = Y
$ - Generalized Stein (Discrete-Time Lyapunov) Equation (
ggstein
) $AXA^T - BXB^T = Y
$ - Standard Sylvester equations (
gesylv
) $AX + XB = Y
$ - Discrete-time Sylvester equations (
gesylv2
) $AXB + X = Y
$ - Generalized Sylvester equations (
ggsylv
) $AXB + CXD = Y
$ - Generalized coupled Sylvester equations (
ggcsylv
) $AR + LB = E, CR + LD = F
$ - Dual generalized coupled Sylvester equations (
ggcsylv_dual
) $AR + CL = E, RB + LD = F
$
The library includes single and double precision solvers with iterative refinement for the above equations.
Dependencies
To install and run pyMEPACK the following components are required:
- MEPACK Version 1.1.1
- a BLAS and LAPACK implementation
- Python 3.7.0 +
- Cython 0.29.28 +
- numpy 1.20.3 +
- scipy 1.5.4 +
- setuptools 59.0.0 +
- configparser 5.2.0 +
- parameterized 0.8.0 + (only for tests)
- h5py 3.6.0 + (only for benchmarks)
- slycot 0.4.0 (only for benchmarks)
- Sphinx 5.0.2 + (for documentation)
Installation
pyMEPACK requires MEPACK to be installed on your system. See MEPACK's installation guide for detail (https://gitlab.mpi-magdeburg.mpg.de/software/mepack-release/-/blob/master/doc/install.md?ref_type=heads).
If MEPACK is not installed in a default location or the BLAS and LAPACK library
are not named blas
and lapack
the pymepack.cfg
file can be used to setup
these differences. See pymepack.cfg-sample for details.
The installation of pyMEPACK is done by executing the following commands in the root directory of the project:
pip install .
or
pip install --user .
After a successful installation, pyMEPACK can be imported via import pymepack
.
Documentation
Documentation of the pyMEPACK functions is accessible in the form of __doc__ strings.
HTML Documentation can be build with Sphinx inside the docs
directory:
(cd ./docs && make html)
How to use pyMEPACK
The interface of pyMEPACK is very concise and easy to work with. The following code snippet solves a Lyapunov equation and computes the relative residual of the solution.
#!/usr/bin/env python3
import pymepack as pme
import numpy as np
import scipy as sp
n = 1000
# Prepare
A = np.triu(np.ones((n,n))) + np.diag(np.ones((n)))
X = np.ones((n,n))
Y = A @ X + X @ A.conj().T
# Solve
Xcomp, *_ = pme.gelyap(A, Y)
# Compute the residual
RelRes = pme.res_gelyap(A, Xcomp, Y)
print("Size = {:d} RelRes = {:e}".format(n, RelRes))
Testing
pyMEPACK contains a test suite. This is executed via
(cd /tmp && python3 -m unittest -v pymepack.tests)
The test suite cannot run from the root of source code after installation.
Test data
gelyap
, gglyap
, gestein
and ggstein
solvers, as well as their
respective versions with iterative refinement are tested on examples provided
in SLICOT benchmark collections, namely BB03AD
and BB04AD
[1,2].
All the Sylvester solvers are tested using randomization. We use numpy.random
module and supply the random generator with a seed to avoid build instability.
Last tested with numpy.version = 1.24.1. The non-symmetric stable matrices are
constructed as in the example 4.1 in [1].
Tuning and Benchmarks
See Benchmark and Tuning.
License
pyMEPACK, like MEPACK it self, is license under GPLv3.
Authors
- Martin Köhler, MPI Magdeburg
- Aleksey Maleyko, MPI Magdeburg
Citation
Martin Köhler. (2024). MEPACK: Matrix Equation PACKage (1.1.1). Zenodo. https://doi.org/10.5281/zenodo.10568848
References
[1] Benner, P., 2004. Factorized solution of Sylvester equations with applications in control. sign (H), 1, p.2.
[2] D. Kressner, V. Mehrmann, and T. Penzl. CTLEX - a Collection of Benchmark Examples for Continuous-Time Lyapunov Equations. SLICOT Working Note 1999-6, 1999.
[3] D. Kressner, V. Mehrmann, and T. Penzl. DTLEX - a Collection of Benchmark Examples for Discrete-Time Lyapunov Equations. SLICOT Working Note 1999-7, 1999.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for pymepack-1.1.1.post2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 597c94202f4d68951ec3c9087ba5f2e70e6b2086cd221376a206bbaf398ced43 |
|
MD5 | d1adfb785fb267dc568e6b537af5f852 |
|
BLAKE2b-256 | 22446818f16b280851635cafdba8e050c31209753a9d1ff299cfa70a3d4b1328 |
Hashes for pymepack-1.1.1.post2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e900101faea64e1ae662f57e058c5d4caec95cd5d9316e63daec2d3bcc7dd65d |
|
MD5 | 46adc0df1956adc9304a104401b762c3 |
|
BLAKE2b-256 | c64ee43a8abe244fb855b5ea6de8d61ca5547ab674050b4ff1a33e186a29640b |
Hashes for pymepack-1.1.1.post2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52b59da0c4995295473091b4b1255fc61567af3019015864f1a7b36e77ea1f0c |
|
MD5 | 38d6bed6593c9984f7d196090f4b2145 |
|
BLAKE2b-256 | bfcf524fd24327be0731edd41bbf5d5a7b17fef8661be72995e95e8a44aef42d |
Hashes for pymepack-1.1.1.post2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | add2a3ca9aead990b9fe54dc1b8fd517d2e9aa1889c879e9bdd9ed780c90e458 |
|
MD5 | 82e01dacef3728ad4283d1ad65d546da |
|
BLAKE2b-256 | 6307a613e78061d6354a5eb3b91f7fce83ede4ab70b570259551813f5a3621bb |
Hashes for pymepack-1.1.1.post2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6de3bc833ad98eb0f57527717866e82d822c94a5561593351ecd01e162a15609 |
|
MD5 | 531e4749fef949409b04ad89aaa25cd0 |
|
BLAKE2b-256 | f66182c77c157a9b37a8d2bf1d8074509fbbc4ae010bf3362eaf971a5198635e |
Hashes for pymepack-1.1.1.post2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98e78f9a8cc92f8399042309c6c22657909f3527c4f6611469fdf4be817884ab |
|
MD5 | a1fea19afb3e1f14b3782ac498a7cacf |
|
BLAKE2b-256 | 365e682b15000465514cd70f0f86ade1be8a03edcef6e13a9b25ea63ce42faf1 |