Package cc.redberry.core.context

Examples of cc.redberry.core.context.NameDescriptor


        for (int i = 0; i < namespace.length; ++i) {
            int[] typesCount = new int[TYPES_COUNT];
            for (int j = 0; j < TYPES_COUNT; ++j)
                typesCount[j] = minIndices[j] + nextInt(maxIndices[j] - minIndices[j]);
            StructureOfIndices typeStructure = new StructureOfIndices(TYPES, typesCount);
            NameDescriptor nameDescriptor = CC.getNameManager().mapNameDescriptor(nextName(), typeStructure);
            if (withSymmetries)
                addRandomSymmetries(nameDescriptor);
            namespace[i] = nameDescriptor;
        }
    }
View Full Code Here


    public NameDescriptor nextNameDescriptor() {
        return namespace[nextInt(namespace.length)];
    }

    private NameDescriptor nextNameDescriptor(StructureOfIndices typeStructure) {
        NameDescriptor nameDescriptor = CC.getNameManager().mapNameDescriptor(nextName(), typeStructure);
        if (withSymmetries)
            addRandomSymmetries(nameDescriptor);
        return nameDescriptor;
    }
View Full Code Here

                descriptor.getSymmetries().addUnsafe(type, new Symmetry(nextPermutation(typeData.length), false));
        }
    }

    public SimpleTensor nextSimpleTensor() {
        NameDescriptor nd = nextNameDescriptor();
        StructureOfIndices structureOfIndices = nd.getStructureOfIndices();
        int[] indices = nextIndices(structureOfIndices);
        return Tensors.simpleTensor(nd.getId(), IndicesFactory.createSimple(nd.getSymmetries(), indices));
    }
View Full Code Here

            throw new IllegalArgumentException();
        indices = indices.getFree();
        StructureOfIndices typeStructure = new StructureOfIndices(IndicesFactory.createSimple(null, indices));
        List<NameDescriptor> descriptors = new ArrayList<>();
        int totalIndicesCounts[] = new int[TYPES.length];
        NameDescriptor nd;
        int i;
        for (i = 0; i < minProductSize; ++i) {
            descriptors.add(nd = nextNameDescriptor());
            for (byte b : TYPES) {
                StructureOfIndices.TypeData typeData = nd.getStructureOfIndices().getTypeData(b);
                if (typeData != null)
                    totalIndicesCounts[b] += typeData.length;
            }
        }

        //if tensors are not not enough (product.indices.size < freeIndices.size)
        for (byte b : TYPES) {
            StructureOfIndices.TypeData typeData = typeStructure.getTypeData(b);
            if (typeData == null)
                continue;
            while (totalIndicesCounts[b] < typeData.length) {
                descriptors.add(nd = nextNameDescriptor());
                for (byte bb : TYPES) {
                    StructureOfIndices.TypeData typeData1 = nd.getStructureOfIndices().getTypeData(bb);
                    if (typeData1 != null)
                        totalIndicesCounts[bb] += typeData1.length;
                }
            }
        }
View Full Code Here

        int i;
        for (i = 0; i < actualInput; ++i) {
            if (!(inputValues[i].get(0) instanceof SimpleTensor))
                throw new IllegalArgumentException();
            SimpleTensor st = (SimpleTensor) inputValues[i].get(0);
            NameDescriptor nd = CC.getNameDescriptor(st.getName());
            if (!nd.getName(null).equals(getStringInputName(i)))
                throw new IllegalArgumentException();
        }
        for (; i < INPUT_VALUES_GENERAL_COUNT; ++i)
            if (inputValues[i] != null)
                throw new IllegalArgumentException();
View Full Code Here

*/
final class TraceUtils {
    static final IndexType[] extractTypesFromMatrix(SimpleTensor matrix) {
        if (matrix.getIndices().size() != 3)
            throw new IllegalArgumentException("Not a matrix: " + matrix + ".");
        NameDescriptor descriptor = CC.getNameDescriptor(matrix.getName());
        StructureOfIndices typeStructure = descriptor.getStructureOfIndices();
        byte metricType = -1, matrixType = -1;
        int typeCount;
        for (byte type = 0; type < IndexType.TYPES_COUNT; ++type) {
            typeCount = typeStructure.typeCount(type);
            if (typeCount == 0)
View Full Code Here

        int i;
        for (i = 0; i < actualInput; ++i) {
            if (!(inputValues[i].get(0) instanceof SimpleTensor))
                throw new IllegalArgumentException();
            SimpleTensor st = (SimpleTensor) inputValues[i].get(0);
            NameDescriptor nd = CC.getNameDescriptor(st.getName());
            if (!nd.getName(null).equals(getStringInputName(i)))
                throw new IllegalArgumentException();
        }
        for (; i < INPUT_VALUES_GENERAL_COUNT; ++i)
            if (inputValues[i] != null)
                throw new IllegalArgumentException();
View Full Code Here

     * @param name    string name of the tensor
     * @param indices indices
     * @return new instance of {@link SimpleTensor} object
     */
    public static SimpleTensor simpleTensor(String name, SimpleIndices indices) {
        NameDescriptor descriptor = CC.getNameManager().mapNameDescriptor(name, indices.getStructureOfIndices());
        return new SimpleTensor(descriptor.getId(),
                UnsafeIndicesFactory.createOfTensor(descriptor.getSymmetries(),
                        indices));
    }
View Full Code Here

     * @param name    int name of the tensor
     * @param indices indices
     * @return new instance of {@link SimpleTensor} object
     */
    public static SimpleTensor simpleTensor(int name, SimpleIndices indices) {
        NameDescriptor descriptor = CC.getNameDescriptor(name);
        if (descriptor == null)
            throw new IllegalArgumentException("This name is not registered in the system.");
        if (!descriptor.getStructureOfIndices().isStructureOf(indices))
            throw new IllegalArgumentException("Specified indices are not indices of specified tensor.");
        return new SimpleTensor(name,
                UnsafeIndicesFactory.createOfTensor(descriptor.getSymmetries(),
                        indices));
    }
View Full Code Here

        StructureOfIndices[] structures = new StructureOfIndices[argIndices.length + 1];
        structures[0] = indices.getStructureOfIndices();
        for (int i = 0; i < argIndices.length; ++i)
            structures[i + 1] = argIndices[i].getStructureOfIndices();
        NameDescriptor descriptor = CC.getNameManager().mapNameDescriptor(name, structures);
        return new TensorField(descriptor.getId(),
                UnsafeIndicesFactory.createOfTensor(descriptor.getSymmetries(), indices),
                arguments, argIndices);
    }
View Full Code Here

TOP

Related Classes of cc.redberry.core.context.NameDescriptor

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.