Examples of FromChildToParentIterator


Examples of cc.redberry.core.tensor.iterator.FromChildToParentIterator

     * @param tensor        tensor
     * @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

Examples of cc.redberry.core.tensor.iterator.FromChildToParentIterator

    static Tensor factorOut(Tensor tensor) {
        return factorOut(tensor, JasFactor.ENGINE);
    }

    static Tensor factorOut(Tensor tensor, FactorizationEngine factorizationEngine) {
        FromChildToParentIterator iterator = new FromChildToParentIterator(tensor);
        Tensor c;
        while ((c = iterator.next()) != null)
            if (c instanceof Sum)
                iterator.set(factorOut1(c, factorizationEngine));
        return iterator.result();
    }
View Full Code Here

Examples of cc.redberry.core.tensor.iterator.FromChildToParentIterator

     * @param doFactor specifies whether to cancel factors in the result
     * @return result
     */
    //todo make two separate methods
    public static Tensor together(Tensor t, boolean doFactor) {
        FromChildToParentIterator iterator = new FromChildToParentIterator(t);
        Tensor c;
        while ((c = iterator.next()) != null) {
            if (c instanceof Sum)
                iterator.set(togetherSum(c, doFactor));
            if (c instanceof Product)
                iterator.set(collectScalarFactorsInProduct((Product) c));
        }
        return iterator.result();
    }
View Full Code Here

Examples of cc.redberry.core.tensor.iterator.FromChildToParentIterator

    private ComplexConjugateTransformation() {
    }

    @Override
    public Tensor transform(Tensor t) {
        FromChildToParentIterator iterator = new FromChildToParentIterator(t);
        Tensor c;
        while ((c = iterator.next()) != null)
            if (c instanceof Complex)
                iterator.set(((Complex) c).conjugate());
        return iterator.result();
    }
View Full Code Here

Examples of cc.redberry.core.tensor.iterator.FromChildToParentIterator

        this(varsToIndicator(vars));
    }

    @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)));

        return iterator.result();
    }
View Full Code Here

Examples of cc.redberry.core.tensor.iterator.FromChildToParentIterator

        }
        return iterator.result();
    }

    private static Tensor factorSymbolicTerm(Tensor sum) {
        TreeIterator iterator = new FromChildToParentIterator(sum);
        Tensor c;
        while ((c = iterator.next()) != null)
            if (c instanceof Sum)
                iterator.set(factorOut(c));

        iterator = new FromParentToChildIterator(iterator.result());
        while ((c = iterator.next()) != null) {
            if (!(c instanceof Sum))
                continue;
            if (needTogether(c)) {
                c = TogetherTransformation.together(c, true);
                if (c instanceof Product) {
                    TensorBuilder pb = null;
                    for (int i = c.size() - 1; i >= 0; --i) {
                        if (c.get(i) instanceof Sum) {
                            if (pb == null) {
                                pb = c.getBuilder();
                                for (int j = c.size() - 1; j > i; --j)
                                    pb.put(c.get(j));
                            }
                            pb.put(JasFactor.factor(c.get(i)));
                        } else if (pb != null)
                            pb.put(c.get(i));
                    }
                    iterator.set(pb == null ? c : pb.build());
                }
            } else
                iterator.set(JasFactor.factor(c));
        }
        return iterator.result();
    }
View Full Code Here

Examples of cc.redberry.core.tensor.iterator.FromChildToParentIterator

//        return iterator.result();
    }


    static Tensor factorOut(Tensor tensor) {
        FromChildToParentIterator iterator = new FromChildToParentIterator(tensor);
        Tensor c;
        while ((c = iterator.next()) != null)
            if (c instanceof Sum)
                iterator.set(factorOut1(c));
        return iterator.result();
    }
View Full Code Here

Examples of cc.redberry.core.tensor.iterator.FromChildToParentIterator

        }
        return iterator.result();
    }

    private static Tensor factorSymbolicTerm(Tensor sum) {
        TreeIterator iterator = new FromChildToParentIterator(sum);
        Tensor c;
        while ((c = iterator.next()) != null)
            if (c instanceof Sum)
                iterator.set(factorOut(c));

        iterator = new FromParentToChildIterator(iterator.result());
        while ((c = iterator.next()) != null) {
            if (!(c instanceof Sum))
                continue;
            if (needTogether(c)) {
                c = TogetherTransformation.together(c, true);
                if (c instanceof Product) {
                    TensorBuilder pb = null;
                    for (int i = c.size() - 1; i >= 0; --i) {
                        if (c.get(i) instanceof Sum) {
                            if (pb == null) {
                                pb = c.getBuilder();
                                for (int j = c.size() - 1; j > i; --j)
                                    pb.put(c.get(j));
                            }
                            pb.put(JasFactor.factor(c.get(i)));
                        } else if (pb != null)
                            pb.put(c.get(i));
                    }
                    iterator.set(pb == null ? c : pb.build());
                } else iterator.set(c);
            } else
                iterator.set(JasFactor.factor(c));
        }
        return iterator.result();
    }
View Full Code Here

Examples of cc.redberry.core.tensor.iterator.FromChildToParentIterator

//        return iterator.result();
    }


    static Tensor factorOut(Tensor tensor) {
        FromChildToParentIterator iterator = new FromChildToParentIterator(tensor);
        Tensor c;
        while ((c = iterator.next()) != null)
            if (c instanceof Sum)
                iterator.set(factorOut1(c));
        return iterator.result();
    }
View Full Code Here

Examples of cc.redberry.core.tensor.iterator.FromChildToParentIterator

     * @param tensor     tensors
     * @param setOfNames int set of simple tensors names
     * @return true if tensor contains at least one of simple tensor with name that contains in the set
     */
    public static boolean containsSimpleTensors(Tensor tensor, TIntSet setOfNames) {
        FromChildToParentIterator iterator = new FromChildToParentIterator(tensor);
        Tensor current;
        boolean contains = false;
        while ((current = iterator.next()) != null)
            if (current instanceof SimpleTensor && setOfNames.contains(((SimpleTensor) current).getName())) {
                contains = true;
                break;
            }
        return contains;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.