From 9ae63b43f28725cfb44cbc8120dd63a6509416d8 Mon Sep 17 00:00:00 2001 From: Ian Hinder Date: Wed, 14 Nov 2012 16:53:10 +0100 Subject: 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. --- Tools/CodeGen/TensorTools.m | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'Tools/CodeGen') 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 -------------------------------------------------------------------------- *) -- cgit v1.2.3