protected static void checkNotation(SimpleTensor gammaMatrix) { final IndexType[] types = TraceUtils.extractTypesFromMatrix(gammaMatrix); IndexType metricType = types[0]; IndexType matrixType = types[1]; if (gammaMatrix.getIndices().size() != 3 || gammaMatrix.getIndices().size(metricType) != 1 || gammaMatrix.getIndices().size(matrixType) != 2) throw new IllegalArgumentException("Not a gamma: " + gammaMatrix); }
private static void check(IndexType type, SimpleTensor momentum) { if (momentum.getIndices().size() != 1) throw new IllegalArgumentException("Not a momentum: " + momentum); if (type != null && type != getTypeEnum(momentum.getIndices().get(0))) throw new IllegalArgumentException("Not a momentum: " + momentum + " wrong index type"); }
public SqrSubs(SimpleTensor st) { if (st.getIndices().size() != 1) throw new IllegalArgumentException(); name = st.getName(); }
/** * Attaches symmetry to simple tensor. * * @param tensor simple tensor * @param permutation permutation * @throws java.lang.IllegalStateException if this tensor is already in use (it's permutation group calculated) * @throws java.lang.IllegalArgumentException if degree of specified permutation differs from the size of indices * of specified tensor */ public static void addSymmetry(SimpleTensor tensor, Permutation permutation) { tensor.getIndices().getSymmetries().addSymmetry(permutation); }
/** * Makes simple tensor antisymmetric. * * @param tensor simple tensor * @throws java.lang.IllegalStateException if this tensor is already in use (it's permutation group calculated) */ public static void setAntiSymmetric(SimpleTensor tensor) { tensor.getIndices().getSymmetries().setAntiSymmetric(); }
/** * Makes simple tensor symmetric. * * @param tensor simple tensor * @throws java.lang.IllegalStateException if this tensor is already in use (it's permutation group calculated) */ public static void setSymmetric(SimpleTensor tensor) { tensor.getIndices().getSymmetries().setSymmetric(); }
private SimpleTensor setMatrixIndices0(SimpleTensor tensor, int... indices) { int[] newIndices = new int[tensor.getIndices().size()]; int j = 0; for (int i = 0; i < tensor.getIndices().size(); ++i) if (getType(tensor.getIndices().get(i)) == matrixType.getType()) newIndices[i] = indices[j++]; else newIndices[i] = tensor.getIndices().get(i); return setIndices(tensor, createSimple(null, newIndices)); }
/** * Makes simple tensor symmetric with respect to indices of specified type. * * @param tensor simple tensor * @param type type of indices * @throws java.lang.IllegalStateException if this tensor is already in use (it's permutation group calculated) */ public static void setSymmetric(SimpleTensor tensor, IndexType type) { int dimension = tensor.getIndices().size(type); tensor.getIndices().getSymmetries().addSymmetry(type, Permutations.createCycle(dimension)); tensor.getIndices().getSymmetries().addSymmetry(type, Permutations.createTransposition(dimension)); }
/** * Returns {@code true} if specified tensor is a metric tensor * * @param t tensor * @return {@code true} if specified tensor is a metric tensor */ public boolean isMetric(SimpleTensor t) { return nameManager.isKroneckerOrMetric(t.getName()) && IndicesUtils.haveEqualStates(t.getIndices().get(0), t.getIndices().get(1)); }
/** * Returns {@code true} if specified tensor is a Kronecker tensor * * @param t tensor * @return {@code true} if specified tensor is a Kronecker tensor */ public boolean isKronecker(SimpleTensor t) { return nameManager.isKroneckerOrMetric(t.getName()) && !IndicesUtils.haveEqualStates(t.getIndices().get(0), t.getIndices().get(1)); }
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); }
private static SimpleTensorDifferentiationRule createRule(SimpleTensor var, boolean useDeltaFunction) { if (var.getIndices().size() == 0) return new SymbolicDifferentiationRule(var, useDeltaFunction); return new SymmetricDifferentiationRule(var, useDeltaFunction); }
private static void checkLeviCivita(SimpleTensor LeviCivita) { SimpleIndices indices = LeviCivita.getIndices(); if (indices.size() <= 1) throw new IllegalArgumentException("Levi-Civita cannot be a scalar."); byte type = getType(indices.get(0)); for (int i = 1; i < indices.size(); ++i) if (type != getType(indices.get(i))) throw new IllegalArgumentException("Levi-Civita have indices with different types."); } }
private static void check(SimpleTensor loopMomentum, SimpleTensor[] externalMomentums) { check(null, loopMomentum); IndexType type = getTypeEnum(loopMomentum.getIndices().get(0)); for (SimpleTensor externalMomentum : externalMomentums) check(type, externalMomentum); }
@Override Tensor differentiateSimpleTensorWithoutCheck(SimpleTensor simpleTensor) { int[] to = simpleTensor.getIndices().getAllIndices().copy(); to = addAll(to, freeVarIndices); return applyIndexMapping(derivative, new Mapping(allFreeFrom, to), new int[0]); }
protected static SimpleTensor setMetricIndex(SimpleTensor gamma, int metricIndex) { int[] indices = gamma.getIndices().getAllIndices().copy(); for (int i = indices.length - 1; i >= 0; --i) if (CC.isMetric(getType(indices[i]))) indices[i] = metricIndex; return simpleTensor(gamma.getName(), IndicesFactory.createSimple(null, 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)); }
private Expression createBarSubs(SimpleTensor spinor, boolean negate) { if (spinor == null) return null; int dummy = spinor.getIndices().get(matrixType, 0), free = dummy + 1; SimpleTensor gamma = simpleTensor(gammaName, createSimple(null, setState(true, dummy), free, setType(metricType, 0))); SimpleTensor mom = setIndices(momentum, createSimple(null, setState(true, setType(metricType, 0)))); SimpleTensor rhs = setMatrixIndices0(spinor, free); return expression(multiply(spinor, gamma, mom), negate ? negate(multiply(mass, rhs)) : multiply(mass, rhs)); }
private Expression createSubs(SimpleTensor spinor, boolean negate) { if (spinor == null) return null; int dummy = setState(false, spinor.getIndices().get(matrixType, 0)), free = setState(true, dummy + 1); SimpleTensor gamma = simpleTensor(gammaName, createSimple(null, free, dummy, setType(metricType, 0))); SimpleTensor mom = setIndices(momentum, createSimple(null, setState(true, setType(metricType, 0)))); SimpleTensor rhs = setMatrixIndices0(spinor, free); return expression(multiply(spinor, gamma, mom), negate ? negate(multiply(mass, rhs)) : multiply(mass, rhs)); }
private Expression[] createOrtIdentities(SimpleTensor bar, SimpleTensor spinor) { if (bar == null || spinor == null) return null; int dummy = setState(false, bar.getIndices().get(matrixType, 0)); Tensor lhs0 = multiply(setMatrixIndices0(bar, dummy), setMatrixIndices0(spinor, inverseIndexState(dummy))); Tensor lhs1 = multiply( setMatrixIndices0(bar, dummy), simpleTensor(gammaName, createSimple(null, inverseIndexState(dummy), dummy + 1, setType(metricType, 0))), setIndices(momentum, createSimple(null, setState(true, setType(metricType, 0)))), setMatrixIndices0(spinor, inverseIndexState(dummy + 1))); return new Expression[]{expression(lhs0, Complex.ZERO), expression(lhs1, Complex.ZERO)}; }