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 :
Input | Output | Description |
---|---|---|
Vec<f64> | f64 | A 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> | f64 | A 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§
Required Methods§
Sourcefn to_dmatrix(m: &Self) -> DMatrix<f64>
fn to_dmatrix(m: &Self) -> DMatrix<f64>
Converts an input matrix to a DMatrix.
Sourcefn to_dvector(v: &Self::InVector) -> DVector<f64>
fn to_dvector(v: &Self::InVector) -> DVector<f64>
Converts an input vector to a DVector.
Sourcefn from_dvector(v: &DVector<f64>) -> Self::OutVector
fn from_dvector(v: &DVector<f64>) -> Self::OutVector
Converts a DVector to an output vector.
Provided Methods§
Sourcefn into_dmatrix(m: Self) -> DMatrix<f64>
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.
Sourcefn into_dvector(v: Self::InVector) -> DVector<f64>
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.
impl Input for Vec<f64>
Single row.
Source§impl Input for Vec<Vec<f64>>
Multiple rows, base rust type.
impl Input for Vec<Vec<f64>>
Multiple rows, base rust type.
Source§impl Input for DMatrix<f64>
Direct implementation.
impl Input for DMatrix<f64>
Direct implementation.
Source§fn to_dmatrix(m: &Self) -> DMatrix<f64>
fn to_dmatrix(m: &Self) -> DMatrix<f64>
Converts an input matrix to a DMatrix.
Source§fn into_dmatrix(m: Self) -> DMatrix<f64>
fn into_dmatrix(m: Self) -> DMatrix<f64>
Converts an input matrix to a DMatrix.