Esempio n. 1
0
        /**
         * Returns metric tensor with specified indices.
         *
         * @param index1 first index
         * @param index2 second index
         * @return metric tensor with specified indices
         * @throws IllegalArgumentException if indices have different states
         * @throws IllegalArgumentException if indices have different types
         * @throws IllegalArgumentException if indices have non metric types
         */
        public SimpleTensor CreateMetric(uint index1, uint index2)
        {
            byte type;

            if ((type = IndicesUtils.getType(index1)) != IndicesUtils.getType(index2) ||
                !IndicesUtils.haveEqualStates(index1, index2) ||
                !metricTypes.Get(type))
            {
                throw new ArgumentException("Not metric indices.");
            }
            var indices = IndicesFactory.createSimple(null, index1, index2);
            var nd      = nameManager.mapNameDescriptor(nameManager.GetMetricName(), new StructureOfIndices(indices));
            var name    = nd.Id;

            return(Tensor.SimpleTensor(name, indices));
        }
Esempio n. 2
0
        /**
         * Returns Kronecker tensor with specified upper and lower indices.
         *
         * @param index1 first index
         * @param index2 second index
         * @return Kronecker tensor with specified upper and lower indices
         * @throws IllegalArgumentException if indices have same states
         * @throws IllegalArgumentException if indices have different types
         */
        public SimpleTensor CreateKronecker(uint index1, uint index2)
        {
            byte type;

            if ((type = IndicesUtils.getType(index1)) != IndicesUtils.getType(index2) || IndicesUtils.getRawStateInt((uint)index1) == IndicesUtils.getRawStateInt((uint)index2))
            {
                throw new ArgumentException("This is not kronecker indices!");
            }

            if (!isMetric(type) && IndicesUtils.getState(index2))
            {
                var t = index1;
                index1 = index2;
                index2 = t;
            }

            ISimpleIndices indices = IndicesFactory.createSimple(null, index1, index2);
            var            nd      = nameManager.mapNameDescriptor(nameManager.getKroneckerName(), new StructureOfIndices(indices));
            var            name    = nd.Id;

            return(Tensor.SimpleTensor(name, indices));
        }