GithubHelp home page GithubHelp logo

basnijholt / mumpy Goto Github PK

View Code? Open in Web Editor NEW
4.0 4.0 2.0 24 KB

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

License: Other

Python 100.00%
python linear-algebra sparse-linear-systems binding

mumpy's Introduction

mumpy

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

Installation

On Linux

Either install mumps with:

sudo apt-get instal libmumps-scotch-dev

Both on Linux and OSX

or use the conda package on conda-forge

conda config --add channels conda-forge
conda install cython mumps numpy scipy libgfortran
pip install [email protected]:basnijholt/mumpy.git

and use the following build.conf (if on Linux, not needed for OSX)

[mumps]
include_dirs = $CONDA_PREFIX/include
library_dirs = $CONDA_PREFIX/lib
libraries = zmumps mumps_common pord metis esmumps scotch scotcherr mpiseq gfortran
extra_link_args = -Wl,-rpath=$CONDA_PREFIX/lib

Usage

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


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

    Please see scipy.sparse.linalg.eigsh for documentation.
    
    Notes
    -----
    mumpy only works with complex numbers at the moment.
    """
    class LuInv(sla.LinearOperator):
        def __init__(self, A):
            inst = mumps.MUMPSContext()
            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)

mumpy's People

Contributors

basnijholt avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mumpy's Issues

error when importing mumpy

In [1]: import mumpy.mumps as mumps

ImportError Traceback (most recent call last)
in ()
Hello,

I get an error when I import mumpy. Do you know what could be the origin of the issue?

Thanks!

Alexandre

============================

----> 1 import mumpy.mumps as mumps

~/anaconda/lib/python3.5/site-packages/mumpy/mumps.py in ()
16 import scipy.sparse
17 import warnings
---> 18 from . import _mumps
19 from .fortran_helpers import prepare_for_fortran
20

ImportError: dlopen(/Users/myuser/anaconda/lib/python3.5/site-packages/mumpy/_mumps.cpython-35m-darwin.so, 2): Symbol not found: _zmumps_c
Referenced from: /Users/myuser/anaconda/lib/python3.5/site-packages/mumpy/_mumps.cpython-35m-darwin.so
Expected in: flat namespace
in /Users/myuser/anaconda/lib/python3.5/site-packages/mumpy/_mumps.cpython-35m-darwin.so

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.