Skip to content

Commit 6750af9

Browse files
committed
Ver 0.30.8
2 parents 4269db8 + 05d79c3 commit 6750af9

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "peroxide"
3-
version = "0.30.7"
3+
version = "0.30.8"
44
authors = ["axect <[email protected]>"]
55
edition = "2018"
66
description = "Rust comprehensive scientific computation library contains linear algebra, numerical analysis, statistics and machine learning tools with farmiliar syntax"

RELEASES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Release 0.30.8 (2021-05-21)
2+
3+
* Fix errata in `col_map`, `row_map`
4+
15
# Release 0.30.7 (2021-05-14)
26

37
* Change signature of `cubic_spline`

src/structure/matrix.rs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2627,26 +2627,52 @@ impl FPMatrix for Matrix {
26272627
matrix(result, self.row, self.col, self.shape)
26282628
}
26292629

2630+
/// Column map
2631+
///
2632+
/// # Example
2633+
/// ```rust
2634+
/// use peroxide::fuga::*;
2635+
///
2636+
/// fn main() {
2637+
/// let x = ml_matrix("1 2;3 4;5 6");
2638+
/// let y = x.col_map(|c| c.fmap(|t| t - c.mean()));
2639+
///
2640+
/// assert_eq!(y, ml_matrix("-2 -2;0 0;2 2"));
2641+
/// }
2642+
/// ```
26302643
fn col_map<F>(&self, f: F) -> Matrix
26312644
where
26322645
F: Fn(Vec<f64>) -> Vec<f64>,
26332646
{
26342647
let mut result = matrix(vec![0f64; self.row * self.col], self.row, self.col, Col);
26352648

2636-
for i in 0..self.row {
2649+
for i in 0..self.col {
26372650
result.subs_col(i, &f(self.col(i)));
26382651
}
26392652

26402653
result
26412654
}
26422655

2656+
/// Row map
2657+
///
2658+
/// # Example
2659+
/// ```rust
2660+
/// use peroxide::fuga::*;
2661+
///
2662+
/// fn main() {
2663+
/// let x = ml_matrix("1 2 3;4 5 6");
2664+
/// let y = x.row_map(|r| r.fmap(|t| t - r.mean()));
2665+
///
2666+
/// assert_eq!(y, ml_matrix("-1 0 1;-1 0 1"));
2667+
/// }
2668+
/// ```
26432669
fn row_map<F>(&self, f: F) -> Matrix
26442670
where
26452671
F: Fn(Vec<f64>) -> Vec<f64>,
26462672
{
26472673
let mut result = matrix(vec![0f64; self.row * self.col], self.row, self.col, Row);
26482674

2649-
for i in 0..self.col {
2675+
for i in 0..self.row {
26502676
result.subs_row(i, &f(self.row(i)));
26512677
}
26522678

0 commit comments

Comments
 (0)