1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//
// A rust binding for the GSL library by Guillaume Gomez (guillaume1.gomez@gmail.com)
//

//! The Gegenbauer polynomials are defined in Abramowitz & Stegun, Chapter 22, where they are known as Ultraspherical polynomials.

use ffi;
use std::mem::zeroed;
use enums;

/// This function evaluates the Gegenbauer polynomials C^{(\lambda)}_n(x) using explicit representations for n =1, 2, 3.
pub fn gegenpoly_1(lambda: f64, x: f64) -> f64 {
    unsafe { ffi::gsl_sf_gegenpoly_1(lambda, x) }
}

/// This function evaluates the Gegenbauer polynomials C^{(\lambda)}_n(x) using explicit representations for n =1, 2, 3.
pub fn gegenpoly_2(lambda: f64, x: f64) -> f64 {
    unsafe { ffi::gsl_sf_gegenpoly_2(lambda, x) }
}

/// This function evaluates the Gegenbauer polynomials C^{(\lambda)}_n(x) using explicit representations for n =1, 2, 3.
pub fn gegenpoly_3(lambda: f64, x: f64) -> f64 {
    unsafe { ffi::gsl_sf_gegenpoly_3(lambda, x) }
}

/// This function evaluates the Gegenbauer polynomials C^{(\lambda)}_n(x) using explicit representations for n =1, 2, 3.
pub fn gegenpoly_1_e(lambda: f64, x: f64) -> (enums::Value, ::types::Result) {
    let mut result = unsafe { zeroed::<ffi::gsl_sf_result>() };
    let ret = unsafe { ffi::gsl_sf_gegenpoly_1_e(lambda, x, &mut result) };

    (enums::Value::from(ret), ::types::Result{val: result.val, err: result.err})
}

/// This function evaluates the Gegenbauer polynomials C^{(\lambda)}_n(x) using explicit representations for n =1, 2, 3.
pub fn gegenpoly_2_e(lambda: f64, x: f64) -> (enums::Value, ::types::Result) {
    let mut result = unsafe { zeroed::<ffi::gsl_sf_result>() };
    let ret = unsafe { ffi::gsl_sf_gegenpoly_2_e(lambda, x, &mut result) };

    (enums::Value::from(ret), ::types::Result{val: result.val, err: result.err})
}

/// This function evaluates the Gegenbauer polynomials C^{(\lambda)}_n(x) using explicit representations for n =1, 2, 3.
pub fn gegenpoly_3_e(lambda: f64, x: f64) -> (enums::Value, ::types::Result) {
    let mut result = unsafe { zeroed::<ffi::gsl_sf_result>() };
    let ret = unsafe { ffi::gsl_sf_gegenpoly_3_e(lambda, x, &mut result) };

    (enums::Value::from(ret), ::types::Result{val: result.val, err: result.err})
}

/// This function evaluates the Gegenbauer polynomial C^{(\lambda)}_n(x) for a specific value of n, lambda, x subject to \lambda > -1/2, n >= 0.
pub fn gegenpoly_n(n: i32, lambda: f64, x: f64) -> f64 {
    unsafe { ffi::gsl_sf_gegenpoly_n(n, lambda, x) }
}

/// This function evaluates the Gegenbauer polynomial C^{(\lambda)}_n(x) for a specific value of n, lambda, x subject to \lambda > -1/2, n >= 0.
pub fn gegenpoly_n_e(n: i32, lambda: f64, x: f64) -> (enums::Value, ::types::Result) {
    let mut result = unsafe { zeroed::<ffi::gsl_sf_result>() };
    let ret = unsafe { ffi::gsl_sf_gegenpoly_n_e(n, lambda, x, &mut result) };

    (enums::Value::from(ret), ::types::Result{val: result.val, err: result.err})
}

/// This function computes an array of Gegenbauer polynomials C^{(\lambda)}_n(x) for n = 0, 1, 2, \dots, nmax, subject to \lambda > -1/2, nmax >= 0.
pub fn gegenpoly_array(lambda: f64, x: f64, result_array: &mut [f64]) -> enums::Value {
    enums::Value::from(unsafe {
        ffi::gsl_sf_gegenpoly_array(result_array.len() as _, lambda, x, result_array.as_mut_ptr())
    })
}