Skip to main content

runmat_runtime/
arrays.rs

1//! Array generation functions
2//!
3//! This module provides array generation functions like linspace, logspace,
4//! zeros, ones, eye, etc. These functions are optimized for performance and memory efficiency.
5
6use crate::RuntimeError;
7use runmat_builtins::Value;
8
9/// Create a range vector (equivalent to start:end or start:step:end)
10pub async fn create_range(start: f64, step: Option<f64>, end: f64) -> Result<Value, RuntimeError> {
11    // Delegate to new builtins to ensure unified semantics
12    match step {
13        Some(s) => {
14            crate::call_builtin_async(
15                "colon",
16                &[Value::Num(start), Value::Num(s), Value::Num(end)],
17            )
18            .await
19        }
20        None => crate::call_builtin_async("colon", &[Value::Num(start), Value::Num(end)]).await,
21    }
22}