pub mod evaluation {
use ffi;
use enums;
use types::ComplexF64;
use std::mem::transmute;
pub fn poly_eval(c: &[f64], x: f64) -> f64 {
unsafe { ffi::gsl_poly_eval(c.as_ptr(), c.len() as i32, x) }
}
pub fn poly_complex_eval(c: &[f64], z: &ComplexF64) -> ComplexF64 {
unsafe { transmute(ffi::gsl_poly_complex_eval(c.as_ptr(), c.len() as i32, transmute(*z))) }
}
pub fn complex_poly_complex_eval(c: &[ComplexF64], z: &ComplexF64) -> ComplexF64 {
let mut tmp = Vec::new();
for it in c.iter() {
unsafe { tmp.push(transmute(*it)) };
}
unsafe { transmute(ffi::gsl_complex_poly_complex_eval(tmp.as_ptr(), tmp.len() as i32, transmute(*z))) }
}
pub fn poly_eval_derivs(c: &[f64], x: f64, res: &mut [f64]) -> enums::value::Value {
unsafe { ffi::gsl_poly_eval_derivs(c.as_ptr(), c.len() as u64, x, res.as_mut_ptr(), res.len() as u64) }
}
}
pub mod divided_difference_representation {
use ffi;
use enums;
pub fn poly_dd_init(dd: &mut [f64], xa: &[f64], ya: &[f64]) -> enums::value::Value {
unsafe { ffi::gsl_poly_dd_init(dd.as_mut_ptr(), xa.as_ptr(), ya.as_ptr(), dd.len() as u64) }
}
pub fn poly_dd_eval(dd: &[f64], xa: &[f64], x: f64) -> f64 {
unsafe { ffi::gsl_poly_dd_eval(dd.as_ptr(), xa.as_ptr(), dd.len() as u64, x) }
}
pub fn poly_dd_taylor(c: &mut [f64], xp: f64, dd: &[f64], xa: &[f64], w: &mut [f64]) -> enums::value::Value {
unsafe { ffi::gsl_poly_dd_taylor(c.as_mut_ptr(), xp, dd.as_ptr(), xa.as_ptr(), dd.len() as u64, w.as_mut_ptr()) }
}
pub fn poly_dd_hermite_init(dd: &mut [f64], za: &mut [f64], xa: &[f64], ya: &[f64], dya: &[f64]) -> enums::value::Value {
unsafe { ffi::gsl_poly_dd_hermite_init(dd.as_mut_ptr(), za.as_mut_ptr(), xa.as_ptr(), ya.as_ptr(), dya.as_ptr(), dd.len() as u64) }
}
}
pub mod quadratic_equations {
use ffi;
use types::ComplexF64;
use std::mem::transmute;
pub fn poly_solve_quadratic(a: f64, b: f64, c: f64, x0: &mut f64, x1: &mut f64) -> i32 {
unsafe { ffi::gsl_poly_solve_quadratic(a, b, c, x0, x1) }
}
pub fn poly_complex_solve_quadratic(a: f64, b: f64, c: f64, z0: &mut ComplexF64, z1: &mut ComplexF64) -> i32 {
unsafe { ffi::gsl_poly_complex_solve_quadratic(a, b, c, transmute(z0), transmute(z1)) }
}
}
pub mod cubic_equations {
use ffi;
use types::ComplexF64;
use std::mem::transmute;
pub fn poly_solve_cubic(a: f64, b: f64, c: f64, x0: &mut f64, x1: &mut f64, x2: &mut f64) -> i32 {
unsafe { ffi::gsl_poly_solve_cubic(a, b, c, x0, x1, x2) }
}
pub fn poly_complex_solve_cubic(a: f64, b: f64, c: f64, z0: &mut ComplexF64, z1: &mut ComplexF64, z2: &mut ComplexF64) -> i32 {
unsafe { ffi::gsl_poly_complex_solve_cubic(a, b, c, transmute(z0), transmute(z1), transmute(z2)) }
}
}