Created
November 13, 2016 20:23
-
-
Save felipecruz/44d9d0d5b7b44835b2f30311bfd17211 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func MatrixLUDecomposition(matrix Matrix) Matrix { | |
columns := matrix.cols() | |
rows := matrix.rows() | |
for i := 0; i < columns-1; i++ { | |
val, pivot_index := PivotIndex(matrix, i, i) | |
MatrixExchangeRows(matrix, i, pivot_index) | |
for j := i + 1; j < rows; j++ { | |
multiplier := -matrix.at(j, i) / val | |
MatrixScaleAndSumRows(matrix, i, j, multiplier) | |
matrix.set(j, i, -(multiplier)) | |
} | |
} | |
return matrix | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment