/** * Creates single index with specified name, type and state. * * @param name index name * @param type index type * @param state index state * @return index */ public static int createIndex(int name, IndexType type, boolean state) { return createIndex(name, type.getType(), state); }
public int[] nextIndices(StructureOfIndices structureOfIndices) { int[] indices = new int[structureOfIndices.size()]; int[] typeInd; int p = 0; for (byte b : TYPES) { StructureOfIndices.TypeData typeData = structureOfIndices.getTypeData(b); if (typeData == null || typeData.length == 0) continue; typeInd = new int[typeData.length]; if (typeData.states != null) { //in the case of matrix indices int[] names = nextPermutation(typeInd.length); for (int i = 0; i < typeInd.length; ++i) typeInd[i] = IndicesUtils.createIndex(names[i], b, typeData.states.get(i)); } else { int i; int contracted = (contracted = nextInt(indices.length / 2)) == 0 ? 1 : contracted; for (i = 0; i < typeInd.length / contracted; ++i) typeInd[i] = IndicesUtils.setType(b, i); if (i - contracted < 0) contracted = i; for (; i < typeInd.length; ++i) typeInd[i] = IndicesUtils.createIndex(i - contracted, b, true); shuffle(typeInd); } System.arraycopy(typeInd, 0, indices, p, typeInd.length); p += typeInd.length; } return indices; }
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)); }
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)));
Arrays.fill(temp, 0xFFFFFFFF); for (int j = combination.length - 1; j >= 0; --j) temp[combination[j]] = createIndex(j, getType(metricInds[combination[j]]), true);//raise index int counter = combination.length; for (int j = 0; j < metricInds.length; ++j) if (temp[j] == 0xFFFFFFFF) temp[j] = createIndex(counter++, getType(metricInds[j]), false);//lower index IntArrayList _result = nonMetricIndices.clone(); _result.addAll(temp);
int i, j, k; for (i = 0; i < operatorOrder; ++i) covariantIndices[i] = IndicesUtils.createIndex(i, IndexType.LatinLower, true); upper[i - operatorOrder] = IndicesUtils.createIndex(i, IndexType.LatinLower, true); lower[i - operatorOrder] = IndicesUtils.createIndex(i + matrixIndicesCount / 2, IndexType.LatinLower, false);
upper[i] = IndicesUtils.createIndex(130 + i, IndexType.LatinLower, true);//30 lower[i] = IndicesUtils.createIndex(130 + i + matrixIndicesCount / 2, IndexType.LatinLower, false);