rgsl/
clausen.rs

1//
2// A rust binding for the GSL library by Guillaume Gomez (guillaume1.gomez@gmail.com)
3//
4
5/*!
6The Clausen function is defined by the following integral,
7
8Cl_2(x) = - \int_0^x dt \log(2 \sin(t/2))
9
10It is related to the dilogarithm by Cl_2(\theta) = \Im Li_2(\exp(i\theta)).
11!*/
12
13use crate::{types, Value};
14use std::mem::MaybeUninit;
15
16/// This routine computes the Clausen integral Cl_2(x).
17#[doc(alias = "gsl_sf_clausen")]
18pub fn clausen(x: f64) -> f64 {
19    unsafe { sys::gsl_sf_clausen(x) }
20}
21
22/// This routine computes the Clausen integral Cl_2(x).
23#[doc(alias = "gsl_sf_clausen_e")]
24pub fn clausen_e(x: f64) -> Result<types::Result, Value> {
25    let mut result = MaybeUninit::<sys::gsl_sf_result>::uninit();
26    let ret = unsafe { sys::gsl_sf_clausen_e(x, result.as_mut_ptr()) };
27
28    result_handler!(ret, unsafe { result.assume_init() }.into())
29}