Skip to content

Commit 20fbdbd

Browse files
authored
covariance_ext: fix adaptive subsampling increment when scene is small (#121)
1 parent 1402f3c commit 20fbdbd

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

kite/ext/covariance.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ uint32_t finished_combinations = 0;
2727
typedef npy_float32 float32_t;
2828
typedef npy_float64 float64_t;
2929

30+
#ifndef max
31+
#define max(a,b) \
32+
({ __typeof__ (a) _a = (a); \
33+
__typeof__ (b) _b = (b); \
34+
_a > _b ? _a : _b; })
35+
#endif
36+
3037
typedef enum {
3138
SUCCESS = 0,
3239
SAUBSAMPLING_SPARSE_ERROR
@@ -127,7 +134,7 @@ static state_covariance calc_covariance_matrix(
127134
for (il1=0; il1<nleaves; il1++) {
128135
if (adaptive_subsampling) {
129136
l_length = map[il1*4+1] - map[il1*4+0];
130-
subsampling[il1] = ceil(LOG2(l_length));
137+
subsampling[il1] = max(ceil(LOG2(l_length)), 1);
131138
} else {
132139
subsampling[il1] = 1;
133140
}

0 commit comments

Comments
 (0)