Skip to content

Commit

Permalink
handle signed zero in li6
Browse files Browse the repository at this point in the history
  • Loading branch information
Expander committed Mar 6, 2024
1 parent 3b71df7 commit e27eb5c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/li5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ impl Li5<Complex<f64>> for Complex<f64> {
let c3 = 0.27415567780803774;
let c4 = (25.0/12.0 - (-u).cln())/24.0;
let c5 = -1.0/240.0;

let cs = [
-1.1574074074074074e-04, 2.0667989417989418e-07,
-1.0935444136502338e-09, 8.6986487449450412e-12,
Expand Down
7 changes: 3 additions & 4 deletions src/li6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ impl Li6<Complex<f64>> for Complex<f64> {
let z6 = 1.0173430619844491; // zeta(6)

if self.im == 0.0 && self.re == 0.0 {
Complex::new(0.0, 0.0)
*self
} else if self.im == 0.0 && self.re == 1.0 {
Complex::new(z6, 0.0)
Complex::new(z6, self.im)
} else if self.im == 0.0 && self.re == -1.0 {
Complex::new(-31.0/32.0*z6, 0.0)
Complex::new(-31.0/32.0*z6, self.im)
} else {
let nz = self.norm();
let pz = self.arg();
Expand All @@ -43,7 +43,6 @@ impl Li6<Complex<f64>> for Complex<f64> {
let c4 = 0.068538919452009435;
let c5 = (137.0/60.0 - (-u).cln())/120.0;
let c6 = -1.0/1440.0;

let cs = [
-1.6534391534391534e-05, 2.2964432686654909e-08,
-9.9413128513657614e-11, 6.6912682653423394e-13,
Expand Down
16 changes: 16 additions & 0 deletions tests/li6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,19 @@ fn test_values() {
assert_eq_complex!(v.li6(), li6, eps);
}
}


#[test]
fn test_signed_zero() {
let pz64 = 0.0_f64;
let nz64 = -0.0_f64;

assert!(Complex::new(pz64, pz64).li6().re.is_sign_positive());
assert!(Complex::new(pz64, pz64).li6().im.is_sign_positive());
assert!(Complex::new(pz64, nz64).li6().re.is_sign_positive());
assert!(Complex::new(pz64, nz64).li6().im.is_sign_negative());
assert!(Complex::new(nz64, pz64).li6().re.is_sign_negative());
assert!(Complex::new(nz64, pz64).li6().im.is_sign_positive());
assert!(Complex::new(nz64, nz64).li6().re.is_sign_negative());
assert!(Complex::new(nz64, nz64).li6().im.is_sign_negative());
}

0 comments on commit e27eb5c

Please sign in to comment.