Package gnu.trove.set.hash

Examples of gnu.trove.set.hash.TIntHashSet


        set.removeAll(IndicesUtils.getIndicesNames(tensor.getIndices().getFree()));
        return set;
    }

    public static TIntHashSet getAllIndicesNamesT(Collection<? extends Tensor> tensors) {
        TIntHashSet set = new TIntHashSet();
        for (Tensor tensor : tensors)
            appendAllIndicesNamesT(tensor, set);
        return set;
    }
View Full Code Here


            appendAllIndicesNamesT(tensor, set);
        return set;
    }

    public static TIntHashSet getAllIndicesNamesT(Tensor... tensors) {
        TIntHashSet set = new TIntHashSet();
        for (Tensor tensor : tensors)
            appendAllIndicesNamesT(tensor, set, false);
        return set;
    }
View Full Code Here

    public static Boolean compare1(Tensor u, Tensor v) {
        return IndexMappings.compare1(u, v);
    }

    public static void assertIndicesConsistency(Tensor t) {
        assertIndicesConsistency(t, new TIntHashSet());
    }
View Full Code Here

        }
        if (t instanceof Product)
            for (int i = t.size() - 1; i >= 0; --i)
                assertIndicesConsistency(t.get(i), indices);
        if (t instanceof Sum) {
            TIntHashSet sumIndices = new TIntHashSet(), temp;
            for (int i = t.size() - 1; i >= 0; --i) {
                temp = new TIntHashSet(indices);
                assertIndicesConsistency(t.get(i), temp);
                appendAllIndicesT(t.get(i), sumIndices);
            }
            indices.addAll(sumIndices);
        }
        if (t instanceof Expression)//FUTURE incorporate expression correctly
            for (Tensor c : t)
                assertIndicesConsistency(c, new TIntHashSet(indices));
    }
View Full Code Here

                addAllDiffSimpleTensors(t, names);
    }


    public static TIntHashSet getAllNamesOfSymbols(Tensor... tensors) {
        TIntHashSet set = new TIntHashSet();
        for (Tensor tensor : tensors)
            addSymbolsNames(tensor, set);
        return set;
    }
View Full Code Here

        }
        return false;
    }

    public static TIntHashSet getSimpleTensorsNames(Tensor t) {
        return addSimpleTensorsNames(t, new TIntHashSet());
    }
View Full Code Here

     * @param factors tensors
     * @return the array of tensors with renamed dummy indices
     */
    public static Tensor[] resolveDummy(Tensor[] factors) {
        Tensor[] result = new Tensor[factors.length];
        TIntHashSet forbidden = new TIntHashSet();
        ArrayList<Tensor> toResolve = new ArrayList<>();
        //int position = -1;
        int i;
        Tensor f;
        for (i = factors.length - 1; i >= 0; --i) {
            if ((f = factors[i]) instanceof Sum || f.getIndices().getFree().size() == 0) {
                toResolve.add(f);
                forbidden.addAll(f.getIndices().getFree().getAllIndices().copy());
            } else {
                forbidden.addAll(TensorUtils.getAllIndicesNamesT(f));
                result[i] = f;
            }
        }

        Tensor factor, newFactor;
        int toResolvePosition = toResolve.size();
        for (i = factors.length - 1; i >= 0; --i)
            if (result[i] == null) {
                factor = toResolve.get(--toResolvePosition);
                newFactor = ApplyIndexMapping.renameDummy(factor, forbidden.toArray());
                forbidden.addAll(TensorUtils.getAllIndicesNamesT(newFactor));
                result[i] = newFactor;
            }
//        for (int i = toResolve.size() - 1; i >= 0; --i) {
//            factor = toResolve.get(i);
//            newFactor = ApplyIndexMapping.renameDummy(factor, forbidden.toArray());
View Full Code Here

//        }
        return result;
    }

    public static void resolveAllDummies(Tensor[] factors) {
        TIntHashSet forbidden = new TIntHashSet();
        int i;
        for (i = factors.length - 1; i >= 0; --i)
            forbidden.addAll(TensorUtils.getAllIndicesNamesT(factors[i]));

        for (i = factors.length - 1; i >= 0; --i) {
            factors[i] = ApplyIndexMapping.renameDummy(factors[i], forbidden.toArray());
            forbidden.addAll(TensorUtils.getAllIndicesNamesT(factors[i]));
        }
    }
View Full Code Here

                break;
            }

        SimpleTensor[] resolvedVars = vars;
        if (needRename) {
            TIntHashSet forbidden = TensorUtils.getAllIndicesNamesT(tensor);
            for (SimpleTensor var : vars)
                forbidden.addAll(getIndicesNames(var.getIndices().getFree()));

            resolvedVars = vars.clone();
            for (int i = 0; i < vars.length; ++i)
                if (!forbidden.isEmpty() && resolvedVars[i].getIndices().size() != 0) {
                    if (resolvedVars[i].getIndices().size() != resolvedVars[i].getIndices().getFree().size())
                        resolvedVars[i] = (SimpleTensor) renameDummy(resolvedVars[i], forbidden.toArray());
                    forbidden.addAll(getIndicesNames(resolvedVars[i].getIndices()));
                }
            tensor = renameDummy(tensor, TensorUtils.getAllIndicesNamesT(resolvedVars).toArray(), forbidden);
            tensor = renameIndicesOfFieldsArguments(tensor, forbidden);
        }
View Full Code Here

        return tensor;
    }

    private static Tensor differentiate(Tensor tensor, Transformation[] expandAndContract, SimpleTensor var) {
        if (var.getIndices().size() != 0) {
            TIntHashSet forbidden = TensorUtils.getAllIndicesNamesT(tensor);
            var = (SimpleTensor) renameDummy(var, TensorUtils.getAllIndicesNamesT(tensor).toArray());
            forbidden.addAll(IndicesUtils.getIndicesNames(var.getIndices()));
            tensor = renameDummy(tensor, TensorUtils.getAllIndicesNamesT(var).toArray(), forbidden);
            tensor = renameIndicesOfFieldsArguments(tensor, forbidden);
        }
        return differentiate1(tensor, createRule(var), expandAndContract);
    }
View Full Code Here

TOP

Related Classes of gnu.trove.set.hash.TIntHashSet

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.