Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const XSF_HEADERS: &[&str] = &[
"log.h",
"loggamma.h",
"mathieu.h",
// "par_cyl.h",
"par_cyl.h",
// "sici.h",
"specfun.h",
"sph_bessel.h",
Expand Down Expand Up @@ -197,7 +197,9 @@ const XSF_TYPES: &[(&str, &str)] = &[
("cem_cva", "dd->d"),
("sem_cva", "dd->d"),
// par_cyl.h
// TODO: `pbwa`, `pbdv`, `pbvv`
("pbwa", "dd->dd"),
("pbdv", "dd->dd"),
("pbvv", "dd->dd"),
// sici.h
// TODO: `sici`, `shichi`,
// specfun.h
Expand Down
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ pub use loggamma::{loggamma, rgamma};
mod mathieu;
pub use mathieu::{cem_cva, sem_cva};

// par_cyl.h
mod par_cyl;
pub use par_cyl::{pbdv, pbvv, pbwa};

// specfun.h
mod specfun;
pub use specfun::{hyp1f1, hyperu, hypu, pmv};
Expand Down
71 changes: 71 additions & 0 deletions src/par_cyl.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
use crate::bindings;

/// Parabolic cylinder function *W*
///
/// The function is a particular solution to the differential equation:
///
/// y″ + (x²/4 - a)y = 0
///
/// # Arguments
///
/// - `a` - Real parameter
/// - `x` - Real argument
///
/// # Returns
///
/// - *w*: Value of the function
/// - *wp*: Value of the derivative in `x`
pub fn pbwa(a: f64, x: f64) -> (f64, f64) {
let mut w = f64::NAN;
let mut wd = f64::NAN;
unsafe {
bindings::pbwa(a, x, &mut w, &mut wd);
}
(w, wd)
}

/// Parabolic cylinder function *D*
///
/// Returns *(d, dp)* the parabolic cylinder function *Dv(x)* in *d* and the derivative,
/// *Dv'(x)* in *dp*.
///
/// # Arguments
///
/// - `v` - Real parameter
/// - `x` - Real argument
///
/// # Returns
///
/// - *d*: Value of the function
/// - *dp*: Value of the derivative in `x`
pub fn pbdv(v: f64, x: f64) -> (f64, f64) {
let mut d = f64::NAN;
let mut dp = f64::NAN;
unsafe {
bindings::pbdv(v, x, &mut d, &mut dp);
}
(d, dp)
}

/// Parabolic cylinder function *V*
///
/// Returns *(v, vp)* the parabolic cylinder function *Vv(x)* in *v* and the derivative,
/// *Vv'(x)* in *vp*.
///
/// # Arguments
///
/// - `v` - Real parameter
/// - `x` - Real argument
///
/// # Returns
///
/// - *v*: Value of the function
/// - *vp*: Value of the derivative in `x`
pub fn pbvv(v: f64, x: f64) -> (f64, f64) {
let mut vv = f64::NAN;
let mut vp = f64::NAN;
unsafe {
bindings::pbvv(v, x, &mut vv, &mut vp);
}
(vv, vp)
}
38 changes: 27 additions & 11 deletions tests/test_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,28 @@ macro_rules! xsref_test {
);
}
};
(@single $f:ident, "d->dddd") => {
paste::paste! {
_test!(
[<test_ $f _ d>],
$f,
"d-d_d_d_d",
|x: &[f64]| xsf::$f(x[0]),
(f64, f64, f64, f64)
);
}
};
(@single $f:ident, "dd->dd") => {
paste::paste! {
_test!(
[<test_ $f _ d>],
$f,
"d_d-d_d",
|x: &[f64]| xsf::$f(x[0], x[1]),
(f64, f64)
);
}
};
(@single $f:ident, "D->DD") => {
paste::paste! {
_test!(
Expand All @@ -626,17 +648,6 @@ macro_rules! xsref_test {
);
}
};
(@single $f:ident, "d->dddd") => {
paste::paste! {
_test!(
[<test_ $f _ d>],
$f,
"d-d_d_d_d",
|x: &[f64]| xsf::$f(x[0]),
(f64, f64, f64, f64)
);
}
};
(@single $f:ident, "D->DDDD") => {
paste::paste! {
_test!(
Expand Down Expand Up @@ -869,6 +880,11 @@ xsref_test!(rgamma, "d->d", "D->D");
xsref_test!(cem_cva, "dd->d");
xsref_test!(sem_cva, "dd->d");

// par_cyl.h
xsref_test!(pbwa, "dd->dd");
xsref_test!(pbdv, "dd->dd");
xsref_test!(pbvv, "dd->dd");

// specfun.h
xsref_test!(hyperu, "ddd->d"); // alias of `hypu`
xsref_test!(hyp1f1, "ddD->D"); // no table for ddd->d
Expand Down
Loading