-
3.41.0
|
The matfaust factorization module. More...
Functions | |
function | butterfly (M, varargin) |
Factorizes the matrix M according to a butterfly support and optionally a permutation using the algorithms described in [1]. More... | |
function | eigtj (M, varargin) |
Performs an approximate eigendecomposition of M and returns the eigenvalues in D along with the corresponding normalized right eigenvectors (as the columns of the Faust object V). More... | |
function | hierarchical (M, p, varargin) |
Factorizes the matrix M with Hierarchical Factorization using the parameters set in p. More... | |
function | hierarchical_mhtp (M, hierarchical_p, mhtp_p, varargin) |
Runs the MHTP-PALM4MSA hierarchical factorization algorithm on the matrix M. More... | |
function | palm4msa (M, p, varargin) |
Factorizes the matrix M with Palm4MSA algorithm using the parameters set in p. More... | |
function | palm4msa_mhtp (M, palm4msa_p, mhtp_p, varargin) |
Runs the MHTP-PALM4MSA algorithm to factorize the matrix M. More... | |
function | pinvtj (M, varargin) |
Computes the pseudoinverse of M using svdtj. More... | |
function | svdtj (M, varargin) |
Performs an approximate singular value decomposition and returns the left and right singular vectors as Faust transforms. More... | |
The matfaust factorization module.
This module gives access to the main factorization algorithms of FAuST. These algorithms can factorize a dense matrix to a sparse product (i.e. a Faust object).
There are several factorization algorithms.
function matfaust::fact::butterfly | ( | M | , |
varargin | |||
) |
Factorizes the matrix M according to a butterfly support and optionally a permutation using the algorithms described in [1].
The result is a Faust F of the form BP where B has a butterfly structure and P is a permutation matrix determined by the optional parameter ‘perm'.
M | the matrix to factorize. It can be real (single or double, the class might have a large impact on performance) or complex. M must be square and its dimension must be a power of two. |
'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). |
'perm',value | five kinds of values are possible for this argument. |
'diag_opt',bool | if true then the returned Faust is optimized using matfaust.opt_butterfly_faust. |
'mul_perm',bool | : decides if the permutation is multiplied into the rightest butterfly factor (mul_perm=true) or if this permutation is left apart as the rightest factor of the Faust (mul_perm=false). It can't be true if diag_opt is true (an error is raised otherwise). Defaultly, mul_perm is not set which implies that mul_perm is true iff diag_opt is false. |
F | the Faust which is an approximation of M according to a butterfly support. |
Examples:
Use butterfly with simple permutations:
Use butterfly with a permutation defined by a list of indices J:
Use butterfly with successive permutations J1 and J2 and keep the best approximation:
Or to to use the 8 default permutations (keeping the best approximation resulting Faust)
References:
[1] Leon Zheng, Elisa Riccietti, and Remi Gribonval, Hierarchical Identifiability in Multi-layer Sparse Matrix Factorization
[2] T. Dao, A. Gu, M. Eichhorn, A. Rudra, and C. Re, “Learning Fast Algorithms for Linear Transforms Using Butterfly Factorizations,” in Proceedings of the 36th International Conference on Machine Learning. June 2019, pp. 1517–1527, PMLR
See also: matfaust.wht, matfaust.dft, matfaust.rand_butterfly
function matfaust::fact::eigtj | ( | M | , |
varargin | |||
) |
Performs an approximate eigendecomposition of M and returns the eigenvalues in D along with the corresponding normalized right eigenvectors (as the columns of the Faust object V).
The output is such that V*D*V'
approximates M. V is a product of Givens rotations obtained by truncating the Jacobi algorithm.
The trade-off between accuracy and complexity of V can be set through the parameters nGivens and tol that define the targeted number of Givens rotations and targeted error.
Usage
Primary examples of calls include:
[V,D] = eigtj(M, 'nGivens', n) outputs V as a Faust object made of n elementary Givens rotations grouped into factors containing ideally m = floor(size(M,1)/2)
such Givens rotations, and the diagonal entries of D are the approximate eigenvalues in ascending order.
[V,D] = eigtj(M,’tol’,0.01) same as above with n determined adaptively by a relative approximation error 0.01.
[V,D] = eigtj(M,’tol’,0.01) same as above with n determined adaptively by a relative approximation error 0.01.
[V,D] = eigtj(M,’tol’,0.01,’relerr’,False) same as above with an absolute approximation error.
[V,D] = eigtj(M,’nGivens’,n,’tol’,0.01) same as above with a number of elementary Givens bounded by n even if the targeted approximation error is not achieved.
[V,D]= eigtj(M,’nGivens’,n,’tol’,0.01,’nGivens_per_fac’,t) same as above with (up to) t Givens rotations per factor.
[V,D]= eigtj(M,’nGivens’,n,’order’,’descend’) same as above where the diagonal entries of D are the approximate eigenvalues in descending order (and with columns of V permuted accordingly).
eigtj(M, 'nGivens', n, 'nGivens_per_fac', t, 'tol', 0.01, 'relerr', true) uses a stopping criterion based on absolute error norm(V*D*V'-M, 'fro'). This criterion is concurrent to nGivens (here n).
M | the matrix to diagonalize. Must be real and symmetric, or complex hermitian. Can be in dense or sparse format. The class(M) value can be double or single (only if isreal(M) is true). |
nGivens,integer | [optional if tol is set] targeted number of Givens rotations. The number of rotations per factor of V is defined by nGivens_per_fac. |
'tol',number | [optional if nGivens is set] the tolerance error at which the algorithm stops. The default value is zero so that stopping is based on reaching the targeted nGivens. |
'err_period',int | it defines the period, in number of factors of V, the error is compared to tol (reducing the period spares some factors but increases slightly the computational cost because the error is computed more often). |
'order',char | [optional, default is ‘ascend’] order of eigenvalues, possible choices are ‘ascend, 'descend' or 'undef' (to avoid a sorting operation and save some time). |
'nGivens_per_fac',integer | [optional, default is floor(size(M, 1)/2) ] targeted number of Givens rotations per factor of V. Must be an integer between 1 to floor(size(M, 1)/2) . |
'relerr',bool | [optional, default is true] the type of error used as stopping criterion. (true) for the relative error norm(V*D*V'-M, 'fro')/norm(M, 'fro'), (false) for the absolute error norm(V*D*V'-M, 'fro'). |
'enable_large_Faust',bool | [optional, default is false] if true, it allows to compute a transform that doesn't worth it regarding its complexity relatively to the matrix M. Otherwise, by default, an exception is raised before the algorithm starts. |
'verbosity',integer | [optional] verbosity level. The greater the value the more info is displayed. It can be helpful to understand for example why the algorithm stopped before reaching the tol error or the number of Givens (nGivens). |
[V,D] |
|
Example
References:
See also fact.svdtj
function matfaust::fact::hierarchical | ( | M | , |
p | , | ||
varargin | |||
) |
Factorizes the matrix M with Hierarchical Factorization using the parameters set in p.
M | the dense matrix to factorize. The class(M) value can be double or single (only if isreal(M) is true). This class has a major impact on performance. |
p | is a set of factorization parameters. It might be a fully defined instance of parameters (matfaust.factparams.ParamsHierarchical) or a simplified expression which designates a pre-defined parametrization:
|
'backend',int | (optional) the backend to use (the C++ implementation). Must be 2016 (the default) or 2020 (which should be faster for most of the factorizations). |
'gpu',bool | (optional) set to true to execute the algorithm using the GPU implementation. This option is only available when backend==2020. |
F | The Faust object result of the factorization. |
[F,lambda] | = palm4msa(M, p) when optionally getting lambda (scale). |
Example 1: Fully Defined Parameters for a Random Matrix Factorization
Example 2: Simplified Parameters for Hadamard Factorization
Example 3: Simplified Parameters for a Rectangular Matrix Factorization (the BSL demo MEG matrix)
Example 4: Simplified Parameters for Discrete Fourier Transform Factorization
Example 5: Simplified Parameters for Hadamard Factorization without residual constraints
This factorization parameterization is the same as the one shown in 2. except that there is no constraints at all on residual factors. See matfaust.factparams.ParamsHierarchicalNoResCons and matfaust.factparams.ParamsHierarchicalWHTNoResCons for more details.
Example 6: Simplified Parameters for a Rectangular Matrix Factorization (the BSL demo MEG matrix) without residual constraints
The factorization parameterization shown here is the same as in 3. except that there is no constraint at all on residual factors. See matfaust.factparams.ParamsHierarchicalNoResCons and matfaust.factparams.ParamsHierarchicalRectMatNoResCons for more details. In the example below the MEG matrix is factorized according to the parameterization shown in 3. (aka "MEG") and on the other hand with the parameterization of interest here (aka "MEG_SIMPLE", with no residual constraints), the approximate accuracy is quite the same so we can conclude that on this case (as in 5.) removing residual constraints can not only simplify the parameterization of hierarchical PALM4MSA but also be as efficient.
See also matfaust.faust_fact, factparams.ParamsHierarchical, factparams.ParamsHierarchicalWHT, factparams.ParamsHierarchicalRectMat,factparams.ParamsHierarchicalDFT
function matfaust::fact::hierarchical_mhtp | ( | M | , |
hierarchical_p | , | ||
mhtp_p | , | ||
varargin | |||
) |
Runs the MHTP-PALM4MSA hierarchical factorization algorithm on the matrix M.
This algorithm uses the MHTP-PALM4MSA (matfaust.fact.palm4msa_mhtp) instead of only PALM4MSA as matfaust.fact.hierarchical.
M | the dense matrix to factorize. |
hierarchical_p | is a set of factorization parameters. See matfaust.fact.hierarchical. |
mhtp_p | the matfaust.factparams.MHTPParams instance to define the MHTP algorithm parameters. |
varargin | see matfaust.fact.hierarchical for the other parameters. |
F | The Faust object result of the factorization. |
[F,lambda] | = palm4msa(M, p) when optionally getting lambda (scale). |
Example
function matfaust::fact::palm4msa | ( | M | , |
p | , | ||
varargin | |||
) |
Factorizes the matrix M with Palm4MSA algorithm using the parameters set in p.
M | the dense matrix to factorize. The class(M) value can be double or single (only if isreal(M) is true). This class has a major impact on performance. |
p | the matfaust.factparams.ParamsPalm4MSA instance to define the algorithm parameters. |
'backend',int | (optional) the backend to use (the C++ implementation). Must be 2016 (the default) or 2020 (which should be faster for most of the factorizations). |
'gpu',bool | (optional) set to true to execute the algorithm using the GPU implementation. This option is only available when backend==2020. |
F | the Faust object result of the factorization. |
[F,lambda] | = palm4msa(M, p) when optionally getting lambda (scale). |
Example
See also matfaust.factparams.ParamsPalm4msaWHT to factorize a Hadamard matrix using the SKPERM projector.
function matfaust::fact::palm4msa_mhtp | ( | M | , |
palm4msa_p | , | ||
mhtp_p | , | ||
varargin | |||
) |
Runs the MHTP-PALM4MSA algorithm to factorize the matrix M.
MHTP stands for Multilinear Hard Tresholding Pursuit. This is a generalization of the Bilinear HTP algorithm describe in [1].
[1] Quoc-Tung Le, Rémi Gribonval. Structured Support Exploration For Multilayer Sparse Matrix Fac- torization. ICASSP 2021 - IEEE International Conference on Acoustics, Speech and Signal Processing, Jun 2021, Toronto, Ontario, Canada. pp.1-5. hal-03132013
M | the dense matrix to factorize. |
palm4msa_p | the matfaust.factparams.ParamsPalm4MSA instance to define the PALM4MSA algorithm parameters. |
mthp_p | the matfaust.factparams.MHTPParams instance to define the MHTP algorithm parameters. |
varargin | see matfaust.fact.palm4msa for the other parameters. |
F | the Faust object result of the factorization. |
[F,lambda] | = palm4msa(M, p) when optionally getting lambda (scale). |
Example
function matfaust::fact::pinvtj | ( | M | , |
varargin | |||
) |
Computes the pseudoinverse of M using svdtj.
M | the matrix to compute the pseudoinverse. |
nGivens,int|matrix | see fact.svdtj |
'tol',number | see fact.svdtj |
'relerr',bool | see fact.svdtj |
'nGivens_per_fac',int | see fact.svdtj |
'enable_large_Faust',bool | see fact.svdtj |
'err_period',int | see fact.svdtj |
[V,Sp,Uh] | such that V*Sp*Uh is the approximate of M^+ with:
|
Example
function matfaust::fact::svdtj | ( | M | , |
varargin | |||
) |
Performs an approximate singular value decomposition and returns the left and right singular vectors as Faust transforms.
Usage
Primary examples of calls include:
[U,S,V] = svdtj(M, ‘nGivens’,n) outputs U,V as Faust objects made of n elementary Givens rotations grouped into factors. By default each factor gathers (up to) m = floor(size(M,1)/2) such rotations. By default vector S contains the approximate singular values in any order.
[U,S,V] = svdtj(M,’tol’,0.01) same as above with n determined adaptively by a relative approximation error 0.01
[U,S,V] = svdtj(M,’tol’,0.01,’relerr’,false) same as above with an absolute approximation error
[U,S,V] = svdtj(M,’nGivens’,n,’tol’,0.01) same as above with a number of elementary Givens bounded by n even if the targeted approximation error is not achieved
[U,S,V] = svdtj(M,’nGivens’,n,’tol’,0.01,’nGivens_per_fac’,t) same as above with (up to) t Givens rotations per factor
M | a real or complex, dense or sparse matrix. The class(M) value can be double or single (only if isreal(M) is true). |
nGivens,int|matrix | defines the number of Givens rotations that will be used at most to compute U and V. If it is an integer, it will apply both to U and V. If it is a tuple of two integers as nGivens = [JU, JV], JU will be the limit number of rotations for U and JV the same for V. nGivens argument is optional if tol is set but becomes mandatory otherwise. |
'tol',number | this is the error target on U' S V against M. if error <= tol, the algorithm stops. See relerr below for the error formula. This argument is optional if nGivens is set, otherwise it becomes mandatory. |
'relerr',bool | defines the type of error used to evaluate the stopping criterion defined by tol. true for a relative error ( \(\| U' S V - M\|_F \over \| M \|_F\)) otherwise this is an absolute error ( \(\| U' S V - M\|_F \)). |
'nGivens_per_fac',int | this argument is the number of Givens rotations to set at most by factor of U and V. If this is an integer it will be the same number of U and V. Otherwise, if it is a tuple of integers [tU, tV], tU will be the number of Givens rotations per factor for U and tV the same for V. By default, this parameter is maximized for U and V, i.e. tU = size(M, 1) / 2, tV = size(M, 2) / 2. |
'enable_large_Faust',bool | see fact.eigtj |
'err_period',int | it defines the period, in number of factors of U or V, the error is compared to tol (reducing the period spares some factors but increases slightly the computational cost because the error is computed more often). |
[U,S,V] | such that U*S*V' is the approximate of M with:
|
Example
Explanations:
If we call svdtj on the matrix M, it makes two internal calls to eigtj.
In Matlab it would be:
It gives the following equalities (ignoring the fact that eigtj computes approximations):
\[ W_1 D_1 W_1^* = M M^* \]
\[ W_2 D_2 W_2^* = M^* M \]
But because of the SVD \( M = USV^* \) we also have:
\[MM^* = U S V^* V S U^* = U S^2 U^* = W_1 D_1 W_1^*\]
\[M^* M = V S U^* U S V^* = V S^2 V^* = W_2 D_2 W_2^*\]
It allows to identify the left singular vectors of M to W1, and likewise the right singular vectors to W2.
To compute a consistent approximation of S we observe that U and V are orthogonal/unitary hence \( S = U^* M V \) so we ignore the off-diagonal coefficients of the approximation and take \( S = diag(U^* M V) \approx diag(W_1^* M W_2)\)
See also fact.eigtj, fact.pinvtj