aboutsummaryrefslogtreecommitdiff
path: root/Tools/CodeGen/TensorTools.m
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/CodeGen/TensorTools.m')
-rw-r--r--Tools/CodeGen/TensorTools.m12
1 files changed, 11 insertions, 1 deletions
diff --git a/Tools/CodeGen/TensorTools.m b/Tools/CodeGen/TensorTools.m
index 10c6397..dc6f152 100644
--- a/Tools/CodeGen/TensorTools.m
+++ b/Tools/CodeGen/TensorTools.m
@@ -29,6 +29,7 @@ BeginPackage["TensorTools`", {"Errors`", "MapLookup`", "Kranc`"}];
DefineTensor::usage = "DefineTensor[kernel] registers kernel as a \
TensorTools tensor kernel.";
+DefineDerivative::usage = "DefineDerivative[pd] registers a symbol to be used as a derivative operator.";
MakeExplicit::usage = "MakeExplicit[x] converts an expression x \
containing abstract indices into one containing components \
@@ -145,6 +146,8 @@ replaceConflicting;
(* This is for compatibility with MathTensor notation *)
(*OD = PD;*)
+$Derivatives;
+
Begin["`Private`"];
listOfTensors = {};
@@ -154,6 +157,8 @@ upper = "u";
lower = "l";
delta = \[Delta]
+If[!ValueQ[$Derivatives], $Derivatives = {PD}];
+
SwapIndices[x_, i1_, i2_] :=
Module[{temp, unique},
u = Unique[];
@@ -280,6 +285,9 @@ DefineTensor[T_] :=
TensorAttributes[T] = {TensorWeight -> 0, Symmetries -> {}};
T];
+DefineDerivative[pd_Symbol] :=
+ If[!DerivativeOperatorQ[pd], AppendTo[$Derivatives, pd]];
+
(* --------------------------------------------------------------------------
Index manipulation
-------------------------------------------------------------------------- *)
@@ -549,7 +557,9 @@ listComponentsOfDummyIndex[x_, i:(TensorIndex[_,lower])] :=
contractions of tensorial expressions.
*)
-makeSum[x : PD[Tensor[_, __TensorIndex], __TensorIndex]] :=
+DerivativeOperatorQ[pd_] := MemberQ[$Derivatives, pd];
+
+makeSum[x : (pd_?DerivativeOperatorQ)[Tensor[_, __TensorIndex], __TensorIndex]] :=
makeSumOverDummies[x];
makeSum[f_[x___]] :=