Package cc.redberry.core.tensor

Examples of cc.redberry.core.tensor.Tensor


     * @param t tensor
     * @return the numerical value of tensor
     */
    public static Tensor toNumeric(Tensor t) {
        FromChildToParentIterator iterator = new FromChildToParentIterator(t);
        Tensor c;
        while ((c = iterator.next()) != null)
            if (c instanceof Complex)
                iterator.set(((Complex) c).getNumericValue());

        return iterator.result();
View Full Code Here


        return collectNonScalars(t);
    }

    public static Tensor collectNonScalars(Tensor t) {
        FromChildToParentIterator iterator = new FromChildToParentIterator(t);
        Tensor c;
        while ((c = iterator.next()) != null)
            if (c instanceof Sum) {
                //TODO add check whether we need to do this transformation
                SumBuilderSplitingScalars sbss = new SumBuilderSplitingScalars(c.size());
                for (Tensor tt : c)
                    sbss.put(tt);
                iterator.set(sbss.build());
            }
        return iterator.result();
View Full Code Here

     * @param traverseGuide specifies parts of expression to apply the transformation
     * @return the result
     */
    public static Tensor collectScalarFactors(Tensor tensor, TraverseGuide traverseGuide) {
        FromChildToParentIterator iterator = new FromChildToParentIterator(tensor, traverseGuide);
        Tensor current;
        while ((current = iterator.next()) != null) {
            if (current instanceof Product)
                iterator.set(collectScalarFactorsInProduct((Product) current));
        }
        return iterator.result();
View Full Code Here

    }

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

    }

    @Override
    public Tensor transform(Tensor tensor) {
        SubstitutionIterator iterator = new SubstitutionIterator(tensor, traverseGuide);
        Tensor current;
        while ((current = iterator.next()) != null) {
            if (current instanceof Product)
                iterator.unsafeSet(expandProduct((Product) current, transformations));
            else if (ExpandUtils.isExpandablePower(current)) {
                Sum sum = (Sum) current.get(0);
                int exponent = ((Complex) current.get(1)).intValue();
                if (exponent == -1)
                    continue;
                boolean symbolic = TensorUtils.isSymbolic(sum),
                        reciprocal = exponent < 0;
                exponent = Math.abs(exponent);
                Tensor temp;
                if (symbolic)
                    temp = ExpandUtils.expandSymbolicPower(sum, exponent, transformations);
                else
                    temp = ExpandUtils.expandPower(sum, exponent, iterator.getForbidden(), transformations);
                if (reciprocal)
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, Tensors.reciprocal(numDen.denominator));
View Full Code Here

    }

    @Override
    protected Tensor expandProduct(Product product, Transformation[] transformations) {
        NumeratorDenominator numDen = NumeratorDenominator.getNumeratorAndDenominator(product, NumeratorDenominator.integerDenominatorIndicator);
        Tensor denominator = numDen.denominator;

//        assert !isPositiveIntegerPower(denominator);
        if (denominator instanceof Product)
            denominator = ExpandUtils.expandProductOfSums((Product) numDen.denominator, transformations);
        boolean denExpanded = denominator != numDen.denominator;
        denominator = reciprocal(denominator);

        Tensor numerator = numDen.numerator;
        Tensor res = Tensors.multiply(denominator, numerator), temp = res;
        if (res instanceof Product)
            res = ExpandUtils.expandProductOfSums((Product) temp, transformations);
        if (denExpanded || res != temp)
            return res;
        return product;
View Full Code Here

    }

    @Override
    public Tensor transform(Tensor t) {
        FromChildToParentIterator iterator = new FromChildToParentIterator(t);
        Tensor c;

        while ((c = iterator.next()) != null)
            if (powerExpandApplicable(c, toExpandIndicator))
                iterator.set(Tensors.multiply(powerExpandToArray1(c, toExpandIndicator)));
View Full Code Here

    }

    @Override
    public Tensor transform(Tensor t) {
        SubstitutionIterator iterator = new SubstitutionIterator(t);
        Tensor c;

        while ((c = iterator.next()) != null)
            if (powerExpandApplicable(c, toExpandIndicator))
                iterator.set(Tensors.multiply(powerExpandIntoChainToArray1(c, iterator.getForbidden(), toExpandIndicator)));
View Full Code Here

                for (int j = 0; j < metricInds.length; ++j)
                    if (temp[j] == 0xFFFFFFFF)
                        temp[j] = createIndex(counter++, getType(metricInds[j]), false);//lower index
                IntArrayList _result = nonMetricIndices.clone();
                _result.addAll(temp);
                Tensor renamed = ApplyIndexMapping.applyIndexMapping(st, new Mapping(indicesArray, _result.toArray()));
                //todo bottleneck
                for (Tensor existing : combinationArray)
                    if (TensorUtils.compare1(existing, renamed) != null)
                        continue combinations;
                combinationArray.add(renamed);
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.