Skip to content

Commit

Permalink
ENH: allow long indices of sparse matrix with umfpack in spsolve()
Browse files Browse the repository at this point in the history
  • Loading branch information
rc committed Apr 21, 2016
1 parent 8fd5d22 commit 4a8cb35
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions scipy/sparse/linalg/dsolve/linsolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ def use_solver(**kwargs):

#TODO: pass other options to scikit

def _get_umf_family(A):
"""Get umfpack family string given the sparse matrix dtype."""
family = {'di': 'di', 'Di': 'zi', 'dl': 'dl', 'Dl': 'zl'}
dt = A.dtype.char + A.indices.dtype.char
return family[dt]

def spsolve(A, b, permc_spec=None, use_umfpack=True):
"""Solve the sparse linear system Ax=b, where b may be a vector or a matrix.
Expand Down Expand Up @@ -129,8 +134,7 @@ def spsolve(A, b, permc_spec=None, use_umfpack=True):
raise ValueError("convert matrix data to double, please, using"
" .astype(), or set linsolve.useUmfpack = False")

family = {'d': 'di', 'D': 'zi'}
umf = umfpack.UmfpackContext(family[A.dtype.char])
umf = umfpack.UmfpackContext(_get_umf_family(A))
x = umf.linsolve(umfpack.UMFPACK_A, A, b_vec,
autoTranspose=True)
else:
Expand Down Expand Up @@ -363,8 +367,7 @@ def factorized(A):
raise ValueError("convert matrix data to double, please, using"
" .astype(), or set linsolve.useUmfpack = False")

family = {'d': 'di', 'D': 'zi'}
umf = umfpack.UmfpackContext(family[A.dtype.char])
umf = umfpack.UmfpackContext(_get_umf_family(A))

# Make LU decomposition.
umf.numeric(A)
Expand Down

0 comments on commit 4a8cb35

Please sign in to comment.