23 Sep 00:17 2014

### Interest in a banded matrix solver?

Most of the matrices I deal with have a banded structure coming from a finite-difference representation. I noticed that for such matrices, the DOK implementation is far from optimal so I implemented a matrix diagonal storage form (http://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.solve_banded.html) where

ab[u + i - j, j] == a[i,j].I also implemented a banded solver that is significantly faster for such matrices. Here's a brief sample

np = 100

sol = randMatrix(np, 1)

upper, lower = 1, 3

def fd_mat(i, j, upper=upper, lower=lower, np=np):

for shift in range(-upper, lower+1):

if i==j+shift:

return randint(shift, high=2*np//(abs(shift)+1))

s = SparseMatrix(np, np, fd_mat)

sol = randMatrix(np, 1)

upper, lower = 1, 3

def fd_mat(i, j, upper=upper, lower=lower, np=np):

for shift in range(-upper, lower+1):

if i==j+shift:

return randint(shift, high=2*np//(abs(shift)+1))

s = SparseMatrix(np, np, fd_mat)

In [408]:

%timeit s.LUsolve(sol)

You received this message because you are subscribed to the Google Groups "sympy" group.

To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.

To post to this group, send email to sympy-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.

Visit this group at http://groups.google.com/group/sympy.

To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/db70744c-7bcb-4bfb-a43d-d99aee3b779c%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.