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;
}
Associated Types
Required methods
Implementations on Foreign Types
sourceimpl Scalable for Vec<f64>
impl Scalable for Vec<f64>
sourcefn resize(&self, (r, c): (usize, usize), shape: Shape) -> Matrix
fn resize(&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.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"));
}
sourcefn add_row(&self, v: &Self::Vec) -> Matrix
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"));
}
sourcefn add_col(&self, v: &Self::Vec) -> Matrix
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"));
}