Trait Input

Source
pub trait Input: Sized {
    type InVector: Sized;
    type OutVector;

    // Required methods
    fn to_dmatrix(m: &Self) -> DMatrix<f64>;
    fn to_dvector(v: &Self::InVector) -> DVector<f64>;
    fn from_dvector(v: &DVector<f64>) -> Self::OutVector;

    // Provided methods
    fn into_dmatrix(m: Self) -> DMatrix<f64> { ... }
    fn into_dvector(v: Self::InVector) -> DVector<f64> { ... }
}
Expand description

Implemented by Input -> Output type pairs

Handles conversion to DMatrix type and stores information on associated output type. Most methods of this library can currently work with the following input -> output pairs :

InputOutputDescription
Vec<f64>f64A single, multidimensional, sample.
Vec<Vec<f64>>Vec<f64>Each inner vector is a training sample.
DMatrix<f64>DVector<f64>Using a nalgebra matrix with one row per sample.
Array1<f64>f64A single sample stored in a ndarray array (using the friedrich_ndarray feature).
Array2<f64>Array1<f64>Each row is a sample (using the friedrich_ndarray feature).

User-defined input type should implement this trait.

Required Associated Types§

Source

type InVector: Sized

Type of the vectors storing training output data and given to methods.

Source

type OutVector

Type of the vectors output when a method is called.

Required Methods§

Source

fn to_dmatrix(m: &Self) -> DMatrix<f64>

Converts an input matrix to a DMatrix.

Source

fn to_dvector(v: &Self::InVector) -> DVector<f64>

Converts an input vector to a DVector.

Source

fn from_dvector(v: &DVector<f64>) -> Self::OutVector

Converts a DVector to an output vector.

Provided Methods§

Source

fn into_dmatrix(m: Self) -> DMatrix<f64>

Optional: converts an owned input matrix to a DMatrix. This function is used for to reduce copies when the input type is compatible with DMatrix.

Source

fn into_dvector(v: Self::InVector) -> DVector<f64>

Optional: converts an owned input vector to a DVector. This function is used for to reduce copies when the input type is compatible with DVector.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Input for Vec<f64>

Single row.

Source§

fn to_dmatrix(m: &Self) -> DMatrix<f64>

Converts an input matrix to a DMatrix.

Source§

fn to_dvector(v: &Self::InVector) -> DVector<f64>

Converts an input vector to a DVector.

Source§

fn from_dvector(v: &DVector<f64>) -> Self::OutVector

Converts a DVector to an output vector.

Source§

type InVector = f64

Source§

type OutVector = f64

Source§

impl Input for Vec<Vec<f64>>

Multiple rows, base rust type.

Source§

fn to_dmatrix(m: &Self) -> DMatrix<f64>

Converts an input matrix to a DMatrix.

Source§

fn to_dvector(v: &Self::InVector) -> DVector<f64>

Converts an input vector to a DVector.

Source§

fn from_dvector(v: &DVector<f64>) -> Self::OutVector

Converts a DVector to an output vector.

Source§

type InVector = Vec<f64>

Source§

type OutVector = Vec<f64>

Source§

impl Input for DMatrix<f64>

Direct implementation.

Source§

fn to_dmatrix(m: &Self) -> DMatrix<f64>

Converts an input matrix to a DMatrix.

Source§

fn to_dvector(v: &Self::InVector) -> DVector<f64>

Converts an input vector to a DVector.

Source§

fn into_dmatrix(m: Self) -> DMatrix<f64>

Converts an input matrix to a DMatrix.

Source§

fn into_dvector(v: Self::InVector) -> DVector<f64>

Converts an input vector to a DVector.

Source§

fn from_dvector(v: &DVector<f64>) -> Self::OutVector

Converts a DVector to an output vector.

Source§

type InVector = Matrix<f64, Dynamic, Const<1>, VecStorage<f64, Dynamic, Const<1>>>

Source§

type OutVector = Matrix<f64, Dynamic, Const<1>, VecStorage<f64, Dynamic, Const<1>>>

Implementors§