Crates.io | meshgridrs |
lib.rs | meshgridrs |
version | 0.1.1 |
source | src |
created_at | 2024-02-02 20:47:01.161057 |
updated_at | 2024-02-02 20:54:41.46569 |
description | Partial implementation of numpy's meshgrid function for ndarray. |
homepage | |
repository | https://github.com/jreniel/meshgridrs |
max_upload_size | |
id | 1124716 |
size | 4,888 |
Currently, ndarray doesn't have a built-in meshgrid method.
There exists a meshgrid crate, but it only works with i32 types.
This is a meshgrid function that should work over generic types and in n-dimensions.
My hope is that eventually ndarray incorporates this, or it's own particular version.
use ndarray::Array;
use meshgridrs::{meshgrid, Indexing};
fn main() {
// Example with 3D.
let x = Array::linspace(0.0, 1.0, 3);
let y = Array::linspace(0.0, 1.0, 2);
let z = Array::linspace(0.0, 1.0, 2);
let xi = vec![x, y, z];
let grids = meshgrid(&xi, Indexing::Xy).unwrap();
for (i, grid) in grids.iter().enumerate() {
println!("Grid {}:\n{:?}", i, grid);
};
}
SPDX-License-Identifier: LicenseRef-MIT