flip x block components along a given dimension
y = flipdim(x, dim [,sb])
scalars, vectors, matrices, or hypermatrices of any type, of same sizes
a positive integer, the dimension number along which the flipping should occur
a positive integer, the size of the blocks to permute
Given x, a scalar/vector/matrix/hypermatrix of any type and
two positive integers dim and sb,
this function flips the x components by blocks of size sb
along the dimension number dim of x
(x and y have the same size).
The optional parameter sb (for Size Block) allows flipping
x by blocks of size sb*size(x,2)
(dim=1) or size(x,1)*sb (dim=2).
// Example 1: flip x components along the first dimension x = [1 2 3 4; 5 6 7 8] dim = 1 y = flipdim(x, dim) // Example 2: flip x components along the second dimension dim = 2 y = flipdim(x, dim) // Example 3: flip x components along the third dimension x = matrix(1:24, [3 2 4]) dim = 3 y = flipdim(x, dim) // Example 4: the first example with complex x = [1+%i 2*%i 3 4; 5 6-%i 7 8*%pi*%i] dim = 1 y = flipdim(x, dim) // Integer-encoded numbers: x = int16(grand(4, 3, 2, "uin", -9, 9)) y = flipdim(x, 1) // Booleans: x = (grand(3, 4, "uin", -9, 9) > 0) y = flipdim(x, 2) // Texts: x = matrix(strsplit("a":"x", 1:23), 4, 6); x = x+x flipdim(x, 2) // Polynomials: x = inv_coeff(grand(3, 9, "uin", 0, 3), 2) flipdim(x, 1) // Rationals: n = inv_coeff(grand(3, 9, "uin", 0, 3), 2); d = inv_coeff(grand(3, 9, "uin", 0, 3), 2); r = n./d flipdim(r, 2) | ![]() | ![]() |
Examples using sb:
| Version | Description |
| 5.5.0 | Extension from decimals to any type: booleans, integers, strings, polynomials and rationals.
New input argument sb to flip x blockwise. |