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
//
// A rust binding for the GSL library by Guillaume Gomez (guillaume1.gomez@gmail.com)
//

/*!
The Clausen function is defined by the following integral,

Cl_2(x) = - \int_0^x dt \log(2 \sin(t/2))

It is related to the dilogarithm by Cl_2(\theta) = \Im Li_2(\exp(i\theta)). 
!*/

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

/// This routine computes the Clausen integral Cl_2(x).
pub fn clausen(x: f64) -> f64 {
    unsafe { ffi::gsl_sf_clausen(x) }
}

/// This routine computes the Clausen integral Cl_2(x).
pub fn clausen_e(x: f64) -> (enums::Value, ::types::Result) {
    let mut result = unsafe { zeroed::<ffi::gsl_sf_result>() };
    let ret = unsafe { ffi::gsl_sf_clausen_e(x, &mut result) };

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