private void checkSpinorNotation(SimpleTensor spinor, boolean bar) { if (spinor == null) return; SimpleIndices m = spinor.getIndices().getOfType(matrixType); if (m.size() != 1 || bar == getState(m.get(0))) throw new IllegalArgumentException("Illegal notation for spinor " + spinor); }
/** * Returns whether specified tensor is matrix of specified type and with specified signature. * * @param tensor simple tensor * @param type type of matrix * @param upper number of upper matrix indices * @param lower number of lower matrix indices * @return true if specified tensor is matrix of specified type and with specified signature and false in other case */ public static boolean isGeneralizedMatrix(SimpleTensor tensor, IndexType type, int upper, int lower) { if (CC.isMetric(type)) throw new IllegalArgumentException("Matrices can not be of metric type."); SimpleIndices indices = tensor.getIndices().getOfType(type); int i = 0; for (; i < upper; ++i) if (!getState(indices.get(i))) return false; upper += lower; for (; i < upper; ++i) if (getState(indices.get(i))) return false; return true; }
public static String toString(int index, OutputFormat mode) { return (getState(index) ? "^" : "_") + Context.get().getIndexConverterManager().getSymbol(index, mode) + ""; }
private static String toStringIndex(int index, OutputFormat mode) { return (IndicesUtils.getState(index) ? "^" : "_") + Context.get().getIndexConverterManager().getSymbol(index, mode); }
protected static SimpleTensor setMatrixIndices(SimpleTensor gamma, int matrixUpper, int matrixLower) { int[] indices = gamma.getIndices().getAllIndices().copy(); for (int i = indices.length - 1; i >= 0; --i) if (!CC.isMetric(getType(indices[i]))) { indices[i] = getState(indices[i]) ? createIndex(matrixUpper, getType(indices[i]), getState(indices[i])) : createIndex(matrixLower, getType(indices[i]), getState(indices[i])); } return simpleTensor(gamma.getName(), IndicesFactory.createSimple(null, indices)); }
private static void checkIndices(SimpleIndices upper, SimpleIndices lower) { if (upper.size() != lower.size()) throw new IllegalArgumentException("Upper indices size not equal to lower indices size."); int size = upper.size(); for (int i = 0; i < size; ++i) { if (!IndicesUtils.getState(upper.get(i)) || IndicesUtils.getState(lower.get(i))) throw new IllegalArgumentException(); if (IndicesUtils.getType(upper.get(i)) != IndicesUtils.getType(lower.get(i))) throw new IllegalArgumentException(); if (i != 0) if (IndicesUtils.getType(upper.get(i - 1)) != IndicesUtils.getType(upper.get(i))) throw new IllegalArgumentException("Many types."); } }
/** * @param indices sorted by type array of indices */ StructureOfIndices(int[] indices) { size = indices.length; int i; for (i = 0; i < size; ++i) ++typesCounts[IndicesUtils.getType(indices[i])]; int[] pointers = new int[IndexType.TYPES_COUNT]; for (i = 0; i < IndexType.TYPES_COUNT; ++i) if (!CC.isMetric((byte) i)) states[i] = createBBBA(typesCounts[i]); else pointers[i] = -1; byte type; for (i = 0; i < size; ++i) { type = IndicesUtils.getType(indices[i]); if (pointers[type] != -1) { if (IndicesUtils.getState(indices[i])) states[type].set(pointers[type]); ++pointers[type]; } } }
for (int i = si.size() - 1; i >= 0; --i) { usedTypes.add(getTypeEnum(si.get(i))); free[i] = createIndex(i, getType(si.get(i)), getState(si.get(i)));
/** * 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); }
/** * Returns the structure of specified simple indices. * * @param indices simple indices */ private StructureOfIndices(SimpleIndices indices) { size = indices.size(); int i; for (i = 0; i < size; ++i) ++typesCounts[IndicesUtils.getType(indices.get(i))]; int[] pointers = new int[IndexType.TYPES_COUNT]; for (i = 0; i < IndexType.TYPES_COUNT; ++i) if (!CC.isMetric((byte) i)) states[i] = createBBBA(typesCounts[i]); else pointers[i] = -1; byte type; for (i = 0; i < size; ++i) { type = IndicesUtils.getType(indices.get(i)); if (pointers[type] != -1) { if (IndicesUtils.getState(indices.get(i))) states[type].set(pointers[type]); ++pointers[type]; } } }
to.add(newIndex); kroneckers.add(Tensors.createKronecker(index, inverseIndexState(newIndex))); } else if (IndicesUtils.getState(index) && dummies.contains(getNameWithType(index))) { newIndex = setRawState(getRawStateInt(index), generator.generate(getType(index))); from.add(index);