pub fn generate2d(
    xmin: f64,
    xmax: f64,
    ymin: f64,
    ymax: f64,
    nx: usize,
    ny: usize
) -> (Matrix, Matrix)
Expand description

Generates 2d points (meshgrid)

Input

  • xmin, xmax – range along x
  • ymin, ymax – range along y
  • nx – is the number of points along x (must be >= 2)
  • ny – is the number of points along y (must be >= 2)

Output

  • x, y – (ny by nx) matrices

Example

use russell_lab::generate2d;
let (nx, ny) = (5, 3);
let (x, y) = generate2d(-1.0, 1.0, -2.0, 2.0, nx, ny);
assert_eq!(
    format!("{}", x),
    "┌                          ┐\n\
     │   -1 -0.5    0  0.5    1 │\n\
     │   -1 -0.5    0  0.5    1 │\n\
     │   -1 -0.5    0  0.5    1 │\n\
     └                          ┘"
);
assert_eq!(
    format!("{}", y),
    "┌                ┐\n\
     │ -2 -2 -2 -2 -2 │\n\
     │  0  0  0  0  0 │\n\
     │  2  2  2  2  2 │\n\
     └                ┘"
);