Macaulay2 » Documentation
Packages » GameTheory :: randomTensor
next | previous | forward | backward | up | index | toc

randomTensor -- construct a tensor with random entries from a given ring

Description

This method constructs a tensor with the specified format and fills it with random elements from the given ring. Internally, it uses a hash table where each key is a multi-index (a list of positions) and the value is a random element from the ring. Metadata such as the format, coefficient ring, and index set are stored in the tensor as well.

i1 : T1 = randomTensor {2,2,2};
i2 : T1#{0,1,1}

     7
o2 = -
     4

o2 : QQ
i3 : T2 = randomTensor(ZZ/101, {2,2});
i4 : peek T2

o4 = Tensor{{0, 0} => 16                               }
            {0, 1} => 22
            {1, 0} => 45
            {1, 1} => -34
            format => {2, 2}
            indexes => {{0, 0}, {0, 1}, {1, 0}, {1, 1}}
                             ZZ
            coefficients => ---
                            101

See also

Ways to use randomTensor:

  • randomTensor(List)
  • randomTensor(Ring,List)

For the programmer

The object randomTensor is a method function.


The source of this document is in /build/reproducible-path/macaulay2-1.25.06+ds/M2/Macaulay2/packages/GameTheory.m2:1107:0.