Skip to content

Commit

Permalink
Merge pull request #34 from coco33920/fix_bug
Browse files Browse the repository at this point in the history
Fix bug
  • Loading branch information
vanilla-extracts authored Nov 28, 2023
2 parents 0d214a8 + 275c3fa commit 1880941
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/configuration/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down
3 changes: 2 additions & 1 deletion src/parsing/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) => {
Expand Down
9 changes: 3 additions & 6 deletions src/utils/matrix_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -82,7 +82,6 @@ pub fn lup_decompose(
max_a = (abs_a).clone();
i_max = k;
}

_ => (),
}
}
Expand All @@ -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()),
Expand All @@ -131,7 +129,6 @@ pub fn lup_determinant(
ram: Option<&HashMap<String, Parameters>>,
) -> 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())
}
Expand Down

0 comments on commit 1880941

Please sign in to comment.