Skip to content

Commit

Permalink
Fix sici and shichi return types
Browse files Browse the repository at this point in the history
The implementation returns a status code that is always 0. This is now
reflected by the low-level bindings. The high-level bindings now return
`()`.

Fixes #13, #14.
  • Loading branch information
vks committed Dec 17, 2023
1 parent 6e68a95 commit ded37f8
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub mod unsafe_cephes_double {
/// Compute accurately cos(x) - 1 for x close to 0.
pub fn cosm1(x: f64) -> f64;
/// Sine and cosine integrals.
pub fn sici(x: f64, si: &mut f64, ci: &mut f64) -> f64;
pub fn sici(x: f64, si: &mut f64, ci: &mut f64) -> i32;

// Hyperbolic functions
/// Hyperbolic sine.
Expand All @@ -106,7 +106,7 @@ pub mod unsafe_cephes_double {
/// Inverse hyperbolic tangent.
pub fn atanh(x: f64) -> f64;
/// Hyperbolic sine and cosine integrals.
pub fn shichi(x: f64, chi: &mut f64, shi: &mut f64);
pub fn shichi(x: f64, chi: &mut f64, shi: &mut f64) -> i32;

// Beta functions
/// Beta function.
Expand Down Expand Up @@ -540,10 +540,11 @@ pub mod cephes_double {
/// let mut si = 0.0_f64;
/// let mut ci = 0.0_f64;
/// let mut code = 0.0_f64;
/// code = sici(0.5_f64, &mut si, &mut ci);
/// sici(0.5_f64, &mut si, &mut ci);
/// ```
pub fn sici(x: f64, si: &mut f64, ci: &mut f64) -> f64 {
unsafe { unsafe_cephes_double::sici(x, si, ci) }
pub fn sici(x: f64, si: &mut f64, ci: &mut f64) {
let code = unsafe { unsafe_cephes_double::sici(x, si, ci) };
assert_eq!(code, 0);
}

/// Function to accurately compute hyperbolic sine and cosine integrals
Expand Down Expand Up @@ -598,7 +599,8 @@ pub mod cephes_double {
/// shichi(0.5_f64, &mut shi, &mut chi);
/// ```
pub fn shichi(x: f64, chi: &mut f64, shi: &mut f64){
unsafe { unsafe_cephes_double::shichi(x, chi, shi) }
let code = unsafe { unsafe_cephes_double::shichi(x, chi, shi) };
assert_eq!(code, 0);
}

/// Function to compute the beta function.
Expand Down Expand Up @@ -820,7 +822,7 @@ pub mod unsafe_cephes_single {
/// Quadrant-correct inverse circular tangent.
pub fn atan2f(y: f32, x: f32) -> f32;
/// Sine and cosine integrals.
pub fn sicif(x: f32, si: &mut f32, ci: &mut f32) -> f32;
pub fn sicif(x: f32, si: &mut f32, ci: &mut f32) -> i32;

// Hyperbolic functions
/// Hyperbolic sine.
Expand All @@ -836,7 +838,7 @@ pub mod unsafe_cephes_single {
/// Inverse hyperbolic tangent.
pub fn atanhf(x: f32) -> f32;
/// Hyperbolic sine and cosine integrals.
pub fn shichif(x: f32, chi: &mut f32, shi: &mut f32);
pub fn shichif(x: f32, chi: &mut f32, shi: &mut f32) -> i32;

// Beta functions
/// Beta function.
Expand Down Expand Up @@ -1228,11 +1230,11 @@ pub mod cephes_single {
/// let x = 0.1f32;
/// let mut si = 0.0_f32;
/// let mut ci = 0.0_f32;
/// let mut code = 0.0_f32;
/// code = sici(0.5_f32, &mut si, &mut ci);
/// sici(0.5_f32, &mut si, &mut ci);
/// ```
pub fn sici(x: f32, si: &mut f32, ci: &mut f32) -> f32 {
unsafe { unsafe_cephes_single::sicif(x, si, ci) }
pub fn sici(x: f32, si: &mut f32, ci: &mut f32) {
let code = unsafe { unsafe_cephes_single::sicif(x, si, ci) };
assert_eq!(code, 0);
}

/// Function to accurately compute hyperbolic sine and cosine integrals
Expand Down Expand Up @@ -1287,7 +1289,8 @@ pub mod cephes_single {
/// shichi(0.5_f32, &mut shi, &mut chi);
/// ```
pub fn shichi(x: f32, chi: &mut f32, shi: &mut f32){
unsafe { unsafe_cephes_single::shichif(x, chi, shi) }
let code = unsafe { unsafe_cephes_single::shichif(x, chi, shi) };
assert_eq!(code, 0);
}

/// Function to compute the beta function.
Expand Down

0 comments on commit ded37f8

Please sign in to comment.