Fixed transpose by moving to an iterative method

This commit is contained in:
Jon Janzen
2021-03-31 15:30:08 -06:00
parent 588acf36a3
commit 82360600fe

View File

@@ -32,13 +32,13 @@ impl<const COUNT: usize> Matrix<COUNT> {
} }
pub fn transpose(&mut self) { pub fn transpose(&mut self) {
let tmp = [ for i in 0..self.matrix.len() {
[self.matrix[0][0], self.matrix[1][0], self.matrix[2][0], self.matrix[3][0], ], for j in i..self.matrix[0].len() {
[self.matrix[0][1], self.matrix[1][1], self.matrix[2][1], self.matrix[3][1], ], let v = self.matrix[i][j];
[self.matrix[0][2], self.matrix[1][2], self.matrix[2][2], self.matrix[3][2], ], self.matrix[i][j] = self.matrix[j][i];
[self.matrix[0][3], self.matrix[1][3], self.matrix[2][3], self.matrix[3][3], ], self.matrix[j][i] = v;
]; }
// self.matrix = tmp; }
} }
pub fn determinant(&self) -> f32 { pub fn determinant(&self) -> f32 {