copy-paste assignment 2~5

This commit is contained in:
AnHaechan
2023-08-19 16:52:42 +00:00
parent 3ef3cae0cd
commit 5caaac6c42
15 changed files with 763 additions and 87 deletions

View File

@@ -149,6 +149,48 @@ mod test {
assert_eq!(fibonacci(92), 12200160415121876738);
}
// Equivalence between two floating-point matrices, as element-wise equivalence
use std::cmp::PartialEq;
impl PartialEq for FMat2 {
fn eq(&self, other: &FMat2) -> bool {
self.a == other.a && self.b == other.b && self.c == other.c && self.d == other.d
}
}
#[test]
fn test_inverse() {
assert_eq!(
FMat2 {
a: 1.0,
b: 1.0,
c: 2.0,
d: 3.0
}
.inverse(),
FMat2 {
a: 3.0,
b: -1.0,
c: -2.0,
d: 1.0
}
);
assert_eq!(
FMat2 {
a: 2.0,
b: 3.0,
c: 5.0,
d: 7.0
}
.inverse(),
FMat2 {
a: -7.0,
b: 3.0,
c: 5.0,
d: -2.0
}
);
}
#[test]
fn test_lyrics() {
assert_eq!(twelve_days_of_christmas_lyrics(), LYRICS)