File: views.rs

package info (click to toggle)
rust-ndarray 0.16.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,028 kB
  • sloc: sh: 30; makefile: 2
file content (17 lines) | stat: -rw-r--r-- 336 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use ndarray::prelude::*;
use ndarray::Zip;

#[test]
fn cell_view()
{
    let mut a = Array::from_shape_fn((10, 5), |(i, j)| (i * j) as f32);
    let answer = &a + 1.;

    {
        let cv1 = a.cell_view();
        let cv2 = cv1;

        Zip::from(cv1).and(cv2).for_each(|a, b| a.set(b.get() + 1.));
    }
    assert_eq!(a, answer);
}