use num::complex::Complex;
use crate::cln::CLn;
pub trait Li1<T> {
fn li1(&self) -> T;
}
impl Li1<f64> for f64 {
fn li1(&self) -> f64 {
let x = *self;
if x < 1.0 {
-(-x).ln_1p()
} else if x == 1.0 {
std::f64::INFINITY
} else { -(x - 1.0).ln()
}
}
}
impl Li1<Complex<f64>> for Complex<f64> {
fn li1(&self) -> Complex<f64> {
if *self == Complex::new(0.0, 0.0) {
*self
} else {
-(1.0 - self).cln()
}
}
}