geometry-central
geometry-central copied to clipboard
Better support for reading/writing sparse matrices
We should add support for the following formats (both reading and writing):
-
spmat(MATLAB) — 1-based indexing, just a list of (row, column, value) triples. No matrix size. No special assumptions about ordering of triples. Redundant triples are allowed on read. For matrices with an empty last row or column, we should be sure to write a "dummy" zero in the bottom-right entry. -
npz(SciPy) — see https://docs.scipy.org/doc/scipy-1.2.3/reference/generated/scipy.sparse.load_npz.html -
dmat(libigl) — see https://libigl.github.io/libigl-python-bindings/igl_docs/#read_dmat First line gives matrix dimensions; remaining lines give (row, column, value) entries. Not clear if entries are 0-or 1-based. Seems a special (sorted) ordering is assumed, probably to provide fast load into an Eigen matrix without sorting.
FYI there's now support for reading/writing spmat files (called loadSparseMatrix and saveSparseMatrix in numerical/linear_algebra_utilities.h. It would still be great to support more file types!