Permute allows you create permutated views of a collection without duplicating memory or rearranging the original collection. Even cooler, Permute provides a
RangeReplaceableCollectionType
collection that enables appending too, mutating, and deleting from a permuted collection in a way that actually mutates the original as well (still without changing the order)!
![](/uploads/1/2/6/3/126302345/686911786.jpg)
![Permute Permute](http://poj.org/images/1349_1.jpg)
![Permute Permute](/uploads/1/2/6/3/126302345/667015366.jpg)
Documentation that describes how to install, deploy, and configure Oracle Forms applications with Oracle Forms Services.
Permute defines a protocol
PermutationType
that describes type which can be used to permute a collection. The most basic is SequencedPermutation
which will order the array as specified by the list of indicies. Note that this list of indices must be the same length as the array otherwise an our of bounds error might occur. Another useful permutation type, SwapPermutation
, allows you to specify the ordering of the items in terms of index swaps.
If you want to access the base collection (the collection the permutation is applied to), use the
base
property. Also, you can assign new permutations to a collection by upating the permutation
property. (Note that this is of type AnyPermutation
so that the backing permutation can be updated to a custom transformation when elements are added or removed from the array.)
Well, I know that the poster explicitly asked for a for loop, and Jeff Mather's answer provided exactly that.But still I got curious whether it is possible to decompose a matrix into tiles (sub-matrices) of a given size without a loop. In case someone else is curious, too, here's what I have come up with: T = permute(reshape(permute(reshape(A, size(A, 1), n, ), 2 1 3), n, m, ), 2 1 3)transforms a two-dimensional array A into a three-dimensional array T, where each 2d slice T(:,:, i) is one of the tiles of size m x n. The third index enumerates the tiles in standard Matlab linearized order, tile rows first.The variant T = permute(reshape(A, size(A, 1), n, ), 2 1 3);T = permute(reshape(T, n, m, , size(T, 3)), 2 1 3 4);makes T a four-dimensional array where T(:,:, i, j) gives the 2d slice with tile indices i, j.Coming up with these expressions feels a bit like solving a sliding puzzle.;-).
![](/uploads/1/2/6/3/126302345/686911786.jpg)