Created
February 27, 2012 09:38
-
-
Save archie/1922816 to your computer and use it in GitHub Desktop.
Signature Matrix Creation
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
def createSignatureMatrix(characterMatrix: Array[Array[Int]], hashFunctions: List[HashFunction]): Array[Array[Int]] = { | |
val signatureMatrix: Array[Array[Int]] = createEmptySignatureMatrix(hashFunctions.length, characterMatrix(0).length) | |
characterMatrix.zipWithIndex.foreach { case (row, i) => | |
row.zipWithIndex.foreach { case (character, j) => | |
/* only apply hash functions if character is not 0 */ | |
if (character == 1) { | |
hashFunctions.zipWithIndex.foreach { case (hasher, k) => | |
val hashedRowValue: Int = hasher.apply(i) | |
if (isReplaceable(signatureMatrix(k)(j), hashedRowValue)) { | |
signatureMatrix(k)(j) = hashedRowValue | |
} | |
} | |
} | |
} | |
} | |
signatureMatrix | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment