diff options
author | kartofen <mladenovnasko0@gmail.com> | 2022-08-24 21:45:43 +0300 |
---|---|---|
committer | kartofen <mladenovnasko0@gmail.com> | 2022-08-24 21:45:43 +0300 |
commit | b6dca5a6ab31476b060bb081cbabeb9dc85023bf (patch) | |
tree | 8b32033d9518d908d2d204fd5b8b1eda1ed5a421 | |
parent | 6d30ea4ac938e4198ff44c082a33d745eb3951e7 (diff) |
fix div by 0
-rw-r--r-- | src/markov.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/markov.h b/src/markov.h index 2fdaf16..2cb22ce 100644 --- a/src/markov.h +++ b/src/markov.h @@ -69,6 +69,8 @@ void generate_chain(char *file_path) for(int j = 0; j < ITEMS; j++) all += items_seen[i][j]; + if(all == 0) continue; + for(int j = 0; j < ITEMS; j++) chain[i][j] = (double)items_seen[i][j]/all; } |