Created
September 18, 2014 22:22
-
-
Save ghidalgo3/3f07af1b6a4f33162857 to your computer and use it in GitHub Desktop.
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
//submatrix determination for calculating determinants of matrices | |
def submatrix(i : Int, j : Int, matrix : Array[Array]) = { | |
//returns a new array of size n-1 with the ith index removed | |
def removeIndex(index : Int, arr: Array): Array = { | |
arr | |
.zipWithIndex //what you call if you need an indexed loop | |
.filter{ case (_,index) => index != r } | |
.map { case (value, _) => value } | |
} | |
removeIndex(i , matrix.map{ case row => removeIndex(j, row) } ) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment