Skip to content

Commit

Permalink
Add precision tracking and upgrading for Float
Browse files Browse the repository at this point in the history
- Fix precision of float formatting
  • Loading branch information
benruijl committed Jun 20, 2024
1 parent e0ce7b4 commit 273d550
Show file tree
Hide file tree
Showing 5 changed files with 578 additions and 109 deletions.
17 changes: 9 additions & 8 deletions src/coefficient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,15 +539,15 @@ impl CoefficientView<'_> {
let f = f.to_float();
let p = f.prec();
(
f.powf(Rational::new(n2, d2).to_multi_prec_float(p)).into(),
f.powf(&Rational::new(n2, d2).to_multi_prec_float(p)).into(),
Coefficient::one(),
)
}
(&CoefficientView::Float(f), &CoefficientView::Large(r)) => {
let f = f.to_float();
let p = f.prec();
(
f.powf(Rational::from_large(r.to_rat()).to_multi_prec_float(p))
f.powf(&Rational::from_large(r.to_rat()).to_multi_prec_float(p))
.into(),
Coefficient::one(),
)
Expand All @@ -556,7 +556,7 @@ impl CoefficientView<'_> {
let f = f.to_float();
let p = f.prec();
(
Rational::new(n2, d2).to_multi_prec_float(p).powf(f).into(),
Rational::new(n2, d2).to_multi_prec_float(p).powf(&f).into(),
Coefficient::one(),
)
}
Expand All @@ -566,14 +566,15 @@ impl CoefficientView<'_> {
(
Rational::from_large(r.to_rat())
.to_multi_prec_float(p)
.powf(f)
.powf(&f)
.into(),
Coefficient::one(),
)
}
(&CoefficientView::Float(f1), &CoefficientView::Float(f2)) => {
(f1.to_float().powf(f2.to_float()).into(), Coefficient::one())
}
(&CoefficientView::Float(f1), &CoefficientView::Float(f2)) => (
f1.to_float().powf(&f2.to_float()).into(),
Coefficient::one(),
),
_ => {
unimplemented!(
"Power of configuration {:?}^{:?} is not implemented",
Expand Down Expand Up @@ -1355,7 +1356,7 @@ mod test {
);
assert_eq!(
r,
"1.5707963267948966192313216916397514420985846996875529104874722*x+21.472450421034924682062764237715547275896106906504257500510430"
"1.5707963267948966192313216916397514420985846996875529104874722*x+21.472450421034925"
);
}

Expand Down
Loading

0 comments on commit 273d550

Please sign in to comment.