Mentions légales du service

Skip to content
Snippets Groups Projects
Commit c9d91413 authored by hhakim's avatar hhakim
Browse files

Review/doctest matfaust.factparams and add it to doctest ci job.

parent cc73164f
Branches
Tags
No related merge requests found
...@@ -186,7 +186,7 @@ doctest_nightly_matfaust: ...@@ -186,7 +186,7 @@ doctest_nightly_matfaust:
- rm -Rf build - rm -Rf build
# all is set to doctest matfaust # all is set to doctest matfaust
# no -nojvm because it's needed for Faust.imagesc doctest # no -nojvm because it's needed for Faust.imagesc doctest
- 'for S in Faust proj.sp proj.splin proj.spcol proj.splincol proj.const proj.supp proj.normlin proj.normcol proj.blockdiag proj.anticirc proj.circ proj.hankel proj.skperm proj.sptriu proj.sptril proj.spsymm proj.toeplitz proj.proj_id poly.poly poly.expm_multiply poly.next poly.basis poly.expm_inv_multiply; do if matlab -nodisplay -r "addpath /usr/share/octave/packages/doctest-0.7.0/; setup_FAUST; doctest matfaust.$S; exit;" | tee /tmp/matlab_doctest_$ | grep FAIL; then exit 1; else exit 0; fi; done' - 'for S in Faust proj.sp proj.splin proj.spcol proj.splincol proj.const proj.supp proj.normlin proj.normcol proj.blockdiag proj.anticirc proj.circ proj.hankel proj.skperm proj.sptriu proj.sptril proj.spsymm proj.toeplitz proj.proj_id poly.poly poly.expm_multiply poly.next poly.basis poly.expm_inv_multiply factparams.ParamsHierarchicalWHTNoResCons factparams.ParamsHierarchicalRectMatNoResCons factparams.ParamsHierarchicalNoResCons factparams.ParamsHierarchicalRectMat; do if matlab -nodisplay -r "addpath /usr/share/octave/packages/doctest-0.7.0/; setup_FAUST; doctest matfaust.$S; exit;" | tee /tmp/matlab_doctest_$ | grep FAIL; then exit 1; else exit 0; fi; done'
after_script: after_script:
- if [ $(rpm -qa faust | wc -l) -gt 0 ]; then sudo rpm -e faust;fi - if [ $(rpm -qa faust | wc -l) -gt 0 ]; then sudo rpm -e faust;fi
only: only:
......
% ========================================================= % =========================================================
%> A ParamsHierarchical specialization for which there is no residual constraints. %> @brief A ParamsHierarchical specialization for which there is no residual constraints.
% ========================================================= % =========================================================
classdef ParamsHierarchicalNoResCons < matfaust.factparams.ParamsHierarchical classdef ParamsHierarchicalNoResCons < matfaust.factparams.ParamsHierarchical
methods methods
% ========================================================= %=========================================================
%> @brief Constructor. %> @brief Constructor.
%> %>
%> @param fact_constraints a ConstrainstList or a cell array of matfaust.proj.proj_gen or matfaust.factparams.ConstraintGeneric that define the structure of the pyfaust.fact.hierarchical resulting Faust factors in the same order if is_fact_side_left==true, in the reverse order otherwise. %> @param fact_constraints a ConstrainstList or a cell array of matfaust.proj.proj_gen or matfaust.factparams.ConstraintGeneric that define the structure of the pyfaust.fact.hierarchical resulting Faust factors in the same order if is_fact_side_left==true, in the reverse order otherwise.
...@@ -27,43 +27,57 @@ classdef ParamsHierarchicalNoResCons < matfaust.factparams.ParamsHierarchical ...@@ -27,43 +27,57 @@ classdef ParamsHierarchicalNoResCons < matfaust.factparams.ParamsHierarchical
%> @b Example %> @b Example
%> This example shows two parametrizations that are equivalent. The first one, p1, is defined trough a ParamsHierarchical instance while the second one, p2, is defined using a ParamsHierarchicalNoResCons instance. %> This example shows two parametrizations that are equivalent. The first one, p1, is defined trough a ParamsHierarchical instance while the second one, p2, is defined using a ParamsHierarchicalNoResCons instance.
%> @code %> @code
%> import matfaust.proj.* %> >> import matfaust.proj.*
%> import matfaust.factparams.* %> >> import matfaust.factparams.*
%> import matfaust.fact.hierarchical %> >> import matfaust.fact.hierarchical
%> import matfaust.wht %> >> import matfaust.wht
%> H = full(wht(32)); %> >> H = full(wht(32));
%> d = size(H, 1); %> >> d = size(H, 1);
%> n = ceil(log2(d)); %> >> n = ceil(log2(d));
%> res_projs = {}; %> >> res_projs = {};
%> fac_projs = {}; %> >> fac_projs = {};
%> for i=1:n %> >> for i=1:n
%> if i == n %> .. if i == n
%> res_projs = { res_projs{:}, skperm([d,d], ceil(d/2^i), 'normalized', true)}; %> .. res_projs = { res_projs{:}, skperm([d,d], ceil(d/2^i), 'normalized', true)};
%> else %> .. else
%> res_projs = { res_projs{:}, proj_id([d,d])}; %> .. res_projs = { res_projs{:}, proj_id([d,d])};
%> end %> .. end
%> fac_projs = {fac_projs{:}, skperm([d, d], 2, 'normalized', true)}; %> .. fac_projs = {fac_projs{:}, skperm([d, d], 2, 'normalized', true)};
%> end %> .. end
%> stop_crit = StoppingCriterion(30); %> >> stop_crit = StoppingCriterion(30);
%> p1 = ParamsHierarchical(fac_projs, res_projs, stop_crit, stop_crit, 'is_update_way_R2L', true, 'packing_RL', false); %> >> p1 = ParamsHierarchical(fac_projs, res_projs, stop_crit, stop_crit, 'is_update_way_R2L', true, 'packing_RL', false);
%> disp("factorizing with p1 (ParamsHierarchical) into Faust F1") %> >> % factorizing with p1 (ParamsHierarchical) into Faust F1
%> F1 = hierarchical(H, p1, 'backend', 2020) %> >> F1 = hierarchical(H, p1, 'backend', 2020);
%> F1_error = norm(full(F1)-H)/norm(H) %> Faust::hierarchical: 1/5
%> simple_projs = {fac_projs{:}, res_projs{end}}; %> Faust::hierarchical: 2/5
%> p2 = ParamsHierarchicalNoResCons(simple_projs, stop_crit, stop_crit, 'is_update_way_R2L', true, 'packing_RL', false); %> Faust::hierarchical: 3/5
%> disp("factorizing with p2 (ParamsHierarchical) into Faust F2") %> Faust::hierarchical: 4/5
%> F2 = hierarchical(H, p2, 'backend', 2020) %> Faust::hierarchical: 5/5
%> F2_error = norm(full(F2)-H)/norm(H) %>
%> >> F1_error = norm(full(F1)-H)/norm(H)
%>
%> F1_error =
%>
%> 0
%>
%> >> simple_projs = {fac_projs{:}, res_projs{end}};
%> >> p2 = ParamsHierarchicalNoResCons(simple_projs, stop_crit, stop_crit, 'is_update_way_R2L', true, 'packing_RL', false);
%> >> % factorizing with p2 (ParamsHierarchical) into Faust F2
%> >> F2 = hierarchical(H, p2, 'backend', 2020);
%> Faust::hierarchical: 1/5
%> Faust::hierarchical: 2/5
%> Faust::hierarchical: 3/5
%> Faust::hierarchical: 4/5
%> Faust::hierarchical: 5/5
%>
%> >> F2_error = norm(full(F2)-H)/norm(H)
%>
%> F2_error =
%>
%> 0
%> >>
%> @endcode %> @endcode
%> %>
%> Output:
%> @code
%> factorizing with p1 (ParamsHierarchical) into Faust F1
%> Faust::hierarchical: 1/5
%> Faust::hierarchical: 2/5
%> Faust::hierarchical: 3/5
%> Faust::hierarchical: 4/5
%> Faust::hierarchical: 5/5
%> %>
%> F1 = %> F1 =
%> %>
...@@ -102,7 +116,7 @@ classdef ParamsHierarchicalNoResCons < matfaust.factparams.ParamsHierarchical ...@@ -102,7 +116,7 @@ classdef ParamsHierarchicalNoResCons < matfaust.factparams.ParamsHierarchical
%> %>
%> @endcode %> @endcode
%> %>
% ========================================================= %=========================================================
function p = ParamsHierarchicalNoResCons(fact_constraints, stop_crit1, stop_crit2, varargin) function p = ParamsHierarchicalNoResCons(fact_constraints, stop_crit1, stop_crit2, varargin)
import matfaust.factparams.* import matfaust.factparams.*
import matfaust.proj.proj_id import matfaust.proj.proj_id
......
...@@ -31,17 +31,17 @@ classdef ParamsHierarchicalRectMat < matfaust.factparams.ParamsHierarchical ...@@ -31,17 +31,17 @@ classdef ParamsHierarchicalRectMat < matfaust.factparams.ParamsHierarchical
%> %>
%> @b Example: %> @b Example:
%> @code %> @code
%> import matfaust.factparams.* %> >> import matfaust.factparams.*
%> % set p1 with m, n, j, k parameters %> >> % set p1 with m, n, j, k parameters
%> p1 = ParamsHierarchicalRectMat(32, 128, 8, 4, 2); %> >> p1 = ParamsHierarchicalRectMat(32, 128, 8, 4, 2);
%> % now with additional optional rho and P %> >> % now with additional optional rho and P
%> p2 = ParamsHierarchicalRectMat(32, 128, 8, 4, 2, 'rho', .7, 'P', 1.5); %> >> p2 = ParamsHierarchicalRectMat(32, 128, 8, 4, 2, 'rho', .7, 'P', 1.5);
%> @endcode %> @endcode
%> %>
%> %>
%> [1] Le Magoarou L. and Gribonval R., "Flexible multi-layer sparse %> [1] Le Magoarou L. and Gribonval R., "Flexible multi-layer sparse
%> approximations of matrices and applications", Journal of Selected %> approximations of matrices and applications", Journal of Selected
%> Topics in Signal Processing, 2016. [https://hal.archives-ouvertes.fr/hal-01167948v1] %> Topics in Signal Processing, 2016. [https://hal.archives-ouvertes.fr/hal-01167948v1]
%================================== %==================================
function p = ParamsHierarchicalRectMat(m, n, j, k, s, varargin) function p = ParamsHierarchicalRectMat(m, n, j, k, s, varargin)
import matfaust.factparams.* import matfaust.factparams.*
...@@ -97,8 +97,8 @@ classdef ParamsHierarchicalRectMat < matfaust.factparams.ParamsHierarchical ...@@ -97,8 +97,8 @@ classdef ParamsHierarchicalRectMat < matfaust.factparams.ParamsHierarchical
%> >> num_facts = 9; %> >> num_facts = 9;
%> >> k = 10; %> >> k = 10;
%> >> s = 8; %> >> s = 8;
%> >> p = ParamsHierarchicalRectMat.createParams(rand(256, 1024), {'rectmat', num_facts, k, s}) %> >> p = ParamsHierarchicalRectMat.createParams(rand(256, 1024), {'rectmat', num_facts, k, s});
%> >> p2 = ParamsHierarchicalRectMat.createParams(rand(256, 1024), {'rectmat', num_facts, k, s, 'rho', 1.2, 'P', 2}) %> >> p2 = ParamsHierarchicalRectMat.createParams(rand(256, 1024), {'rectmat', num_facts, k, s, 'rho', 1.2, 'P', 2});
%> @endcode %> @endcode
%======================== %========================
function sp = createParams(M, p) function sp = createParams(M, p)
......
...@@ -6,25 +6,31 @@ ...@@ -6,25 +6,31 @@
%> factors are not constrained at all, the other factors are constrained with %> factors are not constrained at all, the other factors are constrained with
%> matfaust.proj.skperm. %> matfaust.proj.skperm.
%> %>
%> @b Example
%> @code
%> import matfaust.wht
%> import matfaust.factparams.*
%> import matfaust.fact.hierarchical
%>
%> H = full(wht(32));
%> p = ParamsHierarchicalWHTNoResCons(5);
%> F = hierarchical(H, p)
%> @endcode
%> %>
%> <b/> See also matfaust.fact.hierarchical, matfaust.demo.hadamard %> <b/> See also matfaust.fact.hierarchical, matfaust.demo.hadamard
% ================================================= % =================================================
classdef ParamsHierarchicalWHTNoResCons < matfaust.factparams.ParamsHierarchicalNoResCons classdef ParamsHierarchicalWHTNoResCons < matfaust.factparams.ParamsHierarchicalNoResCons
methods methods
% ================================================= %=================================================
%> @param n: the number of output factors (the input matrix to factorize must %> @param n: the number of output factors (the input matrix to factorize must
%> be of size [2^n, 2^n]) . %> be of size [2^n, 2^n]) .
% ================================================= %>
%> @b Example
%> @code
%> >> import matfaust.wht
%> >> import matfaust.factparams.*
%> >> import matfaust.fact.hierarchical
%> >> H = full(wht(32));
%> >> p = ParamsHierarchicalWHTNoResCons(5);
%> >> F = hierarchical(H, p);
%> Faust::HierarchicalFact<FPP,DEVICE,FPP2>::compute_facts : factorization 1/4
%> Faust::HierarchicalFact<FPP,DEVICE,FPP2>::compute_facts : factorization 2/4
%> Faust::HierarchicalFact<FPP,DEVICE,FPP2>::compute_facts : factorization 3/4
%> Faust::HierarchicalFact<FPP,DEVICE,FPP2>::compute_facts : factorization 4/4
%>
%> >>
%> @endcode
%=================================================
function p = ParamsHierarchicalWHTNoResCons(n, varargin) function p = ParamsHierarchicalWHTNoResCons(n, varargin)
import matfaust.factparams.* import matfaust.factparams.*
proj_name = 'skperm'; % because splincol doesn't work well proj_name = 'skperm'; % because splincol doesn't work well
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment