Function
linspace
(start: f64, end: f64, n: usize)
Source from the content-addressed store, hash-verified
| 447 | } |
| 448 | |
| 449 | fn linspace(start: f64, end: f64, n: usize) -> Vec<f64> { |
| 450 | if n == 0 { |
| 451 | return vec![]; |
| 452 | } |
| 453 | if n == 1 { |
| 454 | return vec![start]; |
| 455 | } |
| 456 | let step = (end - start) / (n as f64 - 1.0); |
| 457 | (0..n).map(|i| start + step * i as f64).collect() |
| 458 | } |
| 459 | |
| 460 | pub fn sigma_mapping(array: &[f64], step: f64) -> Result<Vec<(f64, char)>, String> { |
| 461 | if step <= 0.0 { |
Tested by
no test coverage detected