next | previous | forward | backward | up | top | index | toc | Macaulay2 web site
Tensors (missing documentation) :: makeTensor

makeTensor -- Constructor for making tensors from their entries.

Synopsis

Description

A tensor can be built like a matrix, by entering a rectangular nested list of its entries,

i1 : makeTensor{{{1,2},{3,4}},{{5,6},{7,8}}}

     +------+------+
o1 = |{1, 2}|{3, 4}|
     +------+------+
     |{5, 6}|{7, 8}|
     +------+------+

       8
o1 : ZZ {2x2x2}

or by entering its dimensions followed by a non-nested visible list of entries

i2 : makeTensor({2,2,2},{1,2,3,4,5,6,7,8})

     +------+------+
o2 = |{1, 2}|{3, 4}|
     +------+------+
     |{5, 6}|{7, 8}|
     +------+------+

       8
o2 : ZZ {2x2x2}
i3 : makeTensor({3,3,3},1..27)

     +------------+------------+------------+
o3 = |{1 , 2 , 3 }|{4 , 5 , 6 }|{7 , 8 , 9 }|
     +------------+------------+------------+
     |{10, 11, 12}|{13, 14, 15}|{16, 17, 18}|
     +------------+------------+------------+
     |{19, 20, 21}|{22, 23, 24}|{25, 26, 27}|
     +------------+------------+------------+

       27
o3 : ZZ  {3x3x3}

or by entering its dimenions followed by a function which gives the entries of tensor as a function of their position keys,

i4 : R=QQ[x,y,z]

o4 = R

o4 : PolynomialRing
i5 : T=makeTensor({3,3,3},(i,j,k)->x^i*y^j*z^k)

     +---------------+--------------------+---------------------+
     |           2   |                2   |  2     2      2 2   |
o5 = |{1 , z  , z   }|{y  , y*z  , y*z   }|{y   , y z  , y z   }|
     +---------------+--------------------+---------------------+
     |             2 |                  2 |    2     2      2 2 |
     |{x , x*z, x*z }|{x*y, x*y*z, x*y*z }|{x*y , x*y z, x*y z }|
     +---------------+--------------------+---------------------+
     |  2   2    2 2 |  2    2      2   2 |  2 2   2 2    2 2 2 |
     |{x , x z, x z }|{x y, x y*z, x y*z }|{x y , x y z, x y z }|
     +---------------+--------------------+---------------------+

      27
o5 : R  {3x3x3}
i6 : T_(1,2,2)==x^1*y^2*z^2

o6 = true

Caveat

The constructor tensor is used to return tensors from tensor-related types defined in the Tensors package.

Ways to use makeTensor :

  • makeTensor(List)
  • makeTensor(VisibleList,Function)
  • makeTensor(VisibleList,VisibleList)