Skip to main content

KernelScalar

Trait KernelScalar 

Source
pub trait KernelScalar: Scalar {
    // Required methods
    fn linear_kernel(
        layout: Layout,
        m: usize,
        n: usize,
        k: usize,
        x: &[Self],
        ldx: usize,
        y: Option<&[Self]>,
        ldy: usize,
        d: &mut [Self],
        ldd: usize,
    ) -> Result<()>;
    fn rbf_kernel(
        layout: Layout,
        m: usize,
        n: usize,
        k: usize,
        x: &[Self],
        ldx: usize,
        y: Option<&[Self]>,
        ldy: usize,
        d: &mut [Self],
        ldd: usize,
        gamma: Self,
    ) -> Result<()>;
    fn polynomial_kernel(
        layout: Layout,
        m: usize,
        n: usize,
        k: usize,
        x: &[Self],
        ldx: usize,
        y: Option<&[Self]>,
        ldy: usize,
        d: &mut [Self],
        ldd: usize,
        gamma: Self,
        degree: i64,
        coef0: Self,
    ) -> Result<()>;
    fn sigmoid_kernel(
        layout: Layout,
        m: usize,
        n: usize,
        k: usize,
        x: &[Self],
        ldx: usize,
        y: Option<&[Self]>,
        ldy: usize,
        d: &mut [Self],
        ldd: usize,
        gamma: Self,
        coef0: Self,
    ) -> Result<()>;
}
Expand description

Scalar element type for kernel-matrix computations.

Required Methods§

Source

fn linear_kernel( layout: Layout, m: usize, n: usize, k: usize, x: &[Self], ldx: usize, y: Option<&[Self]>, ldy: usize, d: &mut [Self], ldd: usize, ) -> Result<()>

Linear kernel: K(x, y) = x · y.

Source

fn rbf_kernel( layout: Layout, m: usize, n: usize, k: usize, x: &[Self], ldx: usize, y: Option<&[Self]>, ldy: usize, d: &mut [Self], ldd: usize, gamma: Self, ) -> Result<()>

RBF (Gaussian) kernel: K(x, y) = exp(-γ · ‖x − y‖²).

Source

fn polynomial_kernel( layout: Layout, m: usize, n: usize, k: usize, x: &[Self], ldx: usize, y: Option<&[Self]>, ldy: usize, d: &mut [Self], ldd: usize, gamma: Self, degree: i64, coef0: Self, ) -> Result<()>

Polynomial kernel: K(x, y) = (γ · x · y + c)^degree.

Source

fn sigmoid_kernel( layout: Layout, m: usize, n: usize, k: usize, x: &[Self], ldx: usize, y: Option<&[Self]>, ldy: usize, d: &mut [Self], ldd: usize, gamma: Self, coef0: Self, ) -> Result<()>

Sigmoid kernel: K(x, y) = tanh(γ · x · y + c).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl KernelScalar for f32

Source§

fn linear_kernel( layout: Layout, m: usize, n: usize, k: usize, x: &[Self], ldx: usize, y: Option<&[Self]>, ldy: usize, d: &mut [Self], ldd: usize, ) -> Result<()>

Source§

fn rbf_kernel( layout: Layout, m: usize, n: usize, k: usize, x: &[Self], ldx: usize, y: Option<&[Self]>, ldy: usize, d: &mut [Self], ldd: usize, gamma: Self, ) -> Result<()>

Source§

fn polynomial_kernel( layout: Layout, m: usize, n: usize, k: usize, x: &[Self], ldx: usize, y: Option<&[Self]>, ldy: usize, d: &mut [Self], ldd: usize, gamma: Self, degree: i64, coef0: Self, ) -> Result<()>

Source§

fn sigmoid_kernel( layout: Layout, m: usize, n: usize, k: usize, x: &[Self], ldx: usize, y: Option<&[Self]>, ldy: usize, d: &mut [Self], ldd: usize, gamma: Self, coef0: Self, ) -> Result<()>

Source§

impl KernelScalar for f64

Source§

fn linear_kernel( layout: Layout, m: usize, n: usize, k: usize, x: &[Self], ldx: usize, y: Option<&[Self]>, ldy: usize, d: &mut [Self], ldd: usize, ) -> Result<()>

Source§

fn rbf_kernel( layout: Layout, m: usize, n: usize, k: usize, x: &[Self], ldx: usize, y: Option<&[Self]>, ldy: usize, d: &mut [Self], ldd: usize, gamma: Self, ) -> Result<()>

Source§

fn polynomial_kernel( layout: Layout, m: usize, n: usize, k: usize, x: &[Self], ldx: usize, y: Option<&[Self]>, ldy: usize, d: &mut [Self], ldd: usize, gamma: Self, degree: i64, coef0: Self, ) -> Result<()>

Source§

fn sigmoid_kernel( layout: Layout, m: usize, n: usize, k: usize, x: &[Self], ldx: usize, y: Option<&[Self]>, ldy: usize, d: &mut [Self], ldd: usize, gamma: Self, coef0: Self, ) -> Result<()>

Implementors§