Package cc.redberry.core.tensor

Examples of cc.redberry.core.tensor.Tensor


    }

    @Override
    public TraverseState next() {
        TraverseState oldState = state();
        Tensor oldTensor = tensor();

        TraverseState newState = super.next();
        Tensor newTensor = tensor();

        if (oldState == TraverseState.Entering && oldTensor instanceof TensorField)
            currentUpperProduct = new TensorReference(currentUpperProduct);
        if (oldState == TraverseState.Entering && oldTensor instanceof Derivative) {
            derivativeStack = new TensorReference<>(derivativeStack);
View Full Code Here


    @Override
    public final Tensor result() {
        Sum sum = new Sum();
        for (Split sp : collectedTerms)
            sum.add(sp.tensorEquvivalent());
        Tensor result = sum.equivalent();
        result.setParent(CC.getRootParentTensor());
        return result;
    }
View Full Code Here

        IndicesInsertion insertion = new IndicesInsertion(IndicesFactory.createSimple(null, upper),
                IndicesFactory.createSimple(null, lower),
                indicator);

        StringBuilder sb;
        Tensor temp;
        String covariantIndicesString;
        Transformation n2 = new SqrSubs(Tensors.parseSimple("n_l")), n2Transformer = new Transformer(TraverseState.Leaving, new Transformation[]{n2});
        Transformation[] transformations = ArraysUtils.addAll(new Transformation[]{EliminateMetricsTransformation.ELIMINATE_METRICS, n2Transformer}, riemannBackground);
        for (i = 0; i < actualHatQuantities; ++i) {
            hatQuantities[i] = new Expression[operatorOrder + 1 - i];
            covariantIndicesString = IndicesUtils.toString(Arrays.copyOfRange(covariantIndices, 0, covariantIndices.length - i), OutputFormat.Redberry);
            for (j = 0; j < operatorOrder + 1 - i; ++j) {
                sb = new StringBuilder();
                sb.append(getStringHatQuantitieName(i)).
                        append(IndicesUtils.toString(Arrays.copyOfRange(covariantIndices, j, covariantIndices.length - i), OutputFormat.Redberry)).
                        append("=iK*").
                        append(getStringInputName(1 + i)).
                        append(covariantIndicesString);
                for (k = 0; k < j; ++k)
                    sb.append("*n").append(IndicesUtils.toString(IndicesUtils.inverseIndexState(covariantIndices[k]), OutputFormat.Redberry));

                temp = Tensors.parse(sb.toString(), insertion);
                temp = inputValues[0].transform(temp);
                temp = inputValues[i + 1].transform(temp);
                temp = ExpandTransformation.expand(temp, transformations);
                for (Transformation t : transformations)
                    temp = t.transform(temp);
                hatQuantities[i][j] = (Expression) temp;
            }
        }
        for (; i < HAT_QUANTITIES_GENERAL_COUNT; ++i) {
            hatQuantities[i] = new Expression[1];
            sb = new StringBuilder();
            sb.append(getStringHatQuantitieName(i)).append("=0");
            hatQuantities[i][0] = (Expression) Tensors.parse(sb.toString(), insertion);
        }
        kn = new Expression[operatorOrder + 1];
        covariantIndicesString = IndicesUtils.toString(covariantIndices, OutputFormat.Redberry);
        String matricIndices = IndicesUtils.toString(ArraysUtils.addAll(upper, lower), OutputFormat.Redberry);
        for (i = 0; i < operatorOrder + 1; ++i) {
            sb = new StringBuilder();
            sb.append("Kn").append(IndicesUtils.toString(Arrays.copyOfRange(covariantIndices, i, covariantIndices.length), OutputFormat.Redberry)).
                    append(matricIndices).
                    append("=K").
                    append(covariantIndicesString).
                    append(matricIndices);
            for (k = 0; k < i; ++k)
                sb.append("*n").append(IndicesUtils.toString(IndicesUtils.inverseIndexState(covariantIndices[k]), OutputFormat.Redberry));
            temp = Tensors.parse(sb.toString());
            temp = inputValues[0].transform(temp);
            temp = inputValues[1].transform(temp);
            temp = ExpandTransformation.expand(temp, transformations);
            for (Transformation t : transformations)
                temp = t.transform(temp);
            kn[i] = (Expression) temp;
        }

        final int[] symmetry = new int[F.get(0).getIndices().size()];
        symmetry[0] = 1;
        symmetry[1] = 0;
        for (i = 2; i < symmetry.length; ++i)
            symmetry[i] = i;
        Tensors.addSymmetry((SimpleTensor) F.get(0), IndexType.LatinLower, true, symmetry);
        this.F = F;

        covariantIndicesString = IndicesUtils.toString(Arrays.copyOfRange(covariantIndices, 0, 2), OutputFormat.Redberry);
        sb = new StringBuilder();
        sb.append("HATF").
                append(covariantIndicesString).
                append("=iK*F").
                append(covariantIndicesString);
        Tensor HATF = (Expression) Tensors.parse(sb.toString(), insertion);

        HATF = F.transform(HATF);
        HATF = inputValues[0].transform(HATF);
        this.HATF = (Expression) HATF;
    }
View Full Code Here

        Expression kronecker = (Expression) Tensors.parse("d_{l}^{l}=4");
        Transformation n2 = new SqrSubs(Tensors.parseSimple("n_l")), n2Transformer = new Transformer(TraverseState.Leaving, new Transformation[]{n2});
        Transformation[] common = new Transformation[]{EliminateMetricsTransformation.ELIMINATE_METRICS, n2Transformer, kronecker};
        Transformation[] all = ArraysUtils.addAll(common, riemansSubstitutions);
        Tensor temp;

        //Calculating Delta- tensors
        System.out.println("Evaluating \\Delta- tensors.");

        //DELTA_1,2
View Full Code Here

    @Override
    public Tensor transform(Tensor tensor) {
        TreeTraverseIterator iterator = new TreeTraverseIterator(tensor);
        TraverseState state;
        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);
            }
        }
        return iterator.result();
    }
View Full Code Here

    }

    @Override
    public Tensor toTensor() {
        SimpleTensor[] vars = new SimpleTensor[content.length - 1];
        Tensor temp = content[0].toTensor();

        TIntHashSet allowedDummies = TensorUtils.getAllIndicesNamesT(temp);
        IndicesBuilder free = new IndicesBuilder().append(temp.getIndices());
        for (int i = 1; i < content.length; ++i) {
            temp = content[i].toTensor();
            free.append(temp.getIndices().getInverted());
            allowedDummies.addAll(IndicesUtils.getIndicesNames(temp.getIndices()));
            if (!(temp instanceof SimpleTensor) && !(temp instanceof TensorField))
                throw new IllegalArgumentException("Derivative with respect to non simple argument: " + temp);
            vars[i - 1] = (SimpleTensor) temp;
        }
        allowedDummies.removeAll(IndicesUtils.getIndicesNames(free.getIndices().getFree()));
        Tensor result = new DifferentiateTransformation(
                vars, new Transformation[]{ExpandAndEliminateTransformation.EXPAND_AND_ELIMINATE}
        ).transform(content[0].toTensor());
        result = ApplyIndexMapping.optimizeDummies(result);
        TIntHashSet generated = TensorUtils.getAllDummyIndicesT(result);
        generated.removeAll(allowedDummies);
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

    @Override
    public Tensor transform(Tensor t) {
        TreeTraverseIterator iterator = new TreeTraverseIterator(t, guide);
        TraverseState currentState;
        Tensor currentTensor, newTensor;
        while ((currentState = iterator.next()) != null) {
            if (currentState != state)
                continue;
            currentTensor = newTensor = iterator.current();
View Full Code Here

         * @param transformation
         * @return result
         */
        public static Tensor applyToEachChild(Tensor tensor, final Transformation transformation) {
            TensorBuilder builder = null;
            Tensor c, oc;
            for (int i = 0, size = tensor.size(); i < size; ++i) {
                c = transformation.transform(oc = tensor.get(i));
                if (builder != null || c != oc) {
                    if (builder == null) {
                        builder = tensor.getBuilder();
View Full Code Here

         * @param t              tensor
         * @param transformation transformation
         * @return result
         */
        public static Tensor applyUntilUnchanged(Tensor t, final Transformation transformation) {
            Tensor r;
            do {
                r = t;
                t = transformation.transform(r);
            } while (r != t);
            return r;
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.