Trait peroxide::traits::fp::FPMatrix[][src]

pub trait FPMatrix {
Show methods fn take_row(&self, n: usize) -> Matrix;
fn take_col(&self, n: usize) -> Matrix;
fn skip_row(&self, n: usize) -> Matrix;
fn skip_col(&self, n: usize) -> Matrix;
fn fmap<F>(&self, f: F) -> Matrix
    where
        F: Fn(f64) -> f64
;
fn col_map<F>(&self, f: F) -> Matrix
    where
        F: Fn(Vec<f64>) -> Vec<f64>
;
fn row_map<F>(&self, f: F) -> Matrix
    where
        F: Fn(Vec<f64>) -> Vec<f64>
;
fn col_mut_map<F>(&mut self, f: F)
    where
        F: Fn(Vec<f64>) -> Vec<f64>
;
fn row_mut_map<F>(&mut self, f: F)
    where
        F: Fn(Vec<f64>) -> Vec<f64>
;
fn reduce<F, T>(&self, init: T, f: F) -> f64
    where
        F: Fn(f64, f64) -> f64,
        T: Into<f64>
;
fn zip_with<F>(&self, f: F, other: &Matrix) -> Matrix
    where
        F: Fn(f64, f64) -> f64
;
fn col_reduce<F>(&self, f: F) -> Vec<f64>
    where
        F: Fn(Vec<f64>) -> f64
;
fn row_reduce<F>(&self, f: F) -> Vec<f64>
    where
        F: Fn(Vec<f64>) -> f64
;
}
Expand description

Functional Programming for Matrix

Required methods

fn take_row(&self, n: usize) -> Matrix[src]

fn take_col(&self, n: usize) -> Matrix[src]

fn skip_row(&self, n: usize) -> Matrix[src]

fn skip_col(&self, n: usize) -> Matrix[src]

fn fmap<F>(&self, f: F) -> Matrix where
    F: Fn(f64) -> f64
[src]

fn col_map<F>(&self, f: F) -> Matrix where
    F: Fn(Vec<f64>) -> Vec<f64>, 
[src]

fn row_map<F>(&self, f: F) -> Matrix where
    F: Fn(Vec<f64>) -> Vec<f64>, 
[src]

fn col_mut_map<F>(&mut self, f: F) where
    F: Fn(Vec<f64>) -> Vec<f64>, 
[src]

fn row_mut_map<F>(&mut self, f: F) where
    F: Fn(Vec<f64>) -> Vec<f64>, 
[src]

fn reduce<F, T>(&self, init: T, f: F) -> f64 where
    F: Fn(f64, f64) -> f64,
    T: Into<f64>, 
[src]

fn zip_with<F>(&self, f: F, other: &Matrix) -> Matrix where
    F: Fn(f64, f64) -> f64
[src]

fn col_reduce<F>(&self, f: F) -> Vec<f64> where
    F: Fn(Vec<f64>) -> f64
[src]

fn row_reduce<F>(&self, f: F) -> Vec<f64> where
    F: Fn(Vec<f64>) -> f64
[src]

Implementors

impl FPMatrix for Matrix[src]

fn col_map<F>(&self, f: F) -> Matrix where
    F: Fn(Vec<f64>) -> Vec<f64>, 
[src]

Column map

Example

use peroxide::fuga::*;

fn main() {
    let x = ml_matrix("1 2;3 4;5 6");
    let y = x.col_map(|c| c.fmap(|t| t - c.mean()));

    assert_eq!(y, ml_matrix("-2 -2;0 0;2 2"));
}

fn row_map<F>(&self, f: F) -> Matrix where
    F: Fn(Vec<f64>) -> Vec<f64>, 
[src]

Row map

Example

use peroxide::fuga::*;

fn main() {
    let x = ml_matrix("1 2 3;4 5 6");
    let y = x.row_map(|r| r.fmap(|t| t - r.mean()));

    assert_eq!(y, ml_matrix("-1 0 1;-1 0 1"));
}

fn take_row(&self, n: usize) -> Self[src]

fn take_col(&self, n: usize) -> Self[src]

fn skip_row(&self, n: usize) -> Self[src]

fn skip_col(&self, n: usize) -> Self[src]

fn fmap<F>(&self, f: F) -> Matrix where
    F: Fn(f64) -> f64
[src]

fn col_mut_map<F>(&mut self, f: F) where
    F: Fn(Vec<f64>) -> Vec<f64>, 
[src]

fn row_mut_map<F>(&mut self, f: F) where
    F: Fn(Vec<f64>) -> Vec<f64>, 
[src]

fn reduce<F, T>(&self, init: T, f: F) -> f64 where
    F: Fn(f64, f64) -> f64,
    T: Into<f64>, 
[src]

fn zip_with<F>(&self, f: F, other: &Matrix) -> Self where
    F: Fn(f64, f64) -> f64
[src]

fn col_reduce<F>(&self, f: F) -> Vec<f64> where
    F: Fn(Vec<f64>) -> f64
[src]

fn row_reduce<F>(&self, f: F) -> Vec<f64> where
    F: Fn(Vec<f64>) -> f64
[src]