Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
stencillogic committed Feb 21, 2023
1 parent 1e84591 commit 3c9de8e
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 25 deletions.
8 changes: 2 additions & 6 deletions astro-float-num/src/ops/atan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,10 @@ impl BigFloatNumber {
// Reduction gives 2^(-p+8) per iteration.
// e_eff compensates error of the series and gives 2^(-p+2).
let add_prec = reduction_times as isize * 8 + 2 - e_eff as isize;
let p_arg = p + if add_prec > 0 { add_prec as usize } else {0};
let p_arg = p + if add_prec > 0 { add_prec as usize } else { 0 };
self.set_precision(p_arg, rm)?;

let arg = if reduction_times > 0 {
self.atan_arg_reduce(reduction_times)?
} else {
self
};
let arg = if reduction_times > 0 { self.atan_arg_reduce(reduction_times)? } else { self };

let acc = arg.clone()?; // x
let x_step = arg.mul(&arg, p_arg, rm)?; // x^2
Expand Down
11 changes: 3 additions & 8 deletions astro-float-num/src/ops/cos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,10 @@ impl BigFloatNumber {
// First parts of the series for any e_eff >= 0 give 2^(-p+6) at most.
// The error of the remaining parts of the series is compensated (see doc/README.md).
let add_prec = reduction_times as isize * 6 + 6 - e_eff as isize;
let p_arg = p + if add_prec > 0 { add_prec as usize } else {0};
let p_arg = p + if add_prec > 0 { add_prec as usize } else { 0 };
self.set_precision(p_arg, rm)?;

let arg = if reduction_times > 0 {
self.cos_arg_reduce(reduction_times)?
} else {
self
};
let arg = if reduction_times > 0 { self.cos_arg_reduce(reduction_times)? } else { self };

let acc = BigFloatNumber::from_word(1, p_arg)?; // 1
let x_step = arg.mul(&arg, p_arg, rm)?; // x^2
Expand Down Expand Up @@ -300,7 +296,7 @@ mod tests {
}
}

/* test the polynimial generator error
/* test the polynimial generator error
#[test]
fn poly_cos() {
let mut e = 0;
Expand All @@ -324,5 +320,4 @@ mod tests {
}
println!("{:?}", e);
} */

}
6 changes: 3 additions & 3 deletions astro-float-num/src/ops/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl BigFloatNumber {
count_leading_zeroes_skip_first(m.mantissa_digits())
} else {
0
} + 3; // we need the error of adding n*ln(2) not to be considered by try_set_precision, so add 3 here.
} + 3; // we need the error of adding n*ln(2) not to be considered by try_set_precision, so add 3 here.

// test for one.
if e == 1 && additional_prec == m.mantissa_max_bit_len() + 3 {
Expand Down Expand Up @@ -172,7 +172,7 @@ impl BigFloatNumber {
// argument substitution for atanh gives 2^(-p+5),
// e_eff compensates error of the series and gives 2^(-p+1).
let add_prec = 7 - e_eff as isize;
let p_arg = p + if add_prec > 0 { add_prec as usize } else {0};
let p_arg = p + if add_prec > 0 { add_prec as usize } else { 0 };
x.set_precision(p_arg, rm)?;

let arg = if reduction_times > 0 {
Expand Down Expand Up @@ -254,7 +254,7 @@ impl BigFloatNumber {
zeroes_cnt
} else {
0
} + 3; // add 3 to avoid error being accounted by try_set_precision
} + 3; // add 3 to avoid error being accounted by try_set_precision

let mut p_inc = WORD_BIT_SIZE;
let mut p_wrk = p.max(self.mantissa_max_bit_len()) + p_inc;
Expand Down
6 changes: 3 additions & 3 deletions astro-float-num/src/ops/pow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,10 @@ impl BigFloatNumber {
);

// Argument reduction gives error 2^(-p+5) per step, and 2^(-p+3) once.
// First parts of the series give 2^(-p+5).
// First parts of the series give 2^(-p+5).
// The error of the remaining parts of the series is compensated (see doc/README.md).
let add_prec = reduction_times as isize * 5 + 8 - e_eff as isize;
let p_arg = p + if add_prec > 0 { add_prec as usize } else {0};
let p_arg = p + if add_prec > 0 { add_prec as usize } else { 0 };
self.set_precision(p_arg, rm)?;

let arg = if reduction_times > 0 {
Expand Down Expand Up @@ -739,7 +739,7 @@ mod test {
}
}

/* test the polynimial generator error
/* test the polynimial generator error
#[test]
fn poly_sinh() {
let mut e = 0;
Expand Down
2 changes: 1 addition & 1 deletion astro-float-num/src/ops/sin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ impl BigFloatNumber {
// First parts of the series for any e_eff >= 0 give 2^(-p+6) at most.
// The error of the remaining parts of the series is compensated (see doc/README.md).
let add_prec = reduction_times as isize * 6 + 9 - e_eff as isize;
let p_arg = p + if add_prec > 0 { add_prec as usize } else {0};
let p_arg = p + if add_prec > 0 { add_prec as usize } else { 0 };
self.set_precision(p_arg, rm)?;

let arg = if reduction_times > 0 {
Expand Down
2 changes: 1 addition & 1 deletion astro-float-num/src/ops/tan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl BigFloatNumber {
);

let add_prec = reduction_times as isize * 4 + 9 - e_eff as isize;
let p_arg = p + if add_prec > 0 { add_prec as usize } else {0};
let p_arg = p + if add_prec > 0 { add_prec as usize } else { 0 };
self.set_precision(p_arg, rm)?;

let arg_holder;
Expand Down
3 changes: 1 addition & 2 deletions astro-float-num/src/ops/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,6 @@ fn test_tanh_atanh() {
}
}


// Test operations error.
/* #[test]
fn test_err() {
Expand Down Expand Up @@ -1002,4 +1001,4 @@ fn test_err() {
}
}
println!("maxerr {}", maxeer);
} */
} */
1 change: 0 additions & 1 deletion astro-float-num/tests/mpfr/compare_const_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ fn mpfr_compare_const() {
let rm = RoundingMode::ToEven;
let rnd = rnd_t::RNDN;


let mut mpfr_e = Float::with_val(p as u32, 1);
unsafe {
mpfr::exp(
Expand Down

0 comments on commit 3c9de8e

Please sign in to comment.