Exemple #1
0
 /**
  * Returns metric tensor if specified indices have same states and
  * Kronecker tensor if specified indices have different states.
  *
  * @param index1 first index
  * @param index2 second index
  * @return metric tensor if specified indices have same states and
  *         Kronecker tensor if specified indices have different states
  * @throws IllegalArgumentException if indices have different types
  * @throws IllegalArgumentException if indices have same states and non metric types
  */
 public SimpleTensor CreateMetricOrKronecker(uint index1, uint index2)
 {
     if (IndicesUtils.getRawStateInt(index1) == IndicesUtils.getRawStateInt(index2))
     {
         return(createMetric(index1, index2));
     }
     return(createKronecker(index1, index2));
 }
Exemple #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));
        }