Skip to content

Commit 16df68e

Browse files
authored
Merge pull request #24 from ctralie/sparsedm
Sparsedm
2 parents 09d5b99 + 99d68cc commit 16df68e

File tree

8 files changed

+1334
-426
lines changed

8 files changed

+1334
-426
lines changed

Makefile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
build: ripser
22

33

4-
all: python ripser ripser-coeff ripser-reduction ripser-debug
4+
all: ripser ripser-coeff ripser-reduction ripser-coeff-reduction ripser-debug
55

66
python: src/ripser.cpp
77
c++ -std=c++11 src/ripser.cpp -c -o ripser -Ofast -D NDEBUG -D PYTHON_EXTENSION
@@ -15,10 +15,12 @@ python: src/ripser.cpp
1515
# ripser-reduction: ripser.cpp
1616
# c++ -std=c++11 ripser.cpp -o ripser-reduction -Ofast -D NDEBUG -D ASSEMBLE_REDUCTION_MATRIX -D PRINT_PERSISTENCE_PAIRS
1717

18-
# ripser-debug: ripser.cpp
19-
# c++ -std=c++11 ripser.cpp -o ripser-debug -g
18+
ripser-coeff-reduction: ripser.cpp
19+
c++ -std=c++11 ripser.cpp -o ripser-coeff-reduction -Ofast -D NDEBUG -D USE_COEFFICIENTS -D ASSEMBLE_REDUCTION_MATRIX
20+
21+
ripser-debug: ripser.cpp
22+
c++ -std=c++11 ripser.cpp -o ripser-debug -g
2023

2124

2225
clean:
23-
rm -f ripser
24-
#ripser-coeff ripser-reduction ripser-debug
26+
rm -f ripser ripser-coeff ripser-reduction ripser-coeff-reduction ripser-debug

notebooks/Approximate Sparse Filtrations.ipynb

Lines changed: 404 additions & 0 deletions
Large diffs are not rendered by default.

notebooks/Sparse Distance Matrices.ipynb

Lines changed: 153 additions & 0 deletions
Large diffs are not rendered by default.

ripser/pyRips.pxd

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
from libcpp.vector cimport vector
22

33
cdef extern from "ripser.cpp":
4-
vector[float] pythondm(float* D, int N, int modulus,
5-
int dim_max, float threshold, int do_cocycles)
4+
vector[float] rips_dm(float* D, int N, int modulus,
5+
int dim_max, float threshold, int do_cocycles)
66

7+
cdef extern from "ripser.cpp":
8+
vector[float] rips_dm_sparse(int* I, int* J, float* V, int NEdges,
9+
int N, int modulus, int dim_max,
10+
float threshold, int do_cocycles)

ripser/pyRipser.pyx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ def doRipsFiltrationDM(np.ndarray[float,ndim=1,mode="c"] DParam not None, int ma
1010

1111
cdef int N = DParam.shape[0]
1212

13-
res = pyRips.pythondm(&DParam[0], N, coeff, maxHomDim, thresh, do_cocycles)
13+
res = pyRips.rips_dm(&DParam[0], N, coeff, maxHomDim, thresh, do_cocycles)
1414

1515
return res
16+
17+
@cython.boundscheck(False)
18+
@cython.wraparound(False)
19+
def doRipsFiltrationDMSparse(np.ndarray[int,ndim=1,mode="c"] I not None, np.ndarray[int,ndim=1,mode="c"] J not None, np.ndarray[float,ndim=1,mode="c"] V not None, int N, int maxHomDim, float thresh=-1, int coeff=2, int do_cocycles=0):
20+
21+
cdef int NEdges = I.size
22+
23+
res = pyRips.rips_dm_sparse(&I[0], &J[0], &V[0], NEdges, N, coeff, maxHomDim, thresh, do_cocycles)
24+
25+
return res

0 commit comments

Comments
 (0)