Package gnu.trove.set.hash

Examples of gnu.trove.set.hash.TIntHashSet


    public static Tensor expandPower(Sum argument, int power, int[] forbiddenIndices, Transformation[] transformations) {
        //TODO improve algorithm using Newton formula!!!
        int i;
        Tensor temp = argument;
        TIntHashSet forbidden = new TIntHashSet(forbiddenIndices);
        TIntHashSet argIndices = TensorUtils.getAllIndicesNamesT(argument);
        forbidden.ensureCapacity(argIndices.size() * power);
        forbidden.addAll(argIndices);
        for (i = power - 1; i >= 1; --i)
            temp = expandPairOfSums((Sum) temp,
                    (Sum) ApplyIndexMapping.renameDummy(argument, forbidden.toArray(), forbidden),
                    transformations);
View Full Code Here


        final int exponent = ((Complex) power.get(1)).intValue();
        final Tensor[] scalars = ((Product) power.get(0)).getAllScalars();
        ArrayList<Tensor> factorOut = new ArrayList<>(scalars.length),
                leave = new ArrayList<>(scalars.length);

        TIntHashSet allForbidden = new TIntHashSet(forbiddenIndices);
        int j;
        Tensor temp;
        for (int i = 0; i < scalars.length; ++i) {
            if (indicator.is(scalars[i])) {
                if (scalars[i] instanceof SimpleTensor)   //simple symbolic factor
                    factorOut.add(Tensors.pow(scalars[i], exponent));
                else
                    for (j = 0; j < exponent; ++j) {
                        temp = ApplyIndexMapping.renameDummy(scalars[i], allForbidden.toArray());
                        allForbidden.addAll(TensorUtils.getAllIndicesNamesT(temp));
                        factorOut.add(temp);
                    }
            } else leave.add(scalars[i]);
        }
View Full Code Here

                indicesSpace[b][i + diff] = IndicesUtils.inverseIndexState(indicesSpace[b][i]);
            System.arraycopy(freeIndices[b], 0, indicesSpace[b], diff * 2, freeIndices[b].length);
            shuffle(indicesSpace[b]);
        }

        TIntHashSet forbidden = new TIntHashSet();
        for (int[] sp : indicesSpace) {
            forbidden.ensureCapacity(sp.length);
            forbidden.addAll(IndicesUtils.getIndicesNames(sp));
        }

        //Creating resulting product
        ProductBuilder pb = new ProductBuilder(10, avrProductSize);
        for (Tensor descriptor : descriptors) {
            StructureOfIndices its = IndicesFactory.createSimple(null, descriptor.getIndices().getFree()).getStructureOfIndices();
            int[] factorIndices = new int[its.size()];
            int position = 0;
            for (byte b : TYPES) {
                StructureOfIndices.TypeData typeData = its.getTypeData(b);
                if (typeData == null)
                    continue;
                for (i = 0; i < typeData.length; ++i)
                    factorIndices[position++] = indicesSpace[b][--totalIndicesCounts[b]];
            }

            descriptor = ApplyIndexMapping.applyIndexMapping(descriptor,
                    new Mapping(descriptor.getIndices().getFree().getAllIndices().copy(), factorIndices), forbidden.toArray());
            descriptor = ApplyIndexMapping.renameDummy(descriptor, forbidden.toArray());
            forbidden.addAll(TensorUtils.getAllIndicesNamesT(descriptor));

            pb.put(descriptor);
        }


View Full Code Here

        this.builder = builder;
        this.factorForbiddenIndices = factorForbiddenIndices;
    }

    void put(Tensor summand, Tensor factor) {
        TIntHashSet allowed = TensorUtils.getAllDummyIndicesT(factor);
        allowed.removeAll(factorForbiddenIndices);
        //old variant
        //IndexGenerator ig = new IndexGeneratorFromData(TensorUtils.getAllDummyIndicesT(factor).toArray());
        summand = ApplyIndexMapping.renameDummy(summand, factorForbiddenIndices, allowed.toArray());
        builder.put(summand);
    }
View Full Code Here

        if (forbiddenNames.length == 0)
            return tensor;
        if (tensor instanceof Complex || tensor instanceof ScalarFunction)
            return tensor;

        TIntHashSet allIndicesNames = TensorUtils.getAllDummyIndicesT(tensor);
        //no indices in tensor
        if (allIndicesNames.isEmpty())
            return tensor;

        allIndicesNames.ensureCapacity(forbiddenNames.length);

        IntArrayList fromL = null;
        for (int forbidden : forbiddenNames) {
            if (!allIndicesNames.add(forbidden)) {
                if (fromL == null)
                    fromL = new IntArrayList();
                fromL.add(forbidden);
            }
        }

        if (fromL == null)
            return tensor;

        allIndicesNames.addAll(getIndicesNames(tensor.getIndices().getFree()));
        int[] from = fromL.toArray(), to = new int[fromL.size()];
        Arrays.sort(from);
        int i;
        IndexGeneratorFromData generator = new IndexGeneratorFromData(allowedDummiesNames);
        for (i = from.length - 1; i >= 0; --i)
View Full Code Here

        if (forbiddenNames.length == 0)
            return tensor;
        if (tensor instanceof Complex || tensor instanceof ScalarFunction)
            return tensor;

        TIntHashSet allIndicesNames = TensorUtils.getAllDummyIndicesT(tensor);
        //no indices in tensor
        if (allIndicesNames.isEmpty())
            return tensor;

        allIndicesNames.ensureCapacity(forbiddenNames.length);

        IntArrayList fromL = null;
        for (int forbidden : forbiddenNames) {
            if (!allIndicesNames.add(forbidden)) {
                if (fromL == null)
                    fromL = new IntArrayList();
                fromL.add(forbidden);
            }
        }

        if (fromL == null)
            return tensor;

        allIndicesNames.addAll(getIndicesNames(tensor.getIndices().getFree()));
        IndexGeneratorImpl generator = new IndexGeneratorImpl(allIndicesNames.toArray());
        int[] from = fromL.toArray(), to = new int[fromL.size()];
        Arrays.sort(from);
        added.ensureCapacity(from.length);
        int i;
        for (i = from.length - 1; i >= 0; --i)
View Full Code Here

            zeroReduced[i] = ExpandTransformation.expand(zeroReduced[i],
                    EliminateMetricsTransformation.ELIMINATE_METRICS);
            zeroReduced[i] = EliminateMetricsTransformation.eliminate(zeroReduced[i]);
        }

        TIntHashSet varsNames = new TIntHashSet(vars.length);
        for (SimpleTensor var : vars)
            varsNames.add(var.getName());
        Tensor[] samples = getSamples(zeroReduced, varsNames);
        if (samples.length == 0)
            for (int i = 0; i < vars.length; ++i)
                if (vars[i].getIndices().size() != 0)
                    return null;
View Full Code Here

                if (!(pn instanceof ParseTokenScalarFunction))
                    getAllIndices1(pn, set);
    }

    public static TIntSet getAllIndicesT(ParseToken node) {
        TIntSet set = new TIntHashSet();
        getAllIndicesT1(node, set);
        return set;
    }
View Full Code Here

        if (tensor instanceof Complex)
            return setComplex(i, (Complex) tensor);

        int size = size(), j;
        if (TensorUtils.passOutDummies(tensor)) {
            TIntHashSet forbidden = new TIntHashSet();
            for (j = 0; j < size; ++j)
                if (j != i)
                    TensorUtils.appendAllIndicesNamesT(get(j), forbidden);
            tensor = ApplyIndexMapping.renameDummy(tensor, forbidden.toArray());
        }

        Boolean compare = TensorUtils.compare1(old, tensor);
        if (compare == null)
            return super.set(i, tensor);
View Full Code Here

    public static TIntHashSet getAllDummyIndicesIncludingScalarFunctionsT(Tensor tensor) {
        return getAllDummyIndicesT(true, tensor);
    }

    private static TIntHashSet getAllDummyIndicesT(boolean includeScalarFunctions, Tensor tensor) {
        TIntHashSet set = new TIntHashSet();
        appendAllIndicesNamesT(tensor, set, includeScalarFunctions);
        set.removeAll(IndicesUtils.getIndicesNames(tensor.getIndices().getFree()));
        return set;
    }
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.