#scripting #rhai #scientific #scripting-language #matlab


Scientific computing in the Rhai scripting language

7 releases

0.2.0 May 14, 2023
0.1.9 Feb 18, 2023
0.1.7 Aug 5, 2022
0.1.6 Jul 17, 2022

#106 in Science

Download history 46/week @ 2023-02-03 57/week @ 2023-02-10 78/week @ 2023-02-17 27/week @ 2023-02-24 26/week @ 2023-03-03 20/week @ 2023-03-10 7/week @ 2023-03-17 9/week @ 2023-03-24 22/week @ 2023-03-31 12/week @ 2023-04-07 15/week @ 2023-04-14 1/week @ 2023-04-21 11/week @ 2023-04-28 26/week @ 2023-05-05 28/week @ 2023-05-12 10/week @ 2023-05-19

75 downloads per month
Used in sculpt



Github CI Crates.io docs.rs

About rhai-sci

This crate provides some basic scientific computing utilities for the Rhai scripting language, inspired by languages like MATLAB, Octave, and R. For a complete API reference, check the docs.


To use the latest released version of rhai-sci, add this to your Cargo.toml:

rhai-sci = "0.2.0"

To use the bleeding edge instead, add this:

rhai-sci = { git = "https://github.com/cmccomb/rhai-sci" }


Using this crate is pretty simple! If you just want to evaluate a single line of Rhai, then you only need:

use rhai::INT;
use rhai_sci::eval;
let result = eval::<INT>("argmin([43, 42, -500])").unwrap();

If you need to use rhai-sci as part of a persistent Rhai scripting engine, then do this instead:

use rhai::{Engine, packages::Package, INT};
use rhai_sci::SciPackage;

// Create a new Rhai engine
let mut engine = Engine::new();

// Add the rhai-sci package to the new engine

// Now run your code
let value = engine.eval::<INT>("argmin([43, 42, -500])").unwrap();


Feature Default Description
metadata Disabled Enables exporting function metadata and is necessary for running doc-tests on Rhai examples.
io Enabled Enables the read_matrix function but pulls in several additional dependencies (polars, url, temp-file, csv-sniffer, minreq).
nalgebra Enabled Enables several functions (regress, inv, mtimes, horzcat, vertcat, repmat, svd, hessenberg, and qr) but brings in the nalgebra and linregress crates.
rand Enabled Enables the rand function for generating random FLOAT values and random matrices, but brings in the rand crate.


~225K SLoC