[][src]Trait nshare::MutNdarray2

pub trait MutNdarray2 {
    type Out;
    pub fn mut_ndarray2(self) -> Self::Out;
}

Mutably borrows a 2d type to a ndarray 2d array type.

Coordinates are in (row, col).

This uses an associated type to avoid ambiguity for the compiler. By calling this, the compiler always knows the returned type.

Associated Types

Loading content...

Required methods

pub fn mut_ndarray2(self) -> Self::Out[src]

Loading content...

Implementations on Foreign Types

impl<'a, A, Container> MutNdarray2 for &'a mut ImageBuffer<Luma<A>, Container> where
    A: Primitive + 'static,
    Container: DerefMut<Target = [A]>, 
[src]

use image::{GrayImage, Luma};
use nshare::MutNdarray2;
use ndarray::s;

let mut vals = GrayImage::new(2, 4);
let mut nd = vals.mut_ndarray2();
assert_eq!(nd.dim(), (4, 2));
nd.slice_mut(s![0, ..]).fill(255);
assert_eq!(vals[(1, 0)], Luma([255]));

type Out = ArrayViewMut2<'a, A>

impl<'a, N: Scalar, R: Dim, C: Dim, S> MutNdarray2 for &'a mut Matrix<N, R, C, S> where
    S: StorageMut<N, R, C>, 
[src]

use nshare::MutNdarray2;
use nalgebra::Matrix4;
use ndarray::s;

let mut m = Matrix4::new(
    0.1, 0.2, 0.3, 0.4,
    0.5, 0.6, 0.7, 0.8,
    1.1, 1.2, 1.3, 1.4,
    1.5, 1.6, 1.7, 1.8,
);
let arr = m.mut_ndarray2().slice_mut(s![1, ..]).fill(0.0);
assert!(m.row(1).iter().eq(&[0.0; 4]));

type Out = ArrayViewMut2<'a, N>

Loading content...

Implementors

Loading content...