diff --git a/README.md b/README.md index d44e91c..18643f2 100644 --- a/README.md +++ b/README.md @@ -53,35 +53,37 @@ let dates: Vec = .list() .unwrap(); - let col_names: Vec = vec!["a".to_string(), "b".to_string()]; +let col_names: Vec = vec!["a".to_string(), "b".to_string()]; - let ma: Matrix = Matrix::from_cols(vec![vec![1.0, 2.0, 3.0, 4.0], vec![5.0, 6.0, 7.0, 8.0]]); - let mb: Matrix = Matrix::from_cols(vec![vec![4.0, 3.0, 2.0, 1.0], vec![8.0, 7.0, 6.0, 5.0]]); +let ma: Matrix = + Matrix::from_cols(vec![vec![1.0, 2.0, 3.0, 4.0], vec![5.0, 6.0, 7.0, 8.0]]); +let mb: Matrix = + Matrix::from_cols(vec![vec![4.0, 3.0, 2.0, 1.0], vec![8.0, 7.0, 6.0, 5.0]]); - let fa: Frame = Frame::new( - ma.clone(), - col_names.clone(), - Some(RowIndex::Date(dates.clone())), - ); - let fb: Frame = Frame::new(mb, col_names, Some(RowIndex::Date(dates))); +let fa: Frame = Frame::new( + ma.clone(), + Some(col_names.clone()), + Some(RowIndex::Date(dates.clone())), +); +let fb: Frame = Frame::new(mb, Some(col_names), Some(RowIndex::Date(dates))); - // Math that reads like math - let result: Frame = &fa * &fb; // element‑wise multiply - let total: f64 = result.sum_vertical().iter().sum::(); - assert_eq!(total, 184.0); +// Math that reads like math +let result: Frame = &fa * &fb; // element‑wise multiply +let total: f64 = result.sum_vertical().iter().sum::(); +assert_eq!(total, 184.0); - // broadcast & reduce - let result: Matrix = &ma + 1.0; // add scalar - let result: Matrix = &result - 1.0; // subtract scalar - let result: Matrix = &result * 2.0; // multiply by scalar - let result: Matrix = &result / 2.0; // divide by scalar +// broadcast & reduce +let result: Matrix = &ma + 1.0; // add scalar +let result: Matrix = &result - 1.0; // subtract scalar +let result: Matrix = &result * 2.0; // multiply by scalar +let result: Matrix = &result / 2.0; // divide by scalar - let check: bool = result.eq_elementwise(ma.clone()).all(); - assert!(check); +let check: bool = result.eq_elementwise(ma.clone()).all(); +assert!(check); - // The above math can also be written as: - let check: bool = (&(&(&(&ma + 1.0) - 1.0) * 2.0) / 2.0) - .eq_elementwise(ma) - .all(); - assert!(check); +// The above math can also be written as: +let check: bool = (&(&(&(&ma + 1.0) - 1.0) * 2.0) / 2.0) + .eq_elementwise(ma) + .all(); +assert!(check); ```