Skip to content

Commit 0b05dc0

Browse files
author
counterclocker
committed
added read MM file format
1 parent 5855e96 commit 0b05dc0

14 files changed

Lines changed: 10243 additions & 653 deletions

File tree

examples/mm.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from sparse_lib.sparse.ll_mat import MakeLLSparseMatrix
2+
3+
import sys
4+
5+
A = MakeLLSparseMatrix(mm_filename="simple_matrix.mm")
6+
7+
print type(A)
8+
9+
A.print_to(sys.stdout)

examples/simple_matrix.mm

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
%%MatrixMarket matrix coordinate real general
2+
% Generated 27-Feb-2012
3+
3 4 9
4+
1 1 0.8147236863931789
5+
2 1 0.9057919370756192
6+
3 1 0.1269868162935061
7+
2 2 0.6323592462254095
8+
3 2 0.09754040499940952
9+
1 3 0.2784982188670484
10+
2 3 0.5468815192049838
11+
3 3 0.9575068354342976
12+
2 4 0.1576130816775483

setup.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,16 @@ def get_path_option(config, section, option):
5959
Extension("sparse_lib.sparse.csr_mat", ["sparse_lib/sparse/csr_mat.pxd", "sparse_lib/sparse/csr_mat.pyx"], **sparse_ext_params),
6060
Extension("sparse_lib.sparse.csc_mat", ["sparse_lib/sparse/csc_mat.pxd", "sparse_lib/sparse/csc_mat.pyx"], **sparse_ext_params),
6161
Extension("sparse_lib.sparse.ll_mat_view", ["sparse_lib/sparse/ll_mat_view.pxd", "sparse_lib/sparse/ll_mat_view.pyx"], **sparse_ext_params),
62-
Extension("sparse_lib.utils.equality", ["sparse_lib/utils/equality.pxd", "sparse_lib/utils/equality.pyx"], **sparse_ext_params),
62+
Extension("sparse_lib.sparse.IO.mm", ["sparse_lib/sparse/IO/mm_read_file.pxi", "sparse_lib/sparse/IO/mm.pxd", "sparse_lib/sparse/IO/mm.pyx"], **sparse_ext_params),
6363
#Extension("sparse.ll_vec", ["sparse_lib/sparse/ll_vec.pyx"], **sparse_ext_params)
6464
]
6565

66+
########################################################################################################################
67+
# *** utils ***
68+
utils_ext = [
69+
Extension("sparse_lib.utils.equality", ["sparse_lib/utils/equality.pxd", "sparse_lib/utils/equality.pyx"], **sparse_ext_params),
70+
]
71+
6672
########################################################################################################################
6773
# *** umfpack ***
6874
umfpack_ext_params = ext_params.copy()
@@ -82,7 +88,7 @@ def get_path_option(config, section, option):
8288
########################################################################################################################
8389
# SETUP
8490
########################################################################################################################
85-
ext_modules = sparse_ext + umfpack_ext
91+
ext_modules = sparse_ext + utils_ext + umfpack_ext
8692

8793

8894
setup(name= 'SparseLib',
@@ -95,6 +101,7 @@ def get_path_option(config, section, option):
95101
'sparse_lib.utils',
96102
'sparse_lib.solvers',
97103
'sparse_lib.solvers.suitesparse',
104+
'sparse_lib.sparse.IO'
98105
]
99106

100107
)

sparse_lib/solvers/suitesparse/umfpack.c

Lines changed: 227 additions & 115 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sparse_lib/solvers/suitesparse/umfpack.pyx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ cdef class UmfpackSolver:
410410

411411
return (lnz, unz, n_row, n_col, nz_udiag)
412412

413-
def get_LU(self):
413+
def get_LU(self, get_L=True, get_U=True, get_P=True, get_Q=True, get_D=True, get_R=True):
414414
"""
415415
Return LU factorisation objects. If needed, the LU factorisation is triggered.
416416
@@ -435,6 +435,8 @@ cdef class UmfpackSolver:
435435
436436
"""
437437
# TODO: use properties?? we can only get matrices, not set them...
438+
# TODO: implement the use of L=True, U=True, P=True, Q=True, D=True, R=True
439+
# i.e. allow to return only parts of the arguments and not necessarily all of them...
438440
self.create_numeric()
439441

440442
cdef:

0 commit comments

Comments
 (0)