[−][src]Trait peroxide::traits::sugar::Scalable
Associated Types
type Vec
Required methods
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
Implementations on Foreign Types
impl Scalable for Vec<f64>
[src]
type Vec = Self
fn resize(&self, (r, c): (usize, usize), shape: Shape) -> Matrix
[src]
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")); }
fn add_row(&self, v: &Self::Vec) -> Matrix
[src]
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")); }
fn add_col(&self, v: &Self::Vec) -> Matrix
[src]
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
impl Scalable for Matrix
[src]
Modify Matrix
type Vec = Vec<f64>
fn resize(&self, (r, c): (usize, usize), shape: Shape) -> Matrix
[src]
Resize matrix
#[macro_use] extern crate peroxide; use peroxide::fuga::*; fn main() { let a = ml_matrix("1 2 3;4 5 6"); // ml_matrix has shape `Col` 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")); }
fn add_row(&self, v: &Self::Vec) -> Matrix
[src]
Add row
#[macro_use] extern crate peroxide; use peroxide::fuga::*; fn main() { let a = ml_matrix("1 2 3;4 5 6"); let b = c!(7,8,9); let c = a.add_row(&b); assert_eq!(c, ml_matrix("1 2 3;4 5 6;7 8 9")); }
fn add_col(&self, v: &Self::Vec) -> Matrix
[src]
Add column
#[macro_use] extern crate peroxide; use peroxide::fuga::*; fn main() { let a = ml_matrix("1 2 3;4 5 6"); let b = c!(7,8); let c = a.add_col(&b); assert_eq!(c, ml_matrix("1 2 3 7;4 5 6 8")); }