Trait ToNdarray2

Source
pub trait ToNdarray2 {
    type Out;

    // Required method
    fn into_ndarray2(self) -> Self::Out;
}
Expand description

Converts 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.

Required Associated Types§

Required Methods§

Source

fn into_ndarray2(self) -> Self::Out

Implementations on Foreign Types§

Source§

impl<'a, N: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> ToNdarray2 for Matrix<N, R, C, ViewStorage<'a, N, R, C, RStride, CStride>>

use nalgebra::Matrix4;
use nshare::ToNdarray2;

let 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.row(1).into_ndarray2();
assert!(arr.iter().eq(&[0.5, 0.6, 0.7, 0.8]));
assert_eq!(arr.dim(), (1, 4));
Source§

impl<'a, N: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> ToNdarray2 for Matrix<N, R, C, ViewStorageMut<'a, N, R, C, RStride, CStride>>

use nalgebra::Matrix4;
use nshare::ToNdarray2;

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.row_mut(1).into_ndarray2().fill(0.0);
assert!(m.row(1).iter().eq(&[0.0; 4]));

Implementors§