diff --git a/CHANGELOG.md b/CHANGELOG.md index b1b4541..66f444e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# Version 2.11.6 : Fix bug + +## Bug fix +- fix bug with lup-decomposition of rationals (an abs missing) + # Version 2.11.5 : Pretty print ## Bug fix diff --git a/Cargo.toml b/Cargo.toml index 892e7b8..8ba644b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mini-calc" -version = "2.11.5" +version = "2.11.6" license = "GPL-3.0-or-later" description = "A fully-featured minimalistic configurable rust calculator" homepage = "https://calc.nwa2coco.fr" diff --git a/src/configuration/loader.rs b/src/configuration/loader.rs index adefe34..2297061 100644 --- a/src/configuration/loader.rs +++ b/src/configuration/loader.rs @@ -131,7 +131,7 @@ pub fn load_color(string: String) -> Color { pub fn replace_variable(str: String) -> String { str.replace("%author%", "Charlotte Thomas") - .replace("%version%", "v2.11.5") + .replace("%version%", "v2.11.6") .to_string() } diff --git a/src/main.rs b/src/main.rs index 11d65cc..9254ef1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -279,7 +279,7 @@ fn main() { let style = &loaded.clone().prompt_style; let mut text = &loaded.clone().prompt; let mut verbose = false; - let version: String = "v2.11.5".to_string(); + let version: String = "v2.11.6".to_string(); interface.set_completer(Arc::new(CalcCompleter)); interface .set_prompt(&format!( diff --git a/src/parsing/ast.rs b/src/parsing/ast.rs index 67fab41..71153a0 100644 --- a/src/parsing/ast.rs +++ b/src/parsing/ast.rs @@ -188,7 +188,7 @@ impl Parameters { for y in x.clone() { let vs = vec![" "; (max_size - y.len()) / 2]; let vs2 = vec![" "; (max_size - y.len()) - vs.len()]; - new_line.push(format!("{}{}{}", vs.join(""), y, vs2.join(""))); + new_line.push(format!("{}{}{}", vs2.join(""), y, vs.join(""))); } final_v.push(new_line); @@ -292,6 +292,7 @@ impl Parameters { match self { Parameters::Int(i) => Parameters::Int(i.abs()), Parameters::Float(f) => Parameters::Float(f.abs()), + Parameters::Rational(r) => Parameters::Rational(r.abs()), Parameters::Identifier(s) => match ram { None => Parameters::Null, Some(t) => { diff --git a/src/utils/matrix_utils.rs b/src/utils/matrix_utils.rs index 61924d9..b696937 100644 --- a/src/utils/matrix_utils.rs +++ b/src/utils/matrix_utils.rs @@ -73,7 +73,7 @@ pub fn lup_decompose( for i in 0..n { max_a = Parameters::Float(0.0); - i_max = 0; + i_max = i; for k in i..n { abs_a = ((a[k])[i]).clone().abs(ram.as_deref()); @@ -82,7 +82,6 @@ pub fn lup_decompose( max_a = (abs_a).clone(); i_max = k; } - _ => (), } } @@ -109,10 +108,9 @@ pub fn lup_decompose( (p)[n] = add((p)[n].clone(), Parameters::Int(1), ram.as_deref()); } - for j in i + 1..n { + for j in (i + 1)..n { (a)[j][i] = divide((a)[j][i].clone(), (a)[i][i].clone(), ram.as_deref()); - - for k in i + 1..n { + for k in (i + 1)..n { (a)[j][k] = minus( (a)[j][k].clone(), mult((a)[j][i].clone(), (a)[i][k].clone(), ram.as_deref()), @@ -131,7 +129,6 @@ pub fn lup_determinant( ram: Option<&HashMap>, ) -> Parameters { let mut det: Parameters = (&a[0][0]).clone(); - for i in 1..n { det = mult(det.clone(), (&a[i][i]).clone(), ram.as_deref()) }