Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/refraction-ray/numkl
A thin cython/python wrapper on some routines from Intel MKL
https://github.com/refraction-ray/numkl
cython-wrapper lapack mkl numpy
Last synced: 29 days ago
JSON representation
A thin cython/python wrapper on some routines from Intel MKL
- Host: GitHub
- URL: https://github.com/refraction-ray/numkl
- Owner: refraction-ray
- License: mit
- Created: 2019-07-20T15:23:18.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-06-21T22:21:42.000Z (over 2 years ago)
- Last Synced: 2024-10-11T16:36:38.712Z (about 1 month ago)
- Topics: cython-wrapper, lapack, mkl, numpy
- Language: Python
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# NUMKL
[![version](https://img.shields.io/pypi/v/numkl.svg)](https://pypi.org/project/numkl/)
[![conda](https://anaconda.org/refraction-ray/numkl/badges/version.svg)](https://anaconda.org/refraction-ray/numkl)This package works as the python wrapper to directly call some MKL routines while keep the same interface with numpy.
## Install
Use `pip install numkl`
Or `conda install -c refraction-ray numkl`
You should make sure Intel MKL library and Intel compilers are installed and configured for relevant enviroment variables. Especially, environment variable `MKLROOT` is necessary for pip installation. And proper `LD_LIBRARY_PATH` is necessary in runtime.
Currently, you also need cython preinstalled in your python enviroment for pip installation.
Note this package is in its very early age, no guarantee on successful installation and usage. And this package only supports linux.
## Example
```python
from numkl import eig # must import numkl before numpy!!
import numpy as np
a = np.array([[0.,1.0],[1.0,0.]])
e,v = eig.eighx(a)
```The only thing requiring special attention is that one should in general import numkl before numpy. Such that we could successfully link to the ilp64 lib instead of lp64, which is 32bit int interface of MKL and the default one linked by numpy.
## Why
This package is not reinventing wheels like numpy, instead, it provide features that current numpy doesn't provide.
For the symmetric or Hermitian matrix eigenproblem, numpy has already provided the interface `numpy.linalg.eigh` and `numpy.linalg.eigvalsh`. By correctly configuring and linking, these two functions also can directly calling MKL routines. So why bother?
There are at least two aspects why numpy eigenproblem interface is not good enough:
1. The 32 bit int overflow and unable to calculate eigenproblem for large matrix. See [this issue](https://github.com/numpy/numpy/issues/13956). Note currently this issue cannot be solve by simply hacking the compiling parameters, instead one need to change the source code of numpy.
2. The memory waste due to keeping the input matrix. See [this issue](https://github.com/numpy/numpy/issues/14024). Actually, it costs two times of the space in numpy for getting all eigenvalues than directly using lapack routine.In a word, this package is designed for "push-to-the-limit" style computations, where you can compute the eigenproblem for matrix dimension larger than 32766. And the interface is seamlessly integrated with numpy.