/** * 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)); }
public bool isMetric(SimpleTensor t) { return(nameManager.isKroneckerOrMetric(t.GetName()) && IndicesUtils.haveEqualStates(t.GetIndices()[0], t.GetIndices()[1])); }
/** * Returns {@code true} if specified tensor is a metric tensor * * @param t tensor * @return {@code true} if specified tensor is a metric tensor */ public bool IsMetric(SimpleTensor t) { return(nameManager.IsKroneckerOrMetric(t.Name) && IndicesUtils.haveEqualStates(t.Indices[0], t.Indices[1])); }