Skip to content

Commit c840f0f

Browse files
committed
[fix] warnings inside math.
1 parent 51ee208 commit c840f0f

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

crates/lambda-rs/src/math/matrix.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ pub fn rotate_matrix<
150150
}
151151
};
152152

153-
for i in 0..rows {
154-
for j in 0..columns {
155-
rotation_matrix.update(i, j, rotation[i][j]);
153+
for (i, row) in rotation.iter().enumerate().take(rows) {
154+
for (j, value) in row.iter().enumerate().take(columns) {
155+
rotation_matrix.update(i, j, *value);
156156
}
157157
}
158158

@@ -355,9 +355,8 @@ where
355355
}
356356
submatrix.push(row);
357357
}
358-
result += self.at(0, i)
359-
* submatrix.determinant()
360-
* (-1.0 as f32).powi(i as i32);
358+
result +=
359+
self.at(0, i) * submatrix.determinant() * (-1.0_f32).powi(i as i32);
361360
}
362361
result
363362
}
@@ -374,7 +373,6 @@ where
374373
return &self.as_ref()[row];
375374
}
376375

377-
///
378376
fn at(&self, row: usize, column: usize) -> <V as Vector>::Scalar {
379377
return self.as_ref()[row].as_ref()[column];
380378
}
@@ -450,7 +448,7 @@ mod tests {
450448
fn non_square_matrix_determinant() {
451449
let m = [[3.0, 8.0], [4.0, 6.0], [0.0, 1.0]];
452450
let result = std::panic::catch_unwind(|| m.determinant());
453-
assert_eq!(false, result.is_ok());
451+
assert!(result.is_err());
454452
}
455453

456454
#[test]

crates/lambda-rs/src/math/vector.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,13 @@ mod tests {
200200
#[test]
201201
fn length() {
202202
let a = [1.0, 2.0, 3.0];
203-
let b = 3.7416573867739413;
203+
let b = 3.741_657_5;
204204

205205
let result = a.length();
206206
assert_eq!(result, b);
207207

208208
let c = [1.0, 2.0, 3.0, 4.0];
209-
let d = 5.477225575051661;
209+
let d = 5.477_226;
210210
let result = c.length();
211211
assert_eq!(result, d);
212212
}

0 commit comments

Comments
 (0)