home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / e / e032 / 3.ddi / FILES / PROGRAMM.PAK / TENSORS.M < prev    next >
Encoding:
Text File  |  1992-07-29  |  956 b   |  35 lines

  1.  
  2. (*********************************************************************
  3.  
  4.         Adapted from
  5.         Roman E. Maeder: Programming in Mathematica,
  6.         Second Edition, Addison-Wesley, 1991.
  7.  
  8.  *********************************************************************)
  9.  
  10.  
  11. BeginPackage["Tensors`"]
  12.  
  13. ui::usage = "ui[index] denotes an upper index in a tensor."
  14. li::usage = "li[index] denotes a lower index in a tensor."
  15. Tensor::usage = "Tensor[h][indices] denotes a tensor h with index list indices."
  16.  
  17. Begin["`Private`"]
  18.  
  19. Format[ Tensor[t_][ind___] ] :=
  20.     Module[{indices},
  21.         indices = {ind} /. {ui->Superscript, li->Subscript};
  22.         SequenceForm[t, Sequence @@ indices]
  23.     ] 
  24.  
  25. Format[ Tensor[t_][ind___], TeXForm ] :=
  26.     Module[{indices},
  27.         indices = {ind} /. {ui->Superscript, li->Subscript};
  28.         indices = Transpose[{Table["{}", {Length[indices]}], indices}];
  29.         SequenceForm[t, Sequence @@ Flatten[indices, 1]]
  30.     ] 
  31.  
  32. End[]
  33.  
  34. EndPackage[]
  35.