Skip to content

Commit

Permalink
fix Linspace
Browse files Browse the repository at this point in the history
  • Loading branch information
NamorNiradnug committed May 31, 2024
1 parent 3965b7e commit 72f6ea7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ pub trait Linspace {
impl Linspace for Range<f32> {
#[allow(refining_impl_trait)]
fn linspace(&self, n: usize) -> impl Iterator<Item = f32> {
(0..=(n - 1)).map(move |i| self.start + (self.end - self.start) * (i as f32) / (n as f32))
(0..n).map(move |i| self.start + (self.end - self.start) * (i as f32) / ((n - 1) as f32))
}
}

impl Linspace for Range<f64> {
#[allow(refining_impl_trait)]
fn linspace(&self, n: usize) -> impl Iterator<Item = f64> {
(0..=(n - 1)).map(move |i| self.start + (self.end - self.start) * (i as f64) / (n as f64))
(0..n).map(move |i| self.start + (self.end - self.start) * (i as f64) / ((n - 1) as f64))
}
}

Expand Down

0 comments on commit 72f6ea7

Please sign in to comment.