diff options
author | Ian Hinder <ian.hinder@aei.mpg.de> | 2013-09-09 14:45:17 +0200 |
---|---|---|
committer | Ian Hinder <ian.hinder@aei.mpg.de> | 2013-09-09 14:45:17 +0200 |
commit | aa0cbf94406f348a57f0a043425b0c12d2d2ec90 (patch) | |
tree | 71f9532f31080f50a6767e77b5c228e1dab4ba65 | |
parent | c6023379525bbefc5bcd29595c44e28aa708a17e (diff) |
TensorTools.m: Add ClearAllTensors
This is a very heavy-handed way of achieving this. We should change the way that tensors work at a more fundamental level, but this is enough for now.
-rw-r--r-- | Tools/CodeGen/TensorTools.m | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Tools/CodeGen/TensorTools.m b/Tools/CodeGen/TensorTools.m index 8002f01..0ba9a16 100644 --- a/Tools/CodeGen/TensorTools.m +++ b/Tools/CodeGen/TensorTools.m @@ -31,6 +31,8 @@ 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."; +ClearAllTensors; + MakeExplicit::usage = "MakeExplicit[x] converts an expression x \ containing abstract indices into one containing components \ instead."; @@ -1421,7 +1423,18 @@ HasTensorAttribute[k_, attr_] := IsTensor[k_] := ListQ[TensorAttributes[k]]; +ClearAllTensors[] := + (ClearAll[Tensor]; + ClearAll[TensorCharacter]; + ClearAll[TensorAttributes]); +UndefineTensor[Tensor[T,___]] := + Module[ + {}, + T[is:((TensorIndex[_,_] | _Integer) ..)] =.; + (* TODO: undefine the symmetries somehow *) + TensorCharacter[T] =.; + TensorAttributes[T] =.]; |