Trait IntoNdarray1

Source
pub trait IntoNdarray1 {
    type Out;

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

Converts a 1d type to a ndarray 1d array type.

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_ndarray1(self) -> Self::Out

Implementations on Foreign Types§

Source§

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

use nshare::IntoNdarray1;
use nalgebra::{Vector4, dimension::U2, Const};

let mut m = Vector4::new(
    0.1, 0.2, 0.3, 0.4,
);
let arr = m.rows_generic_with_step_mut::<Const<2>>(0, Const::<2>, 1).into_ndarray1().fill(0.0);
assert!(m.iter().eq(&[0.0, 0.2, 0.0, 0.4]));
Source§

impl<'a, N: Scalar, R: Dim, RStride: Dim, CStride: Dim> IntoNdarray1 for Vector<N, R, ViewStorage<'a, N, R, U1, RStride, CStride>>

use nshare::IntoNdarray1;
use nalgebra::Vector4;

let m = Vector4::new(
    0.1, 0.2, 0.3, 0.4f32,
);
let arr = m.rows(0, 4).into_ndarray1();
assert!(arr.iter().eq(&[0.1, 0.2, 0.3, 0.4]));
assert_eq!(arr.dim(), 4);
Source§

impl<N: Scalar> IntoNdarray1 for DVector<N>

use nshare::IntoNdarray1;
use nalgebra::DVector;
use ndarray::s;

let m = DVector::from_vec(vec![
    0.1, 0.2, 0.3, 0.4,
]);
let arr = m.into_ndarray1();
assert_eq!(arr.dim(), 4);
assert!(arr.iter().eq(&[0.1, 0.2, 0.3, 0.4]));

Implementors§