Skip to main content

diric

Function diric 

Source
pub fn diric(x: f64, n: usize) -> f64
Expand description

The Dirichlet (periodic sinc) function of MATLAB, $\operatorname{diric}(x, n) = \frac{\sin(n x/2)}{n \sin(x/2)}$, of period $2\pi$ ($4\pi$) for odd (even) $n$, with its limits $(-1)^{k(n-1)}$ at $x = 2\pi k$; $\sin(n\theta)/\sin\theta = n \operatorname{diric}(2\theta, n)$ is the array factor of $n$ equally spaced terms.

§Examples

use comnum_math::diric;
assert_eq!(diric(0.0, 8), 1.0);
assert_eq!(diric(2.0 * std::f64::consts::PI, 8), -1.0);
let x = 0.3;
assert!((diric(x, 5) - (2.5 * x).sin() / (5.0 * (0.5 * x).sin())).abs() < 1e-15);