meshgridrs

Crates.iomeshgridrs
lib.rsmeshgridrs
version0.1.1
sourcesrc
created_at2024-02-02 20:47:01.161057
updated_at2024-02-02 20:54:41.46569
descriptionPartial implementation of numpy's meshgrid function for ndarray.
homepage
repositoryhttps://github.com/jreniel/meshgridrs
max_upload_size
id1124716
size4,888
Jaime R Calzada (jreniel)

documentation

README

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

Commit count: 0

cargo fmt