peroxide/numerical/interp.rs
1#[allow(unused_imports)]
2use crate::structure::polynomial::*;
3
4use std::convert::Into;
5use std::f64::consts::PI;
6
7pub fn chebyshev_nodes<T>(num: usize, start: T, end: T) -> Vec<f64>
8where
9 T: Into<f64> + Copy,
10{
11 let mut v = vec![0f64; num];
12 let a = start.into();
13 let b = end.into();
14 for i in 0..num {
15 v[i] = (a + b) / 2. + 0.5 * (b - a) * ((2 * i + 1) as f64 * PI / (2 * num) as f64).cos();
16 }
17 return v;
18}