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 runmat_builtins::Value;
7
8/// Create a range vector (equivalent to start:end or start:step:end)
9pub fn create_range(start: f64, step: Option<f64>, end: f64) -> Result<Value, String> {
10 // Delegate to new builtins to ensure unified semantics
11 match step {
12 Some(s) => crate::call_builtin(
13 "colon",
14 &[Value::Num(start), Value::Num(s), Value::Num(end)],
15 ),
16 None => crate::call_builtin("colon", &[Value::Num(start), Value::Num(end)]),
17 }
18}