Mentions légales du service

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

Fix several matfaust factorization algorithms unit tests.

parent 76030b50
Branches
Tags
No related merge requests found
......@@ -83,7 +83,7 @@ classdef FaustFactoryTest < matlab.unittest.TestCase
end
function test_palm4msaCplxDeftInitFacts(this)
disp('Test matfaust.fact.palm4msaCplx()')
disp('Test matfaust.fact.palm4msaCplxDeftInitFacts()')
import matfaust.factparams.*
num_facts = 2;
is_update_way_R2L = false;
......@@ -136,7 +136,7 @@ classdef FaustFactoryTest < matlab.unittest.TestCase
end
function test_palm4msa2020Cplx(this)
disp('Test matfaust.fact.palm4msaCplx()')
disp('Test matfaust.fact.palm4msa2020Cplx()')
import matfaust.factparams.*
num_facts = 2;
is_update_way_R2L = false;
......@@ -164,7 +164,7 @@ classdef FaustFactoryTest < matlab.unittest.TestCase
end
function test_palm4msa2020CplxDeftInitFacts(this)
disp('Test matfaust.fact.palm4msaCplx()')
disp('Test matfaust.fact.palm4msa2020CplxDeftInitFacts()')
import matfaust.factparams.*
num_facts = 2;
is_update_way_R2L = false;
......@@ -222,7 +222,7 @@ classdef FaustFactoryTest < matlab.unittest.TestCase
norm(E,'fro')/norm(M,'fro')
% matrix to factorize and reference relative error come from
% misc/test/src/C++/hierarchicalFactorization.cpp
this.verifyEqual(norm(E,'fro')/norm(M,'fro'), 0.26844, 'AbsTol', 0.00001)
this.verifyEqual(norm(E,'fro')/norm(M,'fro'), 0.26844, 'AbsTol', 0.001)
end
function test_hierarchical2020(this)
......@@ -260,7 +260,7 @@ classdef FaustFactoryTest < matlab.unittest.TestCase
norm(E,'fro')/norm(M,'fro')
% matrix to factorize and reference relative error come from
% misc/test/src/C++/hierarchicalFactorization.cpp
this.verifyEqual(norm(E,'fro')/norm(M,'fro'), 0.26844, 'AbsTol', 0.00001)
this.verifyEqual(norm(E,'fro')/norm(M,'fro'), 0.26844, 'AbsTol', 0.001)
end
function test_hierarchicalCplx(this)
......@@ -299,7 +299,46 @@ classdef FaustFactoryTest < matlab.unittest.TestCase
norm(E,'fro')/norm(M,'fro')
% matrix to factorize and reference relative error come from
% misc/test/src/C++/hierarchicalFactorization.cpp
this.verifyEqual(norm(E,'fro')/norm(M,'fro'),0.27353, 'AbsTol', 0.0001)
this.verifyEqual(norm(E,'fro')/norm(M,'fro'),0.2727, 'AbsTol', 0.0001)
end
function test_hierarchical2020Cplx(this)
disp('Test matfaust.fact.hierarchical2020Cplx()')
import matfaust.factparams.*
num_facts = 4;
is_update_way_R2L = false;
init_lambda = 1.0;
%init_facts = cell(num_facts,1);
%init_facts{1} = zeros(500,32);
%for i=2:num_facts
%init_facts{i} = zeros(32);
%end
%M = rand(500, 32)
load([this.faust_paths{1},'../../../misc/data/mat/matrix_hierarchical_fact.mat'])
% matrix is loaded from file
M = matrix+j*matrix;
fact_cons = cell(3,1);
res_cons = cell(3, 1);
fact_cons{1} = ConstraintInt(ConstraintName(ConstraintName.SPLIN), 500, 32, 5);
fact_cons{2} = ConstraintInt(ConstraintName(ConstraintName.SP), 32, 32, 96);
fact_cons{3} = ConstraintInt(ConstraintName(ConstraintName.SP), 32, 32, 96);
res_cons{1} = ConstraintReal(ConstraintName(ConstraintName.NORMCOL), 32, 32, 1);
res_cons{2} = ConstraintInt(ConstraintName(ConstraintName.SP), 32, 32, 666);
res_cons{3} = ConstraintInt(ConstraintName(ConstraintName.SP), 32, 32, 333);
stop_crit = StoppingCriterion(200);
stop_crit2 = StoppingCriterion(200);
params = ParamsHierarchical(fact_cons, res_cons, stop_crit, stop_crit2,...
'init_lambda', init_lambda, 'is_update_way_R2L', is_update_way_R2L);
F = matfaust.fact.hierarchical(M, params, 'backend', 2020)
this.verifyEqual(size(F), size(M))
%disp('norm F: ')
%norm(F, 'fro')
E = full(F)-M;
disp('err: ')
norm(E,'fro')/norm(M,'fro')
% matrix to factorize and reference relative error come from
% misc/test/src/C++/hierarchicalFactorization.cpp
this.verifyEqual(norm(E,'fro')/norm(M,'fro'),0.2727, 'AbsTol', 0.0001)
end
function test_fgft_givens(this)
......@@ -403,7 +442,9 @@ classdef FaustFactoryTest < matlab.unittest.TestCase
params.fact_side = 0 % forced
params.verbose = 0 % forced
params.init_lambda = 128;
params = ParamsHierarchical(fact_cons, res_cons, stop_crit, stop_crit2, 'is_fact_side_left', params.fact_side == 1, 'is_update_way_R2L', params.update_way == 1, 'init_lambda', params.init_lambda, 'step_size', params.stepsize, 'constant_step_size', false, 'is_verbose', params.verbose ~= 1);
params.step_size = 1e-16
params.grad_calc_opt_mode = 2
params = ParamsHierarchical(fact_cons, res_cons, stop_crit, stop_crit2, 'is_fact_side_left', params.fact_side == 1, 'is_update_way_R2L', params.update_way == 1, 'init_lambda', params.init_lambda, 'step_size', params.step_size, 'constant_step_size', false, 'is_verbose', params.verbose ~= 1);
diag_init_D = diag(init_D)
[F,D,lambda] = matfaust.fact.fgft_palm(U, Lap, params, diag_init_D)
this.verifyEqual(size(F), size(U))
......@@ -413,7 +454,7 @@ classdef FaustFactoryTest < matlab.unittest.TestCase
err = norm(E,'fro')/norm(U,'fro')
% matrix to factorize and reference relative error come from
% misc/test/src/C++/hierarchicalFactorizationFFT.cpp
this.verifyEqual(err, 0.05550, 'AbsTol', 0.00001)
this.verifyEqual(err, 0.0555, 'AbsTol', 0.0001)
end
function testHadamard(this)
......@@ -563,7 +604,7 @@ classdef FaustFactoryTest < matlab.unittest.TestCase
-0.0083095, -3.38725936, -0.78484126, -0.4883618;
-1.48942563, -1.71787215, -0.84000212, -3.71752454;
-0.88957883, -0.19107863, -5.92900636, -6.51064175]
p = skperm(size(M), 2)
p = skperm(size(M), 2, 'normalized', false)
pM_ref = [-0.04440802,0.,-0.02557815,0.;
-0.0083095,-3.38725936,0.,0.;
0.,-1.71787215,0.,-3.71752454;
......@@ -578,16 +619,16 @@ classdef FaustFactoryTest < matlab.unittest.TestCase
import matfaust.fact.butterfly
D = full(dft(64));
H = full(wht(64));
dirs = {'left', 'right'}
types = {'left', 'right', 'bbtree'}
for t=1:2
if(t == 2)
M = D;
else
M = H;
end
for i=1:2
dir = dirs{i};
F = butterfly(M, 'dir', dir);
for i=1:3
type = types{i};
F = butterfly(M, 'type', type);
this.verifyEqual(norm(full(F)-M)/norm(M), 0, 'AbsTol', 1e-6);
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment