public static double UnnormalisedNeedlemanWunchSimilarity(string source, string target) { double GapCost = DefaultGapCost; //? Correct???? //AbstractSubstitutionCost DCostFunction; if (source == null || target == null) { return(0.0D); } int length = source.Length; int index = target.Length; if (length == 0) { return(index); } if (index == 0) { return(length); } double[][] numArray = new double[length + 1][]; for (int i = 0; i < length + 1; i++) { numArray[i] = new double[index + 1]; } for (int j = 0; j <= length; j++) { numArray[j][0] = j; } for (int k = 0; k <= index; k++) { numArray[0][k] = k; } for (int m = 1; m <= length; m++) { for (int n = 1; n <= index; n++) { double num8 = Get01Cost(source, m - 1, target, n - 1); numArray[m][n] = MathFunctions.MinOf3(numArray[m - 1][n] + GapCost, numArray[m][n - 1] + GapCost, numArray[m - 1][n - 1] + num8); } } return(numArray[length][index]); }
private static int GetPrefixLength(string source, string target) { if (source == null || target == null) { return(MinPrefixTestLength); } int num = MathFunctions.MinOf3(MinPrefixTestLength, source.Length, target.Length); for (int i = 0; i < num; i++) { if (source[i] != target[i]) { return(i); } } return(num); }