Package cc.redberry.core.indexmapping

Examples of cc.redberry.core.indexmapping.Mapping


            //symmetries of eps indices, which are contracted with other product (also totally antisymmetric)
            Map<IntArray, Boolean> symmetries = getEpsilonSymmetries(indices.length);

            //symmetries of product, which is contracted with Levi-Civita
            MappingsPort port = IndexMappings.createPort(temp, temp);
            Mapping mapping;
            Symmetry sym;

            //check for two symmetric indices of product contracted with two antisymmetric indices of eps
            while ((mapping = port.take()) != null) {
                //symmetry of product indices
View Full Code Here


        Tensor current;
        while ((state = iterator.next()) != null) {
            if (state != TraverseState.Leaving)
                continue;
            current = iterator.current();
            Mapping mapping = IndexMappings.getFirst(from, current);
            if (mapping != null) {
                Tensor newFrom = ApplyIndexMapping.applyIndexMapping(to, mapping);
                iterator.set(newFrom);
            }
        }
View Full Code Here

            System.arraycopy(toAdd, 0, to, oldFromLength, toAdd.length);
        }

        assert from.length == freeIndices.length;

        return applyIndexMapping(tensor, new Mapping(from, to, mapping.getSign()), forbidden);
    }
View Full Code Here

            Tensor derivative =
                    new SymmetrizeTransformation(allFreeVarIndicesI, true).transform(symmetric);

            derivative = applyIndexMapping(
                    derivative,
                    new Mapping(allIndices,
                            addAll(varIndices.getInverted().getAllIndices().copy(), allFreeArgIndices)),
                    new int[0]);
            ProductBuilder builder = new ProductBuilder(0, length);
            for (i = 0; i < length; ++i)
                builder.put(createMetricOrKronecker(allFreeArgIndices[i], allFreeVarIndices[i]));
View Full Code Here

        @Override
        Tensor differentiateSimpleTensorWithoutCheck(SimpleTensor simpleTensor) {
            int[] to = simpleTensor.getIndices().getAllIndices().copy();
            to = addAll(to, freeVarIndices);
            return applyIndexMapping(derivative, new Mapping(allFreeFrom, to), new int[0]);
        }
View Full Code Here

    private Tensor __newTo(DFromTo fromTo, TensorField currentField,
                           Tensor currentNode, SubstitutionIterator iterator) {

        TensorField from = fromTo.from;
        Mapping mapping = IndexMappings.simpleTensorsPort(from, currentField).take();
        if (mapping == null)
            return currentNode;

        Indices[] fromIndices = from.getArgIndices(),
                currentIndices = currentField.getArgIndices();

        List<Tensor> argFrom = new ArrayList<>(), argTo = new ArrayList<>();
        Tensor fArg;
        int[] cIndices, fIndices;
        int i;
        for (i = from.size() - 1; i >= 0; --i) {
            if (IndexMappings.positiveMappingExists(currentNode.get(i), from.get(i)))
                continue;

            fIndices = fromIndices[i].getAllIndices().copy();
            cIndices = currentIndices[i].getAllIndices().copy();

            assert cIndices.length == fIndices.length;

            fArg = ApplyIndexMapping.applyIndexMapping(from.get(i), new Mapping(fIndices, cIndices), new int[0]);

            argFrom.add(fArg);
            argTo.add(currentNode.get(i));
        }
View Full Code Here

                                indicesSpace[b][--totalIndicesCounts[b]]);

            }

            descriptor = ApplyIndexMapping.applyIndexMapping(descriptor,
                    new Mapping(free.getAllIndices().copy(), factorIndices), forbidden.toArray());
            descriptor = ApplyIndexMapping.renameDummy(descriptor, forbidden.toArray());
            forbidden.addAll(TensorUtils.getAllIndicesNamesT(descriptor));

            pb.put(descriptor);
        }
View Full Code Here

        return Tensors.multiply(product.getIndexlessSubProduct(), Tensors.multiply(data));
    }

    private static Tensor setIndices(Tensor t, Indices from, Indices to) {
        return ApplyIndexMapping.applyIndexMapping(t,
                new Mapping(from.getAllIndices().copy(), to.getAllIndices().copy()), new int[0]);
    }
View Full Code Here

        result[result.length - 1] = factor;
        return Tensors.multiply(result);
    }

    SubsResult atomicSubstitute(PContent content, ForbiddenContainer forbidden, SubstitutionIterator iterator) {
        Mapping mapping = null;
        int[] indexlessBijection, dataBijection;

        IndexlessBijectionsPort indexlessPort
                = new IndexlessBijectionsPort(fromIndexless, content.indexless);

        while ((indexlessBijection = indexlessPort.take()) != null) {
            mapping = createBijectiveProductPort(fromIndexless, extract(content.indexless, indexlessBijection)).take();
            if (mapping != null)
                break;
        }

        if (mapping == null)
            return null;

        boolean sign = mapping.getSign();
        mapping = null;

        Tensor[] currentData;
        if (content.data instanceof Product) {
            ProductContent currentContent = ((Product) content.data).getContent();
            currentData = currentContent.getDataCopy();
            ProductsBijectionsPort dataPort = new ProductsBijectionsPort(fromContent, currentContent);
            while ((dataBijection = dataPort.take()) != null) {
                mapping = createBijectiveProductPort(fromData, extract(currentData, dataBijection)).take();
                if (mapping != null)
                    break;
            }
        } else {
            if (TensorUtils.isOne(content.data)) {
                if (fromContent.size() != 0)
                    return null;
                dataBijection = new int[0];
                currentData = new Tensor[0];
                mapping = Mapping.IDENTITY;
            } else {
                if (fromContent.size() != 1)
                    return null;
                dataBijection = new int[1];
                currentData = new Tensor[]{content.data};
                mapping = getFirst(fromContent.get(0), content.data);
            }
        }

        if (mapping == null)
            return null;

        mapping = mapping.addSign(sign);
        Arrays.sort(indexlessBijection);
        Arrays.sort(dataBijection);

        Tensor[] indexlessRemainder = new Tensor[content.indexless.length - fromIndexless.length];
        ProductBuilder dataRemainder = new ProductBuilder(0,
                (content.data instanceof Product)
                        ? content.data.size()
                        : 1 - fromContent.size());
        int pivot = 0;
        int i, j = 0;
        for (i = 0; i < content.indexless.length; ++i) {
            if (pivot < indexlessBijection.length && i == indexlessBijection[pivot])
                ++pivot;
            else
                indexlessRemainder[j++] = content.indexless[i];
        }
        pivot = 0;
        for (i = 0; i < currentData.length; ++i) {
            if (pivot < dataBijection.length && i == dataBijection[pivot])
                ++pivot;
            else
                dataRemainder.put(currentData[i]);
        }
        Tensor dataRemainderT = dataRemainder.build();

        PContent remainder = new PContent(indexlessRemainder, dataRemainderT);

        Tensor newTo;
        if (toIsSymbolic)
            newTo = mapping.getSign() ? Tensors.negate(to) : to;
        else {
            if (possiblyAddsDummies) {
                if (forbidden.forbidden == null)
                    forbidden.forbidden = new TIntHashSet(iterator.getForbidden());

                TIntHashSet remainderIndices = new TIntHashSet(forbidden.forbidden);
                remainderIndices.addAll(getAllIndicesNamesT(indexlessRemainder));
                remainderIndices.addAll(getAllIndicesNamesT(dataRemainderT));
                newTo = applyIndexMapping(to, mapping, remainderIndices.toArray());
                forbidden.forbidden.addAll(getAllIndicesNamesT(newTo));
            } else {
                TIntHashSet allowed = new TIntHashSet();
                for (int index : indexlessBijection)
                    allowed.addAll(TensorUtils.getAllDummyIndicesT(content.indexless[index]));
                IndicesBuilder ib = new IndicesBuilder();
                for (int index : dataBijection) {
                    allowed.addAll(TensorUtils.getAllDummyIndicesT(currentData[index]));
                    ib.append(currentData[index]);
                }
                allowed.addAll(ib.getIndices().getNamesOfDummies());
                allowed.removeAll(IndicesUtils.getIndicesNames(mapping.getToData()));
                newTo = applyIndexMappingAndRenameAllDummies(to, mapping, allowed.toArray());
            }
        }
        return new SubsResult(newTo, remainder);
    }
View Full Code Here

        SumBuilder sb = new SumBuilder();
        for (Permutation permutation; cosetRepresentatives.hasNext(); ) {
            permutation = cosetRepresentatives.next();
            sb.put(ApplyIndexMapping.applyIndexMappingAutomatically(t,
                    new Mapping(indicesArray, permutation.permute(indicesArray), permutation.antisymmetry())));
        }

        t = sb.build();

        if (multiplyBySymmetryFactor) {
View Full Code Here

TOP

Related Classes of cc.redberry.core.indexmapping.Mapping

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.