pypardiso-mopt


Namepypardiso-mopt JSON
Version 0.1.0 PyPI version JSON
download
home_pageNone
SummaryPython interface to the Intel MKL Pardiso library to solve large sparse linear systems of equations
upload_time2024-11-04 19:27:35
maintainerNone
docs_urlNone
authorAdrian Haas
requires_python>=3.8
licenseLICENSE.txt
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![pypardiso-tests](https://github.com/haasad/PyPardisoProject/actions/workflows/tests.yaml/badge.svg?branch=master)](https://github.com/haasad/PyPardisoProject/actions/workflows/tests.yaml)
# PyPardiso

PyPardiso is a python package to solve large sparse linear systems of equations with the [Intel oneAPI Math Kernel Library PARDISO solver](https://www.intel.com/content/www/us/en/develop/documentation/onemkl-developer-reference-fortran/top/sparse-solver-routines/onemkl-pardiso-parallel-direct-sparse-solver-iface.html), a shared-memory multiprocessing parallel direct sparse solver.

PyPardiso provides the same functionality as SciPy's [scipy.sparse.linalg.spsolve](https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.linalg.spsolve.html#scipy.sparse.linalg.spsolve) for solving the sparse linear system `Ax=b`. However in many cases it is significantly faster than SciPy's built-in single-threaded SuperLU solver.

PyPardiso is not a python interface to the PARDISO Solver from the [PARDISO 7.2 Solver Project](https://www.pardiso-project.org/) and it also doesn't currently support complex numbers. Check out [JuliaSparse/Pardiso.jl](https://github.com/JuliaSparse/Pardiso.jl/) for these more advanced use cases.

## Installation

PyPardiso runs on Linux, Windows and MacOS. It can be installed with __conda__ or __pip__. It is recommended to install PyPardiso using a virtual environment.

conda-forge | PyPI
:---:|:---:
[![conda-forge version](https://anaconda.org/conda-forge/pypardiso/badges/version.svg)](https://anaconda.org/conda-forge/pypardiso) | [![PyPI version](https://badge.fury.io/py/pypardiso.svg)](https://pypi.org/project/pypardiso/)
`conda install -c conda-forge pypardiso` | `pip install pypardiso`

## Test complex numbers
```python
import pypardiso
import numpy as np
import scipy.sparse as sp
from scipy.sparse.linalg import spsolve

A = sp.rand(10, 10, density=0.5, format='csr')
b = np.random.rand(10)
#x = pypardiso.spsolve(A, b)
x = pypardiso.spsolve(A, b, solver=pypardiso.PyPardisoSolver(mtype=pypardiso.Matrix_type.RNS))
print(x)
A = A.astype(np.cdouble)
b=b.astype(np.cdouble)
x = pypardiso.spsolve(A, b, solver=pypardiso.PyPardisoSolver(mtype=pypardiso.Matrix_type.CNS))
print(x)


A = sp.rand(10, 10, density=0.5, format='csr',dtype=np.cdouble)
x = pypardiso.spsolve(A, b, solver=pypardiso.PyPardisoSolver(mtype=pypardiso.Matrix_type.CNS))
print(x)

x1 = spsolve(A, b)
print(x1)

print(np.max(np.abs(x-x1)))
```

## Basic usage

How to solve the sparse linear system `Ax=b` for `x`, where `A` is a square, sparse matrix in CSR (or CSC) format and `b` is a vector (or matrix):
```python
In [1]: import pypardiso

In [2]: import numpy as np

In [3]: import scipy.sparse as sp

In [4]: A = sp.rand(10, 10, density=0.5, format='csr')

In [5]: A
Out[5]:
<10x10 sparse matrix of type '<class 'numpy.float64'>'
	with 50 stored elements in Compressed Sparse Row format>

In [6]: b = np.random.rand(10)

In [7]: x = pypardiso.spsolve(A, b)

In [8]: x
Out[8]:
array([ 0.02918389,  0.59629935,  0.33407289, -0.48788966,  3.44508841,
        0.52565687, -0.48420646,  0.22136413, -0.95464127,  0.58297397])
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pypardiso-mopt",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Adrian Haas",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/b5/3e/a6884c3ca7980aae6d8ca24e52d0431d7ffdb115bf5cfda7f3aaaefbfe88/pypardiso_mopt-0.1.0.tar.gz",
    "platform": null,
    "description": "[![pypardiso-tests](https://github.com/haasad/PyPardisoProject/actions/workflows/tests.yaml/badge.svg?branch=master)](https://github.com/haasad/PyPardisoProject/actions/workflows/tests.yaml)\n# PyPardiso\n\nPyPardiso is a python package to solve large sparse linear systems of equations with the [Intel oneAPI Math Kernel Library PARDISO solver](https://www.intel.com/content/www/us/en/develop/documentation/onemkl-developer-reference-fortran/top/sparse-solver-routines/onemkl-pardiso-parallel-direct-sparse-solver-iface.html), a shared-memory multiprocessing parallel direct sparse solver.\n\nPyPardiso provides the same functionality as SciPy's [scipy.sparse.linalg.spsolve](https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.linalg.spsolve.html#scipy.sparse.linalg.spsolve) for solving the sparse linear system `Ax=b`. However in many cases it is significantly faster than SciPy's built-in single-threaded SuperLU solver.\n\nPyPardiso is not a python interface to the PARDISO Solver from the [PARDISO 7.2 Solver Project](https://www.pardiso-project.org/) and it also doesn't currently support complex numbers. Check out [JuliaSparse/Pardiso.jl](https://github.com/JuliaSparse/Pardiso.jl/) for these more advanced use cases.\n\n## Installation\n\nPyPardiso runs on Linux, Windows and MacOS. It can be installed with __conda__ or __pip__. It is recommended to install PyPardiso using a virtual environment.\n\nconda-forge | PyPI\n:---:|:---:\n[![conda-forge version](https://anaconda.org/conda-forge/pypardiso/badges/version.svg)](https://anaconda.org/conda-forge/pypardiso) | [![PyPI version](https://badge.fury.io/py/pypardiso.svg)](https://pypi.org/project/pypardiso/)\n`conda install -c conda-forge pypardiso` | `pip install pypardiso`\n\n## Test complex numbers\n```python\nimport pypardiso\nimport numpy as np\nimport scipy.sparse as sp\nfrom scipy.sparse.linalg import spsolve\n\nA = sp.rand(10, 10, density=0.5, format='csr')\nb = np.random.rand(10)\n#x = pypardiso.spsolve(A, b)\nx = pypardiso.spsolve(A, b, solver=pypardiso.PyPardisoSolver(mtype=pypardiso.Matrix_type.RNS))\nprint(x)\nA = A.astype(np.cdouble)\nb=b.astype(np.cdouble)\nx = pypardiso.spsolve(A, b, solver=pypardiso.PyPardisoSolver(mtype=pypardiso.Matrix_type.CNS))\nprint(x)\n\n\nA = sp.rand(10, 10, density=0.5, format='csr',dtype=np.cdouble)\nx = pypardiso.spsolve(A, b, solver=pypardiso.PyPardisoSolver(mtype=pypardiso.Matrix_type.CNS))\nprint(x)\n\nx1 = spsolve(A, b)\nprint(x1)\n\nprint(np.max(np.abs(x-x1)))\n```\n\n## Basic usage\n\nHow to solve the sparse linear system `Ax=b` for `x`, where `A` is a square, sparse matrix in CSR (or CSC) format and `b` is a vector (or matrix):\n```python\nIn [1]: import pypardiso\n\nIn [2]: import numpy as np\n\nIn [3]: import scipy.sparse as sp\n\nIn [4]: A = sp.rand(10, 10, density=0.5, format='csr')\n\nIn [5]: A\nOut[5]:\n<10x10 sparse matrix of type '<class 'numpy.float64'>'\n\twith 50 stored elements in Compressed Sparse Row format>\n\nIn [6]: b = np.random.rand(10)\n\nIn [7]: x = pypardiso.spsolve(A, b)\n\nIn [8]: x\nOut[8]:\narray([ 0.02918389,  0.59629935,  0.33407289, -0.48788966,  3.44508841,\n        0.52565687, -0.48420646,  0.22136413, -0.95464127,  0.58297397])\n```\n",
    "bugtrack_url": null,
    "license": "LICENSE.txt",
    "summary": "Python interface to the Intel MKL Pardiso library to solve large sparse linear systems of equations",
    "version": "0.1.0",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "39371586e380e93eeb7949e1b8b66e95e21b79d0fd365261e4347690fa41b12d",
                "md5": "454739593ce39c61ef88ef1591296d97",
                "sha256": "daf61d8402268e06924b409285ee00bda5510b8c9c826f856bfd26c46a64b667"
            },
            "downloads": -1,
            "filename": "pypardiso_mopt-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "454739593ce39c61ef88ef1591296d97",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 10078,
            "upload_time": "2024-11-04T19:27:33",
            "upload_time_iso_8601": "2024-11-04T19:27:33.979168Z",
            "url": "https://files.pythonhosted.org/packages/39/37/1586e380e93eeb7949e1b8b66e95e21b79d0fd365261e4347690fa41b12d/pypardiso_mopt-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b53ea6884c3ca7980aae6d8ca24e52d0431d7ffdb115bf5cfda7f3aaaefbfe88",
                "md5": "eb86184a52fad5b0036fd27f270a698c",
                "sha256": "d21dcaedcfa46454664053043d89867df270139255bb63741749ccc55f067074"
            },
            "downloads": -1,
            "filename": "pypardiso_mopt-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "eb86184a52fad5b0036fd27f270a698c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 8912,
            "upload_time": "2024-11-04T19:27:35",
            "upload_time_iso_8601": "2024-11-04T19:27:35.515257Z",
            "url": "https://files.pythonhosted.org/packages/b5/3e/a6884c3ca7980aae6d8ca24e52d0431d7ffdb115bf5cfda7f3aaaefbfe88/pypardiso_mopt-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-04 19:27:35",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "pypardiso-mopt"
}
        
Elapsed time: 0.32955s