aboutsummaryrefslogtreecommitdiff
path: root/Tools/CodeGen
diff options
context:
space:
mode:
authorIan Hinder <ian.hinder@aei.mpg.de>2012-11-14 16:53:10 +0100
committerIan Hinder <ian.hinder@aei.mpg.de>2012-11-14 16:53:10 +0100
commit9ae63b43f28725cfb44cbc8120dd63a6509416d8 (patch)
tree92586dcde7558e4c019dbb8968db7ab6ca514204 /Tools/CodeGen
parent58eb73177f4ea930b8380772bd4c7fdaa663dc8f (diff)
TensorTools.m: Add a registration interface for derivative operators
It turns out that we need to know which symbols are going to be used as derivative operators so that we can expand contractions under them. A more general solution might have unintended consequences.
Diffstat (limited to 'Tools/CodeGen')
-rw-r--r--Tools/CodeGen/TensorTools.m8
1 files changed, 8 insertions, 0 deletions
diff --git a/Tools/CodeGen/TensorTools.m b/Tools/CodeGen/TensorTools.m
index 5aab9ed..ff49acf 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
-------------------------------------------------------------------------- *)