From a1b7631735a58d70877a2455b3f1a170d1474503 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ki=C3=ABd=20Llaentenn?= Date: Mon, 4 Oct 2021 03:59:24 +0000 Subject: [PATCH] Make LCM aware of Gaussian integers --- kalk/src/prelude/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kalk/src/prelude/mod.rs b/kalk/src/prelude/mod.rs index 34f274f..b2535ab 100644 --- a/kalk/src/prelude/mod.rs +++ b/kalk/src/prelude/mod.rs @@ -580,7 +580,9 @@ pub mod funcs { // ⎝ ⎠ pub fn lcm(x: KalkNum, y: KalkNum) -> KalkNum { let gcd = gcd(x.clone(), y.clone()); - return abs(x).div_without_unit(gcd).mul_without_unit(y); + let absx = KalkNum::new_with_imaginary(x.value.abs(), &x.unit, x.imaginary_value); + let absy = KalkNum::new_with_imaginary(y.value.abs(), &y.unit, y.imaginary_value); + return absx.div_without_unit(gcd).mul_without_unit(absy); } pub fn log(x: KalkNum) -> KalkNum {