From a70463e14f8766e098b755ed292e42205f306de9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Fuhry?= Date: Wed, 31 May 2023 23:18:19 +0200 Subject: [PATCH] stupid fix apparently I get an overflow with usize (equivalent to u64) and this fixes it --- src/graph/matrix.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/graph/matrix.rs b/src/graph/matrix.rs index f7d92a7..4f89513 100644 --- a/src/graph/matrix.rs +++ b/src/graph/matrix.rs @@ -18,16 +18,16 @@ pub fn fill_with_random(size: usize) -> Vec> { pub fn mult(matrix1: &Vec>, matrix2: &Vec>) -> Vec> { let mut product: Vec> = vec![]; - let mut sum: usize; + let mut sum: u128; for i in 0..matrix1.len() { product.push(vec![]); for j in 0..matrix1.len() { sum = 0; for k in 0..matrix1.len() { - sum += matrix1[i][k] * matrix2[k][j]; + sum += (matrix1[i][k] * matrix2[k][j]) as u128; } - product[i].push(sum); + product[i].push(sum as usize); } } product