Trait peroxide::traits::sugar::Scalable

source ·
pub trait Scalable {
    type Vec;

    // Required methods
    fn reshape(&self, size: (usize, usize), shape: Shape) -> Matrix;
    fn add_col(&self, v: &Self::Vec) -> Matrix;
    fn add_row(&self, v: &Self::Vec) -> Matrix;
}

Required Associated Types§

Required Methods§

source

fn reshape(&self, size: (usize, usize), shape: Shape) -> Matrix

source

fn add_col(&self, v: &Self::Vec) -> Matrix

source

fn add_row(&self, v: &Self::Vec) -> Matrix

Implementations on Foreign Types§

source§

impl Scalable for Vec<f64>

source§

fn reshape(&self, (r, c): (usize, usize), shape: Shape) -> Matrix

Vector to Matrix

#[macro_use]
extern crate peroxide;
use peroxide::fuga::*;

fn main() {
    let a = c!(1,2,3,4,5,6);
    let b1 = a.reshape((3,2), Row);
    let b2 = a.reshape((3,2), Col);
    assert_eq!(b1, ml_matrix("1 2;3 4;5 6"));
    assert_eq!(b2, ml_matrix("1 4;2 5;3 6"));
}
source§

fn add_col(&self, v: &Self::Vec) -> Matrix

Vector + Vector = Matrix

#[macro_use]
extern crate peroxide;
use peroxide::fuga::*;

fn main() {
    let a = c!(1,2,3);
    let b = c!(4,5,6);
    let c1 = a.add_row(&b);
    let c2 = a.add_col(&b);
    assert_eq!(c1, ml_matrix("1 2 3;4 5 6"));
    assert_eq!(c2, ml_matrix("1 4;2 5;3 6"));
}
source§

fn add_row(&self, v: &Self::Vec) -> Matrix

Vector + Vector = Matrix

#[macro_use]
extern crate peroxide;
use peroxide::fuga::*;

fn main() {
    let a = c!(1,2,3);
    let b = c!(4,5,6);
    let c1 = a.add_row(&b);
    let c2 = a.add_col(&b);
    assert_eq!(c1, ml_matrix("1 2 3;4 5 6"));
    assert_eq!(c2, ml_matrix("1 4;2 5;3 6"));
}
source§

type Vec = Vec<f64>

Implementors§

source§

impl Scalable for Matrix

Modify Matrix