Mentions légales du service

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

Update Palm4MSA and HierarchicalFact python/matlab/C++ tests since 64bbc2f0...

Update Palm4MSA and HierarchicalFact python/matlab/C++ tests since 64bbc2f0 modified Palm4MSA when running on a complex matrix.

Also handling complex matrix facto. test in C++ exactly as it is in py. and matlab tests (testing the matrix M = data + i*data).
parent b10edd22
Branches
Tags
No related merge requests found
......@@ -65,6 +65,20 @@
typedef @TEST_FPP@ FPP;
typedef @TEST_FPP2@ FPP2;
void create_matrix(Faust::MatDense<complex<FPP2>,Cpu>& data, Faust::MatDense<complex<FPP2>,Cpu>& idata)
{
idata = data;
idata.scalarMultiply(complex<FPP2>(0,1));
data += idata;
}
void create_matrix(Faust::MatDense<FPP2,Cpu>& data, Faust::MatDense<FPP2,Cpu>& idata)
{
//nothing to do
}
int main(int argc, char* argv[])
{
if (typeid(FPP) == typeid(double))
......@@ -153,8 +167,9 @@ int main(int argc, char* argv[])
params.Display();
// matrix to be factorized
Faust::MatDense<FPP,Cpu> matrix;
Faust::MatDense<FPP,Cpu> matrix, imatrix;
init_faust_mat_from_matio(matrix,MatrixFilename.c_str(),"matrix");
create_matrix(matrix, imatrix);
// transposed the matrix if needed
if (transposedMatrix == 'T')
......
/****************************************************************************/
/****************************************************************************//*{{{*/
/* Description: */
/* For more information on the FAuST Project, please visit the website */
/* of the project : <http://faust.inria.fr> */
......@@ -36,7 +36,7 @@
/* approximations of matrices and applications", Journal of Selected */
/* Topics in Signal Processing, 2016. */
/* <https://hal.archives-ouvertes.fr/hal-01167948v1> */
/****************************************************************************/
/****************************************************************************//*}}}*/
#include "faust_MatDense.h"
#include "faust_Params.h"
#include "faust_ParamsPalm.h"
......@@ -55,15 +55,30 @@
using namespace std;
typedef @TEST_FPP@ FPP;
typedef @TEST_FPP2@ FPP2;
void create_matrix(Faust::MatDense<complex<FPP2>,Cpu>& data, Faust::MatDense<complex<FPP2>,Cpu>& idata)
{
idata = data;
idata.scalarMultiply(complex<FPP2>(0,1));
data += idata;
}
void create_matrix(Faust::MatDense<FPP2,Cpu>& data, Faust::MatDense<FPP2,Cpu>& idata)
{
//nothing todo
}
/** \brief Run a test of Faust::Palm4MSA
*/
int main()
{
Faust::MatDense<FPP,Cpu> data, initFacts1, initFacts2;
Faust::MatDense<FPP,Cpu> data, idata, initFacts1, initFacts2;
char configPalm2Filename[] = "@FAUST_DATA_MAT_DIR@/config_compared_palm2.mat";
init_faust_mat_from_matio(data, configPalm2Filename, "data");
create_matrix(data, idata);
init_faust_mat_from_matio(initFacts1, configPalm2Filename, "init_facts1");
init_faust_mat_from_matio(initFacts2, configPalm2Filename, "init_facts2");
......@@ -110,8 +125,6 @@ int main()
Faust::StoppingCriterion<FPP2> crit(niter);
Faust::ParamsPalm<FPP,Cpu,FPP2> params(data, nfacts, cons, initFact, crit, verbose, updateWay, initLambda);
Faust::BlasHandle<Cpu> blasHandle;
Faust::Palm4MSA<FPP,Cpu,FPP2> palm2(params,blasHandle,true);
......
......@@ -76,7 +76,7 @@ classdef FaustFactoryTest < matlab.unittest.TestCase
E = full(F)-M;
disp('err: ')
norm(E,'fro')/norm(M,'fro')
this.verifyEqual(norm(E,'fro')/norm(M,'fro'), 0.9094, 'AbsTol', 0.0001)
this.verifyEqual(norm(E,'fro')/norm(M,'fro'), 0.29177, 'AbsTol', 0.0001)
end
function test_fact_hierarchical(this)
......@@ -155,7 +155,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.99275, 'AbsTol', 0.00001)
this.verifyEqual(norm(E,'fro')/norm(M,'fro'), 1.0063, 'AbsTol', 0.0001)
end
function testHadamard(this)
......
......@@ -7,6 +7,7 @@ import sys
import numpy as np
from scipy.io import savemat,loadmat
from numpy.linalg import norm
from pyfaust import Faust
import math
class TestFaustPy(unittest.TestCase):
......@@ -832,7 +833,7 @@ class TestFaustFactory(unittest.TestCase):
print("err: ", norm(E,"fro")/norm(M,"fro"))
# matrix to factorize and reference relative error come from
# misc/test/src/C++/hierarchicalFactorization.cpp
self.assertAlmostEqual(norm(E,"fro")/norm(M,"fro"), 0.99275, places=4)
self.assertAlmostEqual(norm(E,"fro")/norm(M,"fro"), 1.0063, places=4)
def testFactPalm4MSACplx(self):
print("Test FaustFactory.fact_palm4msaCplx()")
......@@ -868,7 +869,7 @@ class TestFaustFactory(unittest.TestCase):
print("err: ", norm(E,"fro")/norm(M,"fro"))
# matrix to factorize and reference relative error come from
# misc/test/src/C++/test_palm4MSA.cpp
self.assertAlmostEqual(norm(E,"fro")/norm(M,"fro"), 0.9094, places=4)
self.assertAlmostEqual(norm(E,"fro")/norm(M,"fro"), 0.29177, places=4)
def testHadamard(self):
print("Test FaustFactory.wht()")
......@@ -897,7 +898,6 @@ if __name__ == "__main__":
# (to find pyfaust module)
sys.path.append(sys.argv[1])
del sys.argv[1] # deleted to avoid interfering with unittest
from pyfaust import Faust
if(len(sys.argv) > 1):
#ENOTE: test only a single test if name passed on command line
singleton = unittest.TestSuite()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment