MCPcopy Create free account
hub / github.com/Axect/Peroxide / row_map

Method row_map

src/complex/matrix.rs:1687–1703  ·  view source on GitHub ↗

Row map # Example ```rust use peroxide::fuga::*; use peroxide::complex::matrix::*; use peroxide::traits::fp::FPMatrix; let x = cmatrix(vec![C64::new(1f64, 1f64), C64::new(2f64, 2f64), C64::new(3f64, 3f64), C64::new(4f64, 4f64)], 2, 2, Row ); let y = x.row_map(|r| r.fmap(|t| t + r[0])); let y_row_map = cmatrix(vec![C64::new(2f64, 2f64), C64::new(3f64, 3f64), C64::new(6f64, 6f64), C64::new(7f64,

(&self, f: F)

Source from the content-addressed store, hash-verified

1685 /// assert_eq!(y, y_row_map);
1686 /// ```
1687 fn row_map<F>(&self, f: F) -> ComplexMatrix
1688 where
1689 F: Fn(Vec<C64>) -> Vec<C64>,
1690 {
1691 let mut result = cmatrix(
1692 vec![Complex::zero(); self.row * self.col],
1693 self.row,
1694 self.col,
1695 Shape::Row,
1696 );
1697
1698 for i in 0..self.row {
1699 result.subs_row(i, &f(self.row(i)));
1700 }
1701
1702 result
1703 }
1704
1705 fn col_mut_map<F>(&mut self, f: F)
1706 where

Callers 1

test_row_mapFunction · 0.45

Calls 4

cmatrixFunction · 0.85
fFunction · 0.50
subs_rowMethod · 0.45
rowMethod · 0.45

Tested by 1

test_row_mapFunction · 0.36