Package cc.redberry.core.tensor

Examples of cc.redberry.core.tensor.Tensor


    }

    @Override
    protected Tensor expandProduct(Product product, Transformation[] transformations) {
        NumeratorDenominator numDen = NumeratorDenominator.getNumeratorAndDenominator(product, NumeratorDenominator.integerDenominatorIndicator);
        Tensor numerator = numDen.numerator;
        if (numerator instanceof Product)
            numerator = ExpandUtils.expandProductOfSums((Product) numDen.numerator, transformations);
        if (numDen.numerator == numerator)
            return product;
        return Tensors.multiply(numerator, Tensors.reciprocal(numDen.denominator));
View Full Code Here


    }

    @Override
    public Tensor transform(Tensor tensor) {
        SubstitutionIterator iterator = new SubstitutionIterator(tensor);
        Tensor current;
        while ((current = iterator.next()) != null) {

            BijectionContainer bc = new SumBijectionPort(from, current).take();
            if (bc == null)
                continue;

            IndexMappingBuffer buffer = bc.buffer;
            Tensor newTo;
            if (symbolic)
                newTo = to;
            else {
                int[] forbidden = new int[iterator.forbiddenIndices().size()];
                int c = -1;
View Full Code Here

    }

    @Override
    public Tensor transform(Tensor tensor) {
        SubstitutionIterator iterator = new SubstitutionIterator(tensor);
        Tensor current;
        while ((current = iterator.next()) != null) {
            if (!(current instanceof Product))
                continue;

            while (current instanceof Product) {
                Product cp = (Product) current;
                IndexMappingBuffer buffer = null;

                final Tensor[] currentIndexless = cp.getIndexless();
                int[] indexlessBijection;
                IndexlessBijectionsPort indexlessPort = new IndexlessBijectionsPort(fromIndexless, currentIndexless);
                while ((indexlessBijection = indexlessPort.take()) != null) {
                    buffer = IndexMappings.createBijectiveProductPort(fromIndexless, extract(currentIndexless, indexlessBijection)).take();
                    if (buffer != null)
                        break;
                }
                if (buffer == null)
                    break;

                boolean sign = buffer.getSignum();
                buffer = null;
                ProductContent currentContent = cp.getContent();
                final Tensor[] currentData = currentContent.getDataCopy();
                int[] dataBijection;
                ProductsBijectionsPort dataPort = new ProductsBijectionsPort(fromContent, currentContent);
                while ((dataBijection = dataPort.take()) != null) {
                    buffer = IndexMappings.createBijectiveProductPort(fromData, extract(currentData, dataBijection)).take();
                    if (buffer != null)
                        break;
                }
                if (buffer == null)
                    break;

                buffer.addSignum(sign);
                Tensor newTo;
                if (symbolic)
                    newTo = to;
                else {
                    int[] forbidden = new int[iterator.forbiddenIndices().size()];
                    int c = -1;
View Full Code Here

    }

    @Override
    public Tensor transform(Tensor tensor) {
        SubstitutionIterator iterator = new SubstitutionIterator(tensor);
        Tensor current;
        while ((current = iterator.next()) != null) {
            IndexMappingBuffer buffer =
                    IndexMappings.getFirst(from, current);
            if (buffer == null)
                continue;
            Tensor newTo;
            if (symbolic)
                newTo = to;
            else {
                int[] forbidden = new int[iterator.forbiddenIndices().size()];
                int c = -1;
View Full Code Here

    }

    @Override
    public Tensor transform(Tensor tensor) {
        SubstitutionIterator iterator = new SubstitutionIterator(tensor);
        Tensor current;
        OUT:
        while ((current = iterator.next()) != null) {
            if (!(current instanceof TensorField))
                continue;
            TensorField currentField = (TensorField) current;
            IndexMappingBuffer buffer = IndexMappings.simpleTensorsPort(from, currentField).take();
            if (buffer == null)
                continue;


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

            List<Transformation> transformations = new ArrayList<>();
            Tensor fArg;
            int[] cIndices, fIndices;
            int i;
            for (i = from.size() - 1; i >= 0; --i) {
                if (IndexMappings.mappingExists(current.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), fIndices, cIndices, new int[0]);


                transformations.add(Substitutions.getTransformation(fArg, current.get(i)));
            }

            Tensor newTo;
            if (symbolic)
                newTo = to;
            else {
                int[] forbidden = new int[iterator.forbiddenIndices().size()];
                int c = -1;
                for (Integer f : iterator.forbiddenIndices())
                    forbidden[++c] = f;
                newTo = ApplyIndexMapping.applyIndexMapping(to, buffer, forbidden);
//                if (newTo != to)
                iterator.forbiddenIndices().addAll(TensorUtils.getAllIndicesNames(newTo));

            }

            for (Transformation transformation : transformations)
                newTo = transformation.transform(newTo);
            if (!symbolic) {
                int[] forbidden = new int[iterator.forbiddenIndices().size()];
                int c = -1;
                for (Integer f : iterator.forbiddenIndices())
                    forbidden[++c] = f;
                Tensor temp = newTo;
                newTo = ApplyIndexMapping.renameDummy(temp, forbidden);
                if (temp != newTo)
                    iterator.forbiddenIndices().addAll(TensorUtils.getAllIndicesNames(newTo));
            }
View Full Code Here

        int[] _from = from.clone();
        Arrays.sort(_from);
        if (!Arrays.equals(freeIndices, _from))
            throw new IllegalArgumentException("From indices are not equal to free indices of tensor.");

        Tensor result = unsafeApplyIndexMappingFromSortedClonedPreparedSource(tensor, from, to, forbidden);
        if (buffer.getSignum())
            return Tensors.negate(result);
        else
            return result;
    }
View Full Code Here

    @Override
    public Tensor transform(Tensor t) {
        TreeTraverseIterator iterator = new TreeTraverseIterator(t);
        TraverseState state;
        Tensor c;
        while ((state = iterator.next()) != null) {
            if (state != TraverseState.Leaving)
                continue;
            c = iterator.current();
            if (TensorUtils.isZeroDueToSymmetry(c))
View Full Code Here

     * @return next traverse state or {@code null} if there is no next element
     */
    public TraverseState next() {
        //  if (current != null && currentPointer.previous == null)
        //    return lastState = null;
        Tensor next;
        while (true) {
            next = currentPointer.next();
            if (next == null) {
                if (currentPointer.previous == null)
                    return lastState = null;
View Full Code Here

            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.mappingExists(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), fIndices, cIndices, new int[0]);

            argFrom.add(fArg);
            argTo.add(currentNode.get(i));
        }

        Tensor newTo = to;
        newTo = new SubstitutionTransformation(
                argFrom.toArray(new Tensor[argFrom.size()]),
                argTo.toArray(new Tensor[argTo.size()]),
                false).transform(newTo);
        if (!TensorUtils.isSymbolic(newTo))
View Full Code Here

    }

    @Override
    protected Tensor expandProduct(Product product, Transformation[] transformations) {
        NumeratorDenominator numDen = NumeratorDenominator.getNumeratorAndDenominator(product, NumeratorDenominator.integerDenominatorIndicator);
        Tensor numerator = numDen.numerator;
        if (numerator instanceof Product)
            numerator = ExpandUtils.expandProductOfSums((Product) numDen.numerator, transformations);
        if (numDen.numerator == numerator)
            return product;
        return Tensors.multiply(numerator, numDen.denominator);
View Full Code Here

TOP

Related Classes of cc.redberry.core.tensor.Tensor

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.