jlrs-ndarray

Crates.iojlrs-ndarray
lib.rsjlrs-ndarray
version0.3.0
sourcesrc
created_at2020-10-10 15:22:05.778126
updated_at2021-03-25 17:20:28.694715
descriptionjlrs is a library built around bindings to the Julia C API that enables Julia code to be called from Rust. jlrs can move many kinds of data from Rust to Julia and back, share n-dimensional numerical arrays between languages, call arbitrary functions, and load code from arbitrary Julia source files. jlrs currently supports Linux and Windows.
homepagehttps://github.com/Taaitaaiger/jlrs
repositoryhttps://github.com/Taaitaaiger/jlrs
max_upload_size
id298049
size13,860
Thomas van Doornmalen (Taaitaaiger)

documentation

https://docs.rs/jlrs-ndarray

README

Borrow data from Julia arrays as ndarray's ArrayView and ArrayViewMut.

This crate defines a single trait, NdArray, that provides methods that return an immutable or a mutable view of the array data and is implemented by Array and TypedArray from jlrs.

Example:

use jlrs::prelude::*;
use jlrs_ndarray::NdArray;

fn main() {
    let mut julia = unsafe { Julia::init(16).unwrap() };
    julia.dynamic_frame(|_global, frame| {
        let mut data = vec![1usize, 2, 3, 4, 5, 6];
        let slice = &mut data.as_mut_slice();
        let borrowed = Value::borrow_array(frame, slice, (3, 2))?;

        let _array = borrowed.cast::<TypedArray<usize>>()?.array_view(frame)?;

        Ok(())
    }).unwrap();
}
Commit count: 670

cargo fmt