update sparse maxwell benches

This commit is contained in:
2020-09-21 16:38:52 +02:00
parent 939eae9af1
commit 3593ee2f52
2 changed files with 28 additions and 7 deletions

View File

@@ -21,6 +21,18 @@ pub struct Metrics {
}
impl Grid {
pub fn new_linspace(
x: std::ops::Range<Float>,
nx: usize,
y: std::ops::Range<Float>,
ny: usize,
) -> Self {
let dx = (x.end - x.start) / (nx - 1) as Float;
let dy = (y.end - y.start) / (ny - 1) as Float;
let x = Array2::from_shape_fn((ny, nx), |(_j, i)| i as Float * dx + x.start);
let y = Array2::from_shape_fn((ny, nx), |(j, _i)| j as Float * dy + y.start);
Self { x, y }
}
pub fn new(x: Array2<Float>, y: Array2<Float>) -> Result<Self, ndarray::ShapeError> {
assert_eq!(x.shape(), y.shape());