-
-
Save lancegatlin/3269d3955d92fd324790 to your computer and use it in GitHub Desktop.
asdf
This file contains hidden or 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
// note: more efficient way to store matrix is a class that uses internal Buffer[Double] of size row * columns | |
//submatrix determination for calculating determinants of matrices | |
def submatrix[A](i : Int, j : Int, matrix : Array[Array[A]]) = { | |
//returns a new array of size n-1 with the ith index removed | |
def remove[A](index : Int, arr: Seq[A]): Seq[A] = { | |
// Note: removing the ith index from a sequence is considered highly inefficient and to be avoided whenever possible | |
arr.take(index) ++ arr.drop(index+1) | |
} | |
// remove row first | |
remove(i, matrix).map { case row => remove(j, row) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment