Trait orkhon::prelude::ops::nn::tract_ndarray::AsArray[][src]

pub trait AsArray<'a, A, D = Dim<[usize; 1]>>: Into<ArrayBase<ViewRepr<&'a A>, D>> where
    A: 'a,
    D: Dimension
{ }

Argument conversion into an array view

The trait is parameterized over A, the element type, and D, the dimensionality of the array. D defaults to one-dimensional.

Use .into() to do the conversion.

use ndarray::AsArray;

fn sum<'a, V: AsArray<'a, f64>>(data: V) -> f64 {
    let array_view = data.into();
    array_view.sum()
}

assert_eq!(
    sum(&[1., 2., 3.]),
    6.
);

Implementors

impl<'a, A, D, T> AsArray<'a, A, D> for T where
    T: Into<ArrayBase<ViewRepr<&'a A>, D>>,
    A: 'a,
    D: Dimension
[src]

Loading content...