mirror of
https://github.com/Magnus167/rustframe.git
synced 2025-08-20 22:40:00 +00:00
Compare commits
No commits in common. "25a2a0d831344bbee8c46a4aadde471a025864b9" and "34cff9f05ee37babff757a12d227d41cc7db06c8" have entirely different histories.
25a2a0d831
...
34cff9f05e
1
.gitignore
vendored
1
.gitignore
vendored
@ -12,6 +12,5 @@ data/
|
|||||||
*.info
|
*.info
|
||||||
|
|
||||||
.venv/
|
.venv/
|
||||||
.vscode/
|
|
||||||
|
|
||||||
tarpaulin-report.*
|
tarpaulin-report.*
|
21
README.md
21
README.md
@ -76,26 +76,17 @@ let total: f64 = result.sum_vertical().iter().sum::<f64>();
|
|||||||
assert_eq!(total, 184.0);
|
assert_eq!(total, 184.0);
|
||||||
|
|
||||||
// broadcast & reduce
|
// broadcast & reduce
|
||||||
let result: Matrix<f64> = ma.clone() + 1.0; // add scalar
|
let result: Matrix<f64> = &ma + 1.0; // add scalar
|
||||||
let result: Matrix<f64> = result + &ma - &ma; // add matrix
|
let result: Matrix<f64> = &result - 1.0; // subtract scalar
|
||||||
let result: Matrix<f64> = result - 1.0; // subtract scalar
|
let result: Matrix<f64> = &result * 2.0; // multiply by scalar
|
||||||
let result: Matrix<f64> = result * 2.0; // multiply by scalar
|
let result: Matrix<f64> = &result / 2.0; // divide by scalar
|
||||||
let result: Matrix<f64> = result / 2.0; // divide by scalar
|
|
||||||
|
|
||||||
let check: bool = result.eq_elem(ma.clone()).all();
|
let check: bool = result.eq_elementwise(ma.clone()).all();
|
||||||
assert!(check);
|
assert!(check);
|
||||||
|
|
||||||
// The above math can also be written as:
|
// The above math can also be written as:
|
||||||
let check: bool = (&(&(&(&ma + 1.0) - 1.0) * 2.0) / 2.0)
|
let check: bool = (&(&(&(&ma + 1.0) - 1.0) * 2.0) / 2.0)
|
||||||
.eq_elem(ma.clone())
|
.eq_elementwise(ma)
|
||||||
.all();
|
.all();
|
||||||
assert!(check);
|
assert!(check);
|
||||||
|
|
||||||
// The above math can also be written as:
|
|
||||||
let check: bool = ((((ma.clone() + 1.0) - 1.0) * 2.0) / 2.0)
|
|
||||||
.eq_elem(ma)
|
|
||||||
.all();
|
|
||||||
assert!(check);
|
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user