pub trait Scalable {
    type Vec;

    fn resize(&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

Implementations on Foreign Types

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.resize((3,2), Row);
    let b2 = a.resize((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"));
}

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"));
}

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"));
}

Implementors

Modify Matrix