#array #tensor

ndcopy

Fast N-dimensional array memcpy

3 releases (breaking)

0.3.0 Apr 17, 2022
0.2.0 Oct 28, 2021
0.1.0 Sep 28, 2021

#1724 in Data structures

Download history 80/week @ 2023-02-05 56/week @ 2023-02-12 112/week @ 2023-02-19 85/week @ 2023-02-26 108/week @ 2023-03-05 85/week @ 2023-03-12 59/week @ 2023-03-19 62/week @ 2023-03-26 48/week @ 2023-04-02 97/week @ 2023-04-09 87/week @ 2023-04-16 68/week @ 2023-04-23 115/week @ 2023-04-30 98/week @ 2023-05-07 52/week @ 2023-05-14 122/week @ 2023-05-21

392 downloads per month
Used in 2 crates

MIT/Apache

14KB
329 lines

ndcopy

Fast N-dimensional array memcpy.

Speed is achieved by copying slices row-by-row. Rust code is much faster at copying slices than trying to index N-dimensional coordinates for every value index.

Example Code

use ndcopy::ndshape::{ConstShape, ConstShape3u32};
use ndcopy::copy3;

type SrcShape = ConstShape3u32<50, 50, 50>;
type DstShape = ConstShape3u32<25, 25, 25>;
let src = [1u8; SrcShape::USIZE];
let mut dst = [0u8; DstShape::USIZE];

let copy_shape = [20; 3];
let src_min = [1, 2, 3];
let dst_min = [2, 3, 4];
copy3(
    copy_shape,
    &src,
    &SrcShape {},
    src_min,
    &mut dst,
    &DstShape {},
    dst_min,
);

License: MIT OR Apache-2.0


lib.rs:

Fast N-dimensional array memcpy.

Speed is achieved by copying slices row-by-row. Rust code is much faster at copying slices than trying to index N-dimensional coordinates for every value index.

Example Code

use ndcopy::ndshape::{ConstShape, ConstShape3u32};
use ndcopy::copy3;

type SrcShape = ConstShape3u32<50, 50, 50>;
type DstShape = ConstShape3u32<25, 25, 25>;
let src = [1u8; SrcShape::USIZE];
let mut dst = [0u8; DstShape::USIZE];

let copy_shape = [20; 3];
let src_min = [1, 2, 3];
let dst_min = [2, 3, 4];
copy3(
    copy_shape,
    &src,
    &SrcShape {},
    src_min,
    &mut dst,
    &DstShape {},
    dst_min,
);

Dependencies

~73KB