/** * Creates output port of mappings from tensor <i>{@code from}</i> onto tensor <i>{@code to}</i>. * * @param from from tensor * @param to to tensor * @return output port of mappings */ public static MappingsPort createPort(Tensor from, Tensor to) { return new MappingsPort(createPortOfBuffers(new IndexMappingBufferImpl(), from, to)); }
/** * Creates output port of mappings of two products of tensors represented as arrays of multipliers, where * each multiplier of {@code from} will be mapped on the multiplier of {@code to} at the same * position. Such ordering can be obtained via {@link cc.redberry.core.transformations.substitutions.ProductsBijectionsPort}. * In contrast to {@link #createPortOfBuffers(cc.redberry.core.tensor.Tensor, cc.redberry.core.tensor.Tensor)}, this method * will fully handles mappings of free indices on contracted ones (like e.g. _i^j -> _k^k). * * @param from from tensor * @param to to tensor * @return port of mappings of indices */ public static MappingsPort createBijectiveProductPort(Tensor[] from, Tensor[] to) { if (from.length != to.length) throw new IllegalArgumentException("From length != to length."); if (from.length == 0) return new MappingsPort(IndexMappingProvider.Util.singleton(new IndexMappingBufferImpl())); if (from.length == 1) return new MappingsPort(createPortOfBuffers(from[0], to[0])); return new MappingsPort( new MappingsPortRemovingContracted( new SimpleProductMappingsPort(IndexMappingProvider.Util.singleton(new IndexMappingBufferImpl()), from, to))); }
/** * Creates output port of mappings of two simple tensors and does not take into account the arguments of fields. * * @param from from tensor * @param to to tensor * @return port of mappings of indices */ public static MappingsPort simpleTensorsPort(SimpleTensor from, SimpleTensor to) { final IndexMappingProvider provider = ProviderSimpleTensor.FACTORY_SIMPLETENSOR.create(IndexMappingProvider.Util.singleton(new IndexMappingBufferImpl()), from, to); provider.tick(); return new MappingsPort(new MappingsPortRemovingContracted(provider)); }