Package cc.redberry.core.tensorgenerator

Examples of cc.redberry.core.tensorgenerator.SymbolsGenerator


        with indices (they are found only in scalar combinations) with some symbols*/

        //scalar tensor <-> symbol
        THashMap<Tensor, Tensor> tensorSubstitutions = new THashMap<>();
        //all symbols will have names scalar1,scalar2, etc.
        SymbolsGenerator generator = new SymbolsGenerator("scalar", ArraysUtils.addAll(samples, toInverse, equation));

        //processing equations
        int i;
        for (i = 0; i < equations.length; ++i) {
            Expression eq = equations[i];
            //iterating over the whole equation
            FromChildToParentIterator iterator = new FromChildToParentIterator(eq);
            Tensor t;
            while ((t = iterator.next()) != null) {
                if (!(t instanceof Product) || t.getIndices().size() == 0)
                    continue;
                //split tensor into symbolic and tensor (with nonzero length of indices) parts
                Split split = Split.splitIndexless(t);
                if (split.factor.getIndices().size() == 0)//there is no nonsymbolic part in tensor, e.g. t = a*b
                    continue;

                //there is non symbolic part in current tensor, e.g. t = a*k_{i}*k^{i}, so
                //split.summand = a, split.factor = k_{i}*k^{i}

                if (!tensorSubstitutions.containsKey(split.factor)) {
                    //map does not contains rule for current scalar (e.g. k_{i}*k^{i})
                    Tensor s;
                    //adding new rule for the scalar, e.g. k_{i}*k^{i} = scalar2
                    tensorSubstitutions.put(split.factor, s = generator.take());
                    //replacing this scalar with symbol
                    iterator.set(Tensors.multiply(s, split.summand));
                } else
                    //map is already contains rule for current scalar
                    //replacing this scalar with symbol from map
View Full Code Here


        with indices (they are found only in scalar combinations) with some symbols*/

        //scalar tensor <-> symbol
        THashMap<Tensor, Tensor> tensorSubstitutions = new THashMap<>();
        //all symbols will have names scalar1,scalar2, etc.
        SymbolsGenerator generator = new SymbolsGenerator("scalar", ArraysUtils.addAll(samples, toInverse, equation));

        //processing equations
        int i;
        for (i = 0; i < equations.length; ++i) {
            Expression eq = equations[i];
            //iterating over the whole equation
            FromChildToParentIterator iterator = new FromChildToParentIterator(eq);
            Tensor t;
            while ((t = iterator.next()) != null) {
                if (!(t instanceof Product) || t.getIndices().size() == 0)
                    continue;
                //scalars content
                Tensor[] scalars = ((Product) t).getContent().getScalars();
                for (Tensor scalar : scalars) {
                    if (!tensorSubstitutions.containsKey(scalar)) {
                        //map does not contains rule for current scalar (e.g. k_{i}*k^{i})
                        //adding new rule for the scalar, e.g. k_{i}*k^{i} = scalar2
                        tensorSubstitutions.put(scalar, generator.take());
                    }
                }
            }
        }

View Full Code Here

TOP

Related Classes of cc.redberry.core.tensorgenerator.SymbolsGenerator

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.