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
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
//
// A rust binding for the GSL library by Guillaume Gomez (guillaume1.gomez@gmail.com)
//

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

/// This routine computes the exponential integral E_1(x),
/// 
/// E_1(x) := \Re \int_1^\infty dt \exp(-xt)/t.
pub fn E1(x: f64) -> f64 {
    unsafe { ffi::gsl_sf_expint_E1(x) }
}

/// This routine computes the exponential integral E_1(x),
/// 
/// E_1(x) := \Re \int_1^\infty dt \exp(-xt)/t.
pub fn E1_e(x: f64) -> (enums::Value, ::types::Result) {
    let mut result = unsafe { zeroed::<ffi::gsl_sf_result>() };
    let ret = unsafe { ffi::gsl_sf_expint_E1_e(x, &mut result) };

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

/// This routine computes the second-order exponential integral E_2(x),
/// 
/// E_2(x) := \Re \int_1^\infty dt \exp(-xt)/t^2.
pub fn E2(x: f64) -> f64 {
    unsafe { ffi::gsl_sf_expint_E2(x) }
}

/// This routine computes the second-order exponential integral E_2(x),
/// 
/// E_2(x) := \Re \int_1^\infty dt \exp(-xt)/t^2.
pub fn E2_e(x: f64) -> (enums::Value, ::types::Result) {
    let mut result = unsafe { zeroed::<ffi::gsl_sf_result>() };
    let ret = unsafe { ffi::gsl_sf_expint_E2_e(x, &mut result) };

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

/// This routine computes the exponential integral E_n(x) of order n,
/// 
/// E_n(x) := \Re \int_1^\infty dt \exp(-xt)/t^n.
pub fn En(n: i32, x: f64) -> f64 {
    unsafe { ffi::gsl_sf_expint_En(n, x) }
}

/// This routine computes the exponential integral E_n(x) of order n,
/// 
/// E_n(x) := \Re \int_1^\infty dt \exp(-xt)/t^n.
pub fn En_e(n: i32, x: f64) -> (enums::Value, ::types::Result) {
    let mut result = unsafe { zeroed::<ffi::gsl_sf_result>() };
    let ret = unsafe { ffi::gsl_sf_expint_En_e(n, x, &mut result) };

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

/// This routine computes the exponential integral Ei(x),
/// 
/// Ei(x) := - PV(\int_{-x}^\infty dt \exp(-t)/t)
/// 
/// where PV denotes the principal value of the integral.
pub fn Ei(x: f64) -> f64 {
    unsafe { ffi::gsl_sf_expint_Ei(x) }
}

/// This routine computes the exponential integral Ei(x),
/// 
/// Ei(x) := - PV(\int_{-x}^\infty dt \exp(-t)/t)
/// 
/// where PV denotes the principal value of the integral.
pub fn Ei_e(x: f64) -> (enums::Value, ::types::Result) {
    let mut result = unsafe { zeroed::<ffi::gsl_sf_result>() };
    let ret = unsafe { ffi::gsl_sf_expint_Ei_e(x, &mut result) };

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

/// This routine computes the integral Shi(x) = \int_0^x dt \sinh(t)/t.
pub fn Shi(x: f64) -> f64 {
    unsafe { ffi::gsl_sf_Shi(x) }
}

/// This routine computes the integral Shi(x) = \int_0^x dt \sinh(t)/t.
pub fn Shi_e(x: f64) -> (enums::Value, ::types::Result) {
    let mut result = unsafe { zeroed::<ffi::gsl_sf_result>() };
    let ret = unsafe { ffi::gsl_sf_Shi_e(x, &mut result) };

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

/// This routine computes the integral Chi(x) := \Re[ \gamma_E + \log(x) + \int_0^x dt (\cosh(t)-1)/t] , where \gamma_E is the Euler constant (available as the macro M_EULER).
pub fn Chi(x: f64) -> f64 {
    unsafe { ffi::gsl_sf_Chi(x) }
}

/// This routine computes the integral Chi(x) := \Re[ \gamma_E + \log(x) + \int_0^x dt (\cosh(t)-1)/t] , where \gamma_E is the Euler constant (available as the macro M_EULER).
pub fn Chi_e(x: f64) -> (enums::Value, ::types::Result) {
    let mut result = unsafe { zeroed::<ffi::gsl_sf_result>() };
    let ret = unsafe { ffi::gsl_sf_Chi_e(x, &mut result) };

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

/// This routine computes the third-order exponential integral Ei_3(x) = \int_0^xdt \exp(-t^3) for x >= 0.
pub fn _3(x: f64) -> f64 {
    unsafe { ffi::gsl_sf_expint_3(x) }
}

/// This routine computes the third-order exponential integral Ei_3(x) = \int_0^xdt \exp(-t^3) for x >= 0.
pub fn _3_e(x: f64) -> (enums::Value, ::types::Result) {
    let mut result = unsafe { zeroed::<ffi::gsl_sf_result>() };
    let ret = unsafe { ffi::gsl_sf_expint_3_e(x, &mut result) };

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

/// This routine computes the Sine integral Si(x) = \int_0^x dt \sin(t)/t.
pub fn Si(x: f64) -> f64 {
    unsafe { ffi::gsl_sf_Si(x) }
}

/// This routine computes the Sine integral Si(x) = \int_0^x dt \sin(t)/t.
pub fn Si_e(x: f64) -> (enums::Value, ::types::Result) {
    let mut result = unsafe { zeroed::<ffi::gsl_sf_result>() };
    let ret = unsafe { ffi::gsl_sf_Si_e(x, &mut result) };

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

/// This routine computes the Cosine integral Ci(x) = -\int_x^\infty dt \cos(t)/t for x > 0.
pub fn Ci(x: f64) -> f64 {
    unsafe { ffi::gsl_sf_Ci(x) }
}

/// This routine computes the Cosine integral Ci(x) = -\int_x^\infty dt \cos(t)/t for x > 0.
pub fn Ci_e(x: f64) -> (enums::Value, ::types::Result) {
    let mut result = unsafe { zeroed::<ffi::gsl_sf_result>() };
    let ret = unsafe { ffi::gsl_sf_Ci_e(x, &mut result) };

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

/// This routine computes the Arctangent integral, which is defined as AtanInt(x) = \int_0^x dt \arctan(t)/t.
pub fn atanint(x: f64) -> f64 {
    unsafe { ffi::gsl_sf_atanint(x) }
}

/// This routine computes the Arctangent integral, which is defined as AtanInt(x) = \int_0^x dt \arctan(t)/t.
pub fn atanint_e(x: f64) -> (enums::Value, ::types::Result) {
    let mut result = unsafe { zeroed::<ffi::gsl_sf_result>() };
    let ret = unsafe { ffi::gsl_sf_atanint_e(x, &mut result) };

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