Skip to content

Commit

Permalink
Merge pull request #85 from tarolling/features/linspace
Browse files Browse the repository at this point in the history
ADD: add default signature for linspace macro
  • Loading branch information
Axect authored Dec 12, 2024
2 parents a5fadc1 + 9b1ad8d commit e67d035
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/macros/matlab_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,25 @@ macro_rules! eye {
/// assert_eq!(a, seq!(1,10,1));
/// }
/// ```
/// ```
/// #[macro_use]
/// extern crate peroxide;
/// use peroxide::fuga::*;
///
/// fn main() {
/// let a = linspace!(10, 1000);
/// assert_eq!(a, seq!(10,1000,10));
/// }
/// ```
#[macro_export]
macro_rules! linspace {
( $start:expr, $end:expr, $length: expr) => {{
let step = ($end - $start) as f64 / ($length as f64 - 1f64);
seq!($start, $end, step)
}};

( $start:expr, $end:expr ) => {{
let step = ($end - $start) as f64 / (99f64);
seq!($start, $end, step)
}};
}

0 comments on commit e67d035

Please sign in to comment.