home *** CD-ROM | disk | FTP | other *** search
-
- (*********************************************************************
-
- Adapted from
- Roman E. Maeder: Programming in Mathematica,
- Second Edition, Addison-Wesley, 1991.
-
- *********************************************************************)
-
-
- BeginPackage["Tensors`"]
-
- ui::usage = "ui[index] denotes an upper index in a tensor."
- li::usage = "li[index] denotes a lower index in a tensor."
- Tensor::usage = "Tensor[h][indices] denotes a tensor h with index list indices."
-
- Begin["`Private`"]
-
- Format[ Tensor[t_][ind___] ] :=
- Module[{indices},
- indices = {ind} /. {ui->Superscript, li->Subscript};
- SequenceForm[t, Sequence @@ indices]
- ]
-
- Format[ Tensor[t_][ind___], TeXForm ] :=
- Module[{indices},
- indices = {ind} /. {ui->Superscript, li->Subscript};
- indices = Transpose[{Table["{}", {Length[indices]}], indices}];
- SequenceForm[t, Sequence @@ Flatten[indices, 1]]
- ]
-
- End[]
-
- EndPackage[]
-