Axect / Peroxide

Rust numeric library with R, MATLAB & Python syntax
https://crates.io/crates/peroxide
Apache License 2.0
509 stars 31 forks source link

Length bug in `linspace` #51

Closed Axect closed 2 years ago

Axect commented 2 years ago

If end - start is too small, then linspace may not guarantee the length of output. For example, below code generates error.

use peroxide::fuga::*;

fn main() {
    let x = linspace(435482956799564540_f64, 435482956800000000, 101);
    assert_eq!(x.len(), 101);
}

This error is caused from seq - seq does not guarantee the length. Thus, linspace should not depend on implementation of seq.