next | previous | forward | backward | up | top | index | toc | Macaulay2 website
SparseResultants :: flattening

flattening -- flattening of a multidimensional matrix

Synopsis

Description

i1 : M = randomMultidimensionalMatrix(2,4,3,2)

o1 = {{{{8, 1}, {3, 7}, {8, 3}}, {{3, 7}, {8, 8}, {5, 7}}, {{8, 5}, {2, 3},
     ------------------------------------------------------------------------
     {6, 3}}, {{6, 8}, {6, 9}, {3, 7}}}, {{{6, 9}, {6, 2}, {6, 0}}, {{2, 6},
     ------------------------------------------------------------------------
     {9, 3}, {5, 6}}, {{3, 5}, {7, 7}, {9, 4}}, {{5, 0}, {4, 3}, {1, 8}}}}

o1 : 4-dimensional matrix of shape 2 x 4 x 3 x 2 over ZZ
i2 : s = {0,2};
i3 : Ms = flattening(s,M)

o3 = | 8 1 3 7 8 5 6 8 |
     | 3 7 8 8 2 3 6 9 |
     | 8 3 5 7 6 3 3 7 |
     | 6 9 2 6 3 5 5 0 |
     | 6 2 9 3 7 7 4 3 |
     | 6 0 5 6 9 4 1 8 |

              6        8
o3 : Matrix ZZ  <--- ZZ
i4 : s' = {1,3};
i5 : Ms' = flattening(s',M)

o5 = | 8 3 8 6 6 6 |
     | 1 7 3 9 2 0 |
     | 3 8 5 2 9 5 |
     | 7 8 7 6 3 6 |
     | 8 2 6 3 7 9 |
     | 5 3 3 5 7 4 |
     | 6 6 3 5 4 1 |
     | 8 9 7 0 3 8 |

              8        6
o5 : Matrix ZZ  <--- ZZ
i6 : assert(Ms == transpose Ms')

If the first argument is an integer i, it is interpreted as the list {i}.

i7 : flattening(1,M)

o7 = | 8 1 3 7 8 3 6 9 6 2 6 0 |
     | 3 7 8 8 5 7 2 6 9 3 5 6 |
     | 8 5 2 3 6 3 3 5 7 7 9 4 |
     | 6 8 6 9 3 7 5 0 4 3 1 8 |

              4        12
o7 : Matrix ZZ  <--- ZZ
i8 : assert(oo == flattening({1},M))

See also

Ways to use flattening :

For the programmer

The object flattening is a method function.