Skip to content

Commit 4fc7e76

Browse files
committed
fix index out of bounds
1 parent b020147 commit 4fc7e76

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

algo/main.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ float cal_next_recall_halflife(float h, float p, int d, int recall) {
2929
}
3030

3131
int cal_halflife_index(float h) {
32-
return (int) round(log(h) / log(base)) - min_index;
32+
return max((int) round(log(h) / log(base)) - min_index, 0);
3333
}
3434

3535
float cal_index_halflife(int index) {
@@ -86,7 +86,7 @@ int main() {
8686
}
8787
}
8888

89-
float diff = h0_cost - cost_list[d - 1][h0_index - min_index];
89+
float diff = h0_cost - cost_list[d - 1][h0_index];
9090
if (i % 1000 == 0) {
9191
char name[40];
9292
sprintf(name, "./result/ivl-%d.csv", d);

0 commit comments

Comments
 (0)