/** * Returns {@code true} if specified tensor is metric tensor * * @param t tensor * @return {@code true} if specified tensor is metric tensor */ public static boolean isMetric(Tensor t) { if (!(t instanceof SimpleTensor)) return false; return CC.current().isMetric((SimpleTensor) t); }
/** * Returns true if metric is defined for specified index type. * * @param type index type * @return true if metric is defined for specified index type */ public static boolean isMetric(byte type) { return current().isMetric(type); }
/** * Returns true if metric is defined for specified index type. * * @param type index type * @return true if metric is defined for specified index type */ public static boolean isMetric(IndexType type) { return current().isMetric(type.getType()); }
/** * 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(int index1, int index2) { byte type; if ((type = IndicesUtils.getType(index1)) != IndicesUtils.getType(index2) || IndicesUtils.getRawStateInt(index1) == IndicesUtils.getRawStateInt(index2)) throw new IllegalArgumentException("This is not kronecker indices!"); if (!isMetric(type) && IndicesUtils.getState(index2)) { int t = index1; index1 = index2; index2 = t; } SimpleIndices indices = IndicesFactory.createSimple(null, index1, index2); NameDescriptor nd = nameManager.mapNameDescriptor(nameManager.getKroneckerName(), StructureOfIndices.create(indices)); int name = nd.getId(); return Tensors.simpleTensor(name, indices); }