Skip to content

Commit 7c7cad7

Browse files
committed
tests: internal: ripser: Fix building errors on Windows
Signed-off-by: Hiroshi Hatake <[email protected]>
1 parent 1f29392 commit 7c7cad7

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

tests/internal/ripser.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414

1515
void test_ripser_betti_circle()
1616
{
17-
/* Number of points sampled on the circle */
18-
const size_t n = 16;
17+
#define SIZE_N 16 /* Number of points sampled on the circle */
1918

2019
/* Maximum homology dimension (0, 1, 2) */
2120
const int max_dim = 2;
@@ -24,10 +23,10 @@ void test_ripser_betti_circle()
2423
const float threshold = 2.0f;
2524

2625
/* Point cloud (n x 2) */
27-
double pts[n][2];
26+
double pts[SIZE_N][2];
2827

2928
/* Full dense distance matrix (n x n) */
30-
const size_t m = n * n;
29+
const size_t m = SIZE_N * SIZE_N;
3130
float *dist = NULL;
3231

3332
int ret;
@@ -38,8 +37,8 @@ void test_ripser_betti_circle()
3837
double dy;
3938

4039
/* Generate points uniformly on the unit circle */
41-
for (i = 0; i < n; i++) {
42-
theta = 2.0 * M_PI * (double) i / (double) n;
40+
for (i = 0; i < SIZE_N; i++) {
41+
theta = 2.0 * M_PI * (double) i / (double) SIZE_N;
4342
pts[i][0] = cos(theta);
4443
pts[i][1] = sin(theta);
4544
}
@@ -52,15 +51,15 @@ void test_ripser_betti_circle()
5251
}
5352

5453
/* Fill dense distance matrix: dist[i*n + j] = d(i,j) */
55-
for (i = 0; i < n; i++) {
56-
for (j = 0; j < n; j++) {
54+
for (i = 0; i < SIZE_N; i++) {
55+
for (j = 0; j < SIZE_N; j++) {
5756
if (i == j) {
58-
dist[i * n + j] = 0.0f;
57+
dist[i * SIZE_N + j] = 0.0f;
5958
}
6059
else {
6160
dx = pts[i][0] - pts[j][0];
6261
dy = pts[i][1] - pts[j][1];
63-
dist[i * n + j] = (float) sqrt(dx * dx + dy * dy);
62+
dist[i * SIZE_N + j] = (float) sqrt(dx * dx + dy * dy);
6463
}
6564
}
6665
}
@@ -69,7 +68,7 @@ void test_ripser_betti_circle()
6968

7069
/* Run ripser on the dense distance matrix */
7170
ret = flb_ripser_compute_betti_from_dense_distance(dist,
72-
n,
71+
SIZE_N,
7372
max_dim,
7473
threshold,
7574
&b);
@@ -106,6 +105,7 @@ void test_ripser_betti_circle()
106105
TEST_CHECK(b.betti[2] >= 0);
107106

108107
free(dist);
108+
#undef SIZE_N
109109
}
110110

111111
TEST_LIST = {

0 commit comments

Comments
 (0)