// output of ./demo/perm/cycles-demo.cc:
// Description:
//% Decomposition of a permutation into cycles.
//% Print cycles and code for the permutation.

arg 1: 3 == ldn  [Number of elements is 2**ldn]  default=3
  n=8
arg 2: 1 == pcq  [Whether to print code]  default=1
Using: zip(y, n)

Permutation:
[ 0 2 4 6 1 3 5 7 ]
Inverse:
[ 0 4 1 5 2 6 3 7 ]

Cycles:
 (0) #=1
 (1, 2, 4) #=3
 (3, 6, 5) #=3
 (7) #=1

Code:
template <typename Type>
inline void foo_perm_8(Type *f)
{
  { Type t=f[1];  f[1]=f[4];  f[4]=f[2];  f[2]=t; }
  { Type t=f[3];  f[3]=f[5];  f[5]=f[6];  f[6]=t; }
}
