private static bool doesMatch(SlowBitvector deductionString, SlowBitvector candidateBitvector, int insertionIndex) { if (insertionIndex + candidateBitvector.vector.Count <= deductionString.vector.Count) { return(false); } int overlapEndIndex = Math.Min(deductionString.vector.Count, insertionIndex + candidateBitvector.vector.Count); int overlapLength = overlapEndIndex - insertionIndex; Debug.Assert(overlapLength >= 0, "Overlap length isn't allowed to be negative!"); // fast exit if (overlapLength == 0) { return(true); } SlowBitvector cuttedDeductionString = deductionString.subvector((uint)insertionIndex, (uint)overlapEndIndex); SlowBitvector cuttedCandidateBitvector = candidateBitvector.subvector(0, (uint)overlapLength); return(checkOverlapEqual(cuttedDeductionString, cuttedCandidateBitvector)); }
public static Prediction predictNextBit(SlowBitvector deductionString, uint order) { Debug.Assert(order != 0, "Order is not allowed to be zero!"); if (order == 0) { throw new SystemException("Order is not allowed to be zero!"); } bool isOrderInfinite = order == -1; // TODO< implement for infinite order (== -1) and other orders Debug.Assert(order == 1, "Only implemented for order == 1! TODO"); ulong falseCounter = 0, trueCounter = 0; // should take continuation without direct evidence into account? bool takeFloatingonsiderationIntoAccount = true; int startIndexDeltaFromEnding = takeFloatingonsiderationIntoAccount ? 0 : -1; for (int insertionIndex = deductionString.vector.Count + startIndexDeltaFromEnding; insertionIndex >= 1; insertionIndex--) { Console.WriteLine("InsertionIndex={0}", insertionIndex); for (int startIndex = 0; startIndex < deductionString.vector.Count + 1; startIndex++) { for (int endIndex = startIndex + 1; endIndex < deductionString.vector.Count + 1; endIndex++) { SlowBitvector deductionStringSub = deductionString.subvector((uint)startIndex, (uint)endIndex); Console.WriteLine(""); Console.WriteLine("{0}", debugBitvector(deductionString)); Console.WriteLine("{0}", generateVoidString((uint)insertionIndex) + debugBitvector(deductionStringSub)); bool matches = doesMatch(deductionString, deductionStringSub, insertionIndex); Console.WriteLine("does match={0}", matches); // TODO< if does match the extract the candidate bit and increment the counter > if (matches && (insertionIndex + endIndex >= deductionString.vector.Count)) { Console.WriteLine("==>HERE"); // extract candidate bit int deductionStringSubIndex = deductionString.vector.Count - insertionIndex; bool candidateSymbol = deductionStringSub.vector[deductionStringSubIndex]; if (candidateSymbol) { trueCounter++; } else { falseCounter++; } } } } } return(new Prediction(trueCounter, falseCounter)); }