You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Iḿ struggling with performance because rust has no globlal variables and thus I have to parse them all the time in the code. Using lazy_static actually introduces some overhead. How to have fast constants for usage in code?
pub fn ln_halley(x: &BigDecimal, scale: i64) -> BigDecimal {
//parsing this everytime is bad
let epsilon = BigDecimal::from_f64(0.00000000000000001).unwrap();
let mut y = x - &BigDecimal::one();
let y_0 = y.clone();
loop {
//parsing "2" all the time here too
y = &y + BigDecimal::from_u64(2).unwrap()*(x-&y.exp())/(x+y.exp());
if (&y-&y_0).abs() < epsilon {
break;
}
}
y
}
The text was updated successfully, but these errors were encountered:
Iḿ struggling with performance because rust has no globlal variables and thus I have to parse them all the time in the code. Using lazy_static actually introduces some overhead. How to have fast constants for usage in code?
The text was updated successfully, but these errors were encountered: