2 releases
0.1.1 | Feb 2, 2024 |
---|---|
0.1.0 | Feb 2, 2024 |
#1359 in Math
Used in inpoly
4KB
meshgridrs
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
Dependencies
~2MB
~35K SLoC