SimpleProductMappingsPort(final IndexMappingProvider opu, final Tensor[] from, final Tensor[] to) { providers = new IndexMappingProvider[from.length]; providers[0] = IndexMappings.createPort(opu, from[0], to[0]); for (int i = 1; i < from.length; ++i) providers[i] = IndexMappings.createPort(providers[i - 1], from[i], to[i]); }
public SinglePairSource(Tensor from, Tensor to, int fromPointer) { this.mappingsPort = IndexMappings.createPort(from, to); this.fromPointer = new int[]{fromPointer}; }
/** * Returns a set of all possible mappings of tensor {@code from} on tensor {@code to}. * * @param from from tensor * @param to to tensor * @return a set of all possible mappings of tensor {@code from} on tensor {@code to} */ public static Set<Mapping> getAllMappings(Tensor from, Tensor to) { return getAllMappings(IndexMappings.createPort(from, to)); }
public static List<Permutation> findIndicesSymmetries(int[] indices, Tensor tensor) { return getSymmetriesFromMappings(indices, IndexMappings.createPort(tensor, tensor)); }
@Override public Mapping take() { Mapping buf; while (true) { if (currentSource != null && (buf = currentSource.take()) != null) return buf; if (!permutationGenerator.hasNext()) return null; currentPermutation = permutationGenerator.next(); currentSource = IndexMappings.createPort(from[0], to[currentPermutation[0]]); } }
public static List<Permutation> findIndicesSymmetries(SimpleIndices indices, Tensor tensor) { return getSymmetriesFromMappings(indices.getAllIndices().copy(), IndexMappings.createPort(tensor, tensor)); }
/** * Creates output port of mappings of tensor {@code from} on tensor {@code to} with specified * mappings rules defined in specified {@link IndexMappingBuffer}. * * @param buffer initial mapping rules * @param from from tensor * @param to to tensor * @return output port of mapping */ static OutputPort<IndexMappingBuffer> createPortOfBuffers(final IndexMappingBuffer buffer, final Tensor from, final Tensor to) { final IndexMappingProvider provider = createPort(IndexMappingProvider.Util.singleton(buffer), from, to); provider.tick(); return new MappingsPortRemovingContracted(provider); }
static IndexMappingProvider createPort(IndexMappingProvider opu, Tensor from, Tensor to) { if (from.hashCode() != to.hashCode()) return IndexMappingProvider.Util.EMPTY_PROVIDER; if (from.getClass() != to.getClass()) { Tensor nonComplex; //Processing case -2*(1/2)*g_mn -> g_mn if (from instanceof Product && !(to instanceof Product)) { if (from.size() != 2) return IndexMappingProvider.Util.EMPTY_PROVIDER; if ((nonComplex = extractNonComplexFactor(from)) != null) return new MinusIndexMappingProviderWrapper(createPort(opu, nonComplex, to)); return IndexMappingProvider.Util.EMPTY_PROVIDER; } //Processing case g_mn -> -2*(1/2)*g_mn if (to instanceof Product && !(from instanceof Product)) { if (to.size() != 2) return IndexMappingProvider.Util.EMPTY_PROVIDER; if ((nonComplex = extractNonComplexFactor(to)) != null) return new MinusIndexMappingProviderWrapper(createPort(opu, from, nonComplex)); return IndexMappingProvider.Util.EMPTY_PROVIDER; } return IndexMappingProvider.Util.EMPTY_PROVIDER; } IndexMappingProviderFactory factory = map.get(from.getClass()); if (factory == null) throw new RuntimeException("Unsupported tensor type: " + from.getClass()); return factory.create(opu, from, to); }
private static boolean mappingExists(Tensor from, Tensor to) { final IndexMappingProvider pp = IndexMappings.createPort( IndexMappingProvider.Util.singleton(new IndexMappingBufferImpl()), from, to); pp.tick(); return pp.take() != null; }
/** * Tests whether specified {@link IndexMappingBufferTester} is a real mapping of tensor {@code from} * on tensor {@code to}. * * @param tester tester of mappings * @param from from tensor * @param to to tensor * @return {@code true} if there is mapping of tensor {@code from} on tensor {@code to} equal * to specified mapping */ public static boolean test(IndexMappingBufferTester tester, Tensor from, Tensor to) { tester.reset(); final IndexMappingProvider provider = IndexMappings.createPort(IndexMappingProvider.Util.singleton(tester), from, to); provider.tick(); IndexMappingBuffer buffer; while ((buffer = provider.take()) != null) if (!buffer.getSign()) return true; return false; }
if (i - 1 == begin) providers.add(lastOutput = IndexMappings.createPort(lastOutput, indexlessFrom[begin], indexlessTo[begin])); else providers.add(lastOutput = IndexMappings.createPort(lastOutput, fromContent.get(begin), toContent.get(begin)));
this.mainProvider = IndexMappings.createPort(cache, from.get(mainStretchCoord), to.get(mainStretchCoord)); testersList.remove(mainStretchIndex);
MappingsPort port = IndexMappings.createPort(temp, temp); Mapping mapping; Permutation sym;