%> @brief Factorizes the matrix M according to a butterfly support.
%> @param 'type', str: the type of factorization 'right'ward, 'left'ward or 'bbtree'.
%>
%> @param M: the matrix to factorize. It can be real (single or double, the class might have a large impact on performance) or complex. The dimension must be a power of two.
%>@param 'type', str: the type of factorization 'right'ward, 'left'ward or 'bbtree'.
%> More precisely: if 'left' (resp. 'right') is used then at each stage of the
%> factorization the most left factor (resp. the most right factor) is split in two.
%> If 'bbtree' is used then the matrix is factorized according to a Balanced
%> Binary Tree (which is faster as it allows parallelization).
%>
%>
%> @param 'perm', value five kinds of values are possible for this argument.
%>
%> 1. perm is an array of column indices of the permutation matrix P which is such that the returned Faust is F = G * P where G is the Faust butterfly approximation of M*P.'. If the array of indices is not a valid permutation the behaviour is undefined (however an invalid size or an out of bound index raise an exception).
%> 2. perm is a cell array of arrays of permutation column indices as defined in 1. In that case, all permutations passed to the function are used as explained in 1, each one producing a Faust, the best one (that is the best approximation of M) is kept and returned by butterfly.
%> 3. perm is 'default_8', this is a particular case of 2. Eight default permutations are used. For the definition of those permutations please refer to [2].
%> 4. perm is 'bitrev': in that case the permutation is the bit-reversal permutation (cf. matfaust.tools.bitrev_perm).
%> 5. By default this argument is empty, no permutation is used.
%> 5. By default this argument is empty, no permutation is used (this is equivalent to using the identity permutation matrix in 1).
%>
%> @retval F the Faust which is an approximate of M according to a butterfly support.
%>
...
...
@@ -22,12 +22,19 @@
%> >> import matfaust.wht
%> >> import matfaust.dft
%> >> import matfaust.fact.butterfly
%> >> H = full(wht(32)); % it works with dft too!
%> >> H = full(wht(32));
%> >> F = butterfly(H, 'type', 'bbtree');
%> >> err = norm(full(F)-H)/norm(M)
%> >> err = norm(full(F)-H)/norm(H)
%> err =
%>
%> 1.4311e-15
%> >> % it works with dft too!
%> >> % all you need is to specify the bit-reversal permutation
%> >> DFT = full(dft(32));
%> >> F = butterfly(DFT, 'type', 'bbtree', 'perm', 'bitrev');
%> >> err = norm(full(F)-DFT)/norm(DFT)
%> err =
%> 2.8471e-15
%> @endcode
%>
%> Use butterfly with simple permutations:
...
...
@@ -35,15 +42,19 @@
%> >> M = rand(4, 4);
%> >> % without any permutation
%> >> F1 = butterfly(M, 'type', 'bbtree');
%> >> % which is equivalent to identity permutation
%> >> % which is equivalent to using identity permutation