@Override public boolean test(IndexMappingBufferTester tester) { for (int i = 1; i < from.length; ++i) if (!IndexMappingBufferTester.test(tester, from[i], to[currentPermutation[i]])) return false; return true; } }
@Override public boolean test(final IndexMappingBufferTester tester) { return IndexMappingBufferTester.test(tester, from, to); } }
@Override public boolean test(final IndexMappingBufferTester tester) { //TODO discuss algorithm with Dima boolean[] bijection = new boolean[length]; int i, j; OUT: for (i = 0; i < length; ++i) { for (j = 0; j < length; ++j) if (!bijection[j] && IndexMappingBufferTester.test(tester, from[j], to[i])) { bijection[j] = true; continue OUT; } return false; } return true; // int[] permutation; // final PriorityPermutationGenerator generator = permutationGenerator; // generator.reset(); // int i; // OUTER: // while ((permutation = generator.next()) != null) // for (i = 0; i < from.length; ++i) { // if (!IndexMappingBufferTester.test(tester, from[i], to[permutation[i]])) // continue OUTER; // generator.nice(); // return true; // } // return false; } }
/** * Tests whether specified mapping is a mapping from <i>{@code from}</i> tensor onto <i>{@code to}</i> tensor. * * @param mapping mapping * @param from tensor <i>{@code from}</i> * @param to tensor <i>{@code to}</i> * @return {@code true} if specified mapping is a mapping from <i>{@code from}</i> tensor onto * <i>{@code to}</i> tensor and {@code false} in other case. */ public static boolean testMapping(Mapping mapping, Tensor from, Tensor to) { return IndexMappingBufferTester.test(new IndexMappingBufferTester(mapping), from, to); }