From 9b1ad8d769d6528b259176a717c7add8ac804d08 Mon Sep 17 00:00:00 2001 From: tarolling Date: Mon, 9 Dec 2024 14:15:49 -0500 Subject: [PATCH] ADD: add default signature for linspace macro --- src/macros/matlab_macro.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/macros/matlab_macro.rs b/src/macros/matlab_macro.rs index d91ea9b2..f8087edd 100644 --- a/src/macros/matlab_macro.rs +++ b/src/macros/matlab_macro.rs @@ -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) + }}; }