Skip to main content

Bindings and Python interface for the MUMPS sparse solver

Project description

Python-MUMPS

Python bindings for the MUMPS: a parallel sparse direct solver.

Scope

This package targets MUMPS packaged by conda-forge using Cython bindings. It aims to provide a full wrapper of the MUMPS sequential API. Its primary target OS is Linux.

Next steps include:

  • Support for Windows and OSX
  • Support for distributed (MPI) MUMPS

Installation

python-mumps works with Python 3.10 and higher on Linux, Windows and Mac.

The recommended way to install python-mumps is using mamba/conda.

mamba install -c conda-forge python-mumps

python-mumps can also be installed from PyPI, however this is a more involved procedure that requires separately installing the MUMPS library and a C compiler.

Usage example

The following example shows how Python-MUMPS can be used to implement sparse diagonalization with Scipy.

import scipy.sparse.linalg as sla
from scipy.sparse import identity
import mumps


def sparse_diag(matrix, k, sigma, **kwargs):
    """Call sla.eigsh with mumps support.

    See scipy.sparse.linalg.eigsh for documentation.
    """
    class LuInv(sla.LinearOperator):
        def __init__(self, A):
            inst = mumps.Context()
            inst.analyze(A, ordering='pord')
            inst.factor(A)
            self.solve = inst.solve
            sla.LinearOperator.__init__(self, A.dtype, A.shape)

        def _matvec(self, x):
            return self.solve(x.astype(self.dtype))

    opinv = LuInv(matrix - sigma * identity(matrix.shape[0]))
    return sla.eigsh(matrix, k, sigma=sigma, OPinv=opinv, **kwargs)

Development

Pixi

python-mumps recommends pixi.

After installing pixi, use

pixi run test -v  # (Pytest arguments go after test)

This will also install the necessary dependencies.

pre-commit

python-mumps uses pre-commit to enforce code style. After installing it, run

pre-commit install

or if you want to use pre-commit provided by pixi, run

pixi run pre-commit install

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_mumps-0.0.3.tar.gz (47.6 kB view details)

Uploaded Source

File details

Details for the file python_mumps-0.0.3.tar.gz.

File metadata

  • Download URL: python_mumps-0.0.3.tar.gz
  • Upload date:
  • Size: 47.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for python_mumps-0.0.3.tar.gz
Algorithm Hash digest
SHA256 bb10a6bb3fd1522ed5771b832f99ed0c590b2524d5ae672cbb1b7348634be550
MD5 6658f841a3ea21236d5743f5d948c6a7
BLAKE2b-256 4afa3e6bbb37d03fdff6b105c8f9b9f1051c5305a0c86dda85f23b2a02b95c35

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page