mirror of
https://github.com/kmc7468/cs220.git
synced 2025-12-17 07:28:45 +00:00
copy-paste assignment 2~5
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user