Skip to content

Repository files navigation

Github CICrates.iodocs.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.

Install

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

rhai-sci = "0.2.3"

Usage

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 engineletmut engine = Engine::new();// Add the rhai-sci package to the new engine
engine.register_global_module(SciPackage::new().as_shared_module());// Now run your codelet value = engine.eval::<INT>("argmin([43, 42, -500])").unwrap();

Features

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

About

Scientific computing for Rhai.

Topics

Resources

Stars

20 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages