Package cc.redberry.core.context

Examples of cc.redberry.core.context.NameDescriptor


        for (int i = 0; i < namespace.length; ++i) {
            int[] typesCount = new int[IndexType.TYPES_COUNT];
            for (int j = 0; j < IndexType.TYPES_COUNT; ++j)
                typesCount[j] = minIndices[j] + nextInt(maxIndices[j] - minIndices[j]);
            IndicesTypeStructure typeStructure = new IndicesTypeStructure(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(IndicesTypeStructure 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();
        IndicesTypeStructure indicesTypeStructure = nd.getIndicesTypeStructure();
        int[] indices = nextIndices(indicesTypeStructure);
        return Tensors.simpleTensor(nd.getId(), IndicesFactory.createSimple(nd.getSymmetries(), indices));
    }
View Full Code Here

            throw new IllegalArgumentException();
        indices = indices.getFree();
        IndicesTypeStructure typeStructure = new IndicesTypeStructure(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) {
                IndicesTypeStructure.TypeData typeData = nd.getIndicesTypeStructure().getTypeData(b);
                if (typeData != null)
                    totalIndicesCounts[b] += typeData.length;
            }
        }

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

        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

     * @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.getIndicesTypeStructure());
        return new SimpleTensor(descriptor.getId(),
                                UnsafeIndicesFactory.createOfTensor(descriptor.getSymmetries(),
                                                                    indices));
    }
View Full Code Here

     * @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.getIndicesTypeStructure().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

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.