Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rhaiscript/rhai-sci
Scientific computing for Rhai.
https://github.com/rhaiscript/rhai-sci
lib rhai rhai-sci scripting-language
Last synced: 9 days ago
JSON representation
Scientific computing for Rhai.
- Host: GitHub
- URL: https://github.com/rhaiscript/rhai-sci
- Owner: rhaiscript
- License: apache-2.0
- Created: 2022-07-07T14:22:29.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-11-24T15:54:23.000Z (about 1 year ago)
- Last Synced: 2024-12-01T02:12:33.937Z (about 1 month ago)
- Topics: lib, rhai, rhai-sci, scripting-language
- Language: Rust
- Homepage: https://crates.io/crates/rhai-sci
- Size: 341 KB
- Stars: 15
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE.txt
Awesome Lists containing this project
README
[![Github CI](https://github.com/rhaiscript/rhai-sci/actions/workflows/tests.yml/badge.svg)](https://github.com/rhaiscript/rhai-sci/actions)
[![Crates.io](https://img.shields.io/crates/v/rhai-sci.svg)](https://crates.io/crates/rhai-sci)
[![docs.rs](https://img.shields.io/docsrs/rhai-sci/latest?logo=rust)](https://docs.rs/rhai-sci)# About `rhai-sci`
This crate provides some basic scientific computing utilities for the [`Rhai`](https://rhai.rs/) scripting language, inspired by languages
like MATLAB, Octave, and R. For a complete API reference, check [the docs](https://docs.rs/rhai-sci).# Install
To use the latest released version of `rhai-sci`, add this to your `Cargo.toml`:
```toml
rhai-sci = "0.2.1"
```To use the bleeding edge instead, add this:
```toml
rhai-sci = { git = "https://github.com/cmccomb/rhai-sci" }
```# Usage
Using this crate is pretty simple! If you just want to evaluate a single line of [`Rhai`](https://rhai.rs/), then you only need:
```rust
use rhai::INT;
use rhai_sci::eval;
let result = eval::("argmin([43, 42, -500])").unwrap();
```If you need to use `rhai-sci` as part of a persistent [`Rhai`](https://rhai.rs/) scripting engine, then do this instead:
```rust
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
engine.register_global_module(SciPackage::new().as_shared_module());// Now run your code
let value = engine.eval::("argmin([43, 42, -500])").unwrap();
```# Features
| 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`](#read_matrixfile_path-string---array) function but pulls in several additional dependencies (`polars`, `url`, `temp-file`, `csv-sniffer`, `minreq`). |
| `nalgebra` | Enabled | Enables several functions ([`regress`](#regressx-array-y-array---map), [`inv`](#invmatrix-array---array), [`mtimes`](#mtimesmatrix1-array-matrix2-array---array), [`horzcat`](#horzcatmatrix1-array-matrix2-array---array), [`vertcat`](#vertcatmatrix1-array-matrix2-array---array), [`repmat`](#repmatmatrix-array-nx-i64-ny-i64---array), [`svd`](#svdmatrix-array---map), [`hessenberg`](#hessenbergmatrix-array---map), and [`qr`](#qrmatrix-array---map)) but brings in the `nalgebra` and `linregress` crates. |
| `rand` | Enabled | Enables the [`rand`](#rand) function for generating random FLOAT values and random matrices, but brings in the `rand` crate. |