Crates.io | jlrs-ndarray |
lib.rs | jlrs-ndarray |
version | 0.3.0 |
source | src |
created_at | 2020-10-10 15:22:05.778126 |
updated_at | 2021-03-25 17:20:28.694715 |
description | jlrs 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. |
homepage | https://github.com/Taaitaaiger/jlrs |
repository | https://github.com/Taaitaaiger/jlrs |
max_upload_size | |
id | 298049 |
size | 13,860 |
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();
}