Skip to content

Commit

Permalink
Add support for tensor atributes
Browse files Browse the repository at this point in the history
  • Loading branch information
barrywardell committed Mar 10, 2014
1 parent b3afe26 commit 12862af
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Tools/CodeGen/xTensorKranc.m
Expand Up @@ -29,6 +29,9 @@
MatrixInverse::usage = "";
MatrixOfComponents::usage = "";

SetTensorAttribute::usage = "";
HasTensorAttribute::usage = "";
GetTensorAttribute::usage = "";
CreateGroupFromTensor::usage = "CreateGroupFromTensor[T[a, b, ...]] Creates a variable group from the tensor T";
ReflectionSymmetries::usage = "ReflectionSymmetries[T[a, b, ...]] Produces a list of reflection symmetries of the tensor T.";
ExpandComponents::usage = "ExpandComponents[expr] converts an expression x containing abstract indices into one containing components instead."
Expand Down Expand Up @@ -130,6 +133,22 @@
]];

(*************************************************************)
(* SetTensorAttribute *)
(*************************************************************)

SetTensorAttribute[t_, attr_, val_] :=
t /: KrancTensorAttribute[t, attr] = val;

HasTensorAttribute[t_, attr_] :=
ValueQ[KrancTensorAttribute[t, attr]];

GetTensorAttribute[t_, attr_] :=
Module[{},
If[!HasTensorAttribute[t, attr],
ThrowError["Tensor " <> ToString[t] <> " does not have a " <> ToString[attr] <> " attribute."];
];
KrancTensorAttribute[t, attr]
];
(* DefineParameter *)
(*************************************************************)

Expand Down

0 comments on commit 12862af

Please sign in to comment.