Mentions légales du service

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

Add a skeleton for ParamsPalmFFT.

parent 2a862d9e
Branches
Tags 3.37.4
No related merge requests found
......@@ -192,7 +192,7 @@ if(MATIO_LIB_FILE AND MATIO_INC_DIR AND BUILD_READ_MAT_FILE) # AND HDF5_LIB_FILE
# faust_multiplication : time comparison between Faust-vector product and Dense matrix-vector product
foreach(TEST_FPP float double complex<float> complex<double>)
foreach(testin hierarchicalFactorization test_palm4MSA faust_multiplication faust_matdense_conjugate)
foreach(testin hierarchicalFactorization test_palm4MSA test_palm4MSAFFT faust_multiplication faust_matdense_conjugate)
string(REGEX REPLACE "<|>" "" TEST_FILE_CPP ${TEST_FPP})
set(TEST_CPP_NAME ${testin}_${TEST_FILE_CPP})
set(TEST_FILE_CPP ${TEST_CPP_NAME}.cpp)
......@@ -290,6 +290,7 @@ if (BUILD_READ_MAT_FILE)
endif()
add_test(NAME MATFILE_PALM4MSA_${TEST_FPP} COMMAND ${FAUST_BIN_TEST_BIN_DIR}/test_palm4MSA_${TEST_FPP} )
add_test(NAME MATFILE_PALM4MSA_FFT_${TEST_FPP} COMMAND ${FAUST_BIN_TEST_BIN_DIR}/test_palm4MSAFFT_${TEST_FPP} )
# limit the time of the process in case of bug...
set_tests_properties(MATFILE_FACT_HADAMARD_${TEST_FPP} MATFILE_FACT_HIER_${TEST_FPP} PROPERTIES TIMEOUT ${TIMEOUT_COMP})
......
/****************************************************************************/
/* Description: */
/* For more information on the FAuST Project, please visit the website */
/* of the project : <http://faust.inria.fr> */
/* */
/* License: */
/* Copyright (2018): Hakim Hadj-Djilani, */
/* Nicolas Bellot, Adrien Leman, Thomas Gautrais, */
/* Luc Le Magoarou, Remi Gribonval */
/* INRIA Rennes, FRANCE */
/* http://www.inria.fr/ */
/* */
/* The FAuST Toolbox is distributed under the terms of the GNU Affero */
/* General Public License. */
/* This program is free software: you can redistribute it and/or modify */
/* it under the terms of the GNU Affero General Public License as */
/* published by the Free Software Foundation. */
/* */
/* This program is distributed in the hope that it will be useful, but */
/* WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */
/* See the GNU Affero General Public License for more details. */
/* */
/* You should have received a copy of the GNU Affero General Public */
/* License along with this program. */
/* If not, see <http://www.gnu.org/licenses/>. */
/* */
/* Contacts: */
/* Nicolas Bellot : nicolas.bellot@inria.fr */
/* Adrien Leman : adrien.leman@inria.fr */
/* Thomas Gautrais : thomas.gautrais@inria.fr */
/* Luc Le Magoarou : luc.le-magoarou@inria.fr */
/* Remi Gribonval : remi.gribonval@inria.fr */
/* */
/* References: */
/* [1] Le Magoarou L. and Gribonval R., "Flexible multi-layer sparse */
/* 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_ParamsPalmFFT.h"
#include "faust_StoppingCriterion.h"
#include "faust_init_from_matio.h"
#include "faust_init_from_matio_mat.h"
#include "faust_Palm4MSA.h"
#include "faust_BlasHandle.h"
#include <iostream>
// modif AL AL
//#include "faust_ConstraintInt.h"
//#include "faust_ConstraintFPP.h"
using namespace std;
typedef @TEST_FPP@ FPP;
typedef @TEST_FPP2@ FPP2;
/** \brief Run a test of Faust::Palm4MSA
*/
int main()
{
Faust::MatDense<FPP,Cpu> data, initFacts1, initFacts2;
char configPalm2Filename[] = "@FAUST_DATA_MAT_DIR@/config_compared_palm2.mat";
init_faust_mat_from_matio(data, configPalm2Filename, "data");
init_faust_mat_from_matio(initFacts1, configPalm2Filename, "init_facts1");
init_faust_mat_from_matio(initFacts2, configPalm2Filename, "init_facts2");
int cons1Name, cons1Parameter, cons1Row, cons1Col;
int cons2Name, cons2Row, cons2Col;
FPP2 cons2Parameter;
int nfacts, niter;
bool updateWay, verbose;
FPP initLambda;
cons1Name = init_int_from_matio(configPalm2Filename, "cons1_name");
cons1Parameter = init_int_from_matio(configPalm2Filename, "cons1_parameter");
cons1Row = init_int_from_matio(configPalm2Filename, "cons1_row");
cons1Col = init_int_from_matio(configPalm2Filename, "cons1_col");
cons2Name = init_int_from_matio(configPalm2Filename, "cons2_name");
cons2Parameter = (FPP2) init_double_from_matio(configPalm2Filename, "cons2_parameter");
cons2Row = init_int_from_matio(configPalm2Filename, "cons2_row");
cons2Col = init_int_from_matio(configPalm2Filename, "cons2_col");
initLambda = (FPP) init_double_from_matio(configPalm2Filename, "init_lambda");
nfacts = init_int_from_matio(configPalm2Filename, "nfacts");
niter = init_int_from_matio(configPalm2Filename, "niter");
updateWay = init_bool_from_matio(configPalm2Filename, "update_way");
verbose = init_bool_from_matio(configPalm2Filename, "verbose");
// Creation du vecteur de contrainte
const Faust::ConstraintInt<FPP,Cpu> cons1(static_cast<faust_constraint_name>(cons1Name), cons1Parameter, cons1Row, cons1Col);
const Faust::ConstraintFPP<FPP,Cpu,FPP2> cons2(static_cast<faust_constraint_name>(cons2Name), cons2Parameter, cons2Row, cons2Col);
vector<const Faust::ConstraintGeneric*> cons;
cons.push_back(&cons1);
cons.push_back(&cons2);
// Creation du vecteur de matrice initFact;
vector<Faust::MatDense<FPP,Cpu> > initFact;
initFact.push_back(initFacts1);
initFact.push_back(initFacts2);
// Creation du critere d'arret
Faust::StoppingCriterion<FPP2> crit(niter);
Faust::ParamsPalmFFT<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);
//
//// palm2.next_step();
// palm2.compute_facts();
// std::vector<Faust::MatDense<FPP,Cpu> >& full_facts = const_cast< std::vector<Faust::MatDense<FPP,Cpu> >&>(palm2.get_facts());
// FPP lambda = palm2.get_lambda();
// (full_facts[0]) *= lambda;
//
// Faust::Transform<FPP, Cpu>* t = new Faust::Transform<FPP, Cpu>(full_facts);
// //relativeError
// Faust::MatDense<FPP,Cpu> faustProduct;
// faustProduct=t->get_product();
// faustProduct-=data;
// FPP2 relativeError = Faust::fabs(faustProduct.norm()/data.norm());
//
// std::cout<<std::endl;
// std::cout<<"**************** RELATIVE ERROR BETWEEN FAUST AND DATA MATRIX **************** "<<std::endl;
// std::cout<< "\t\t" << relativeError<<std::endl<<std::endl;
return 0;
}
#ifndef __FAUST_PARAMS_PALM_FFT_H__
#define __FAUST_PARAMS_PALM_FFT_H__
#include "faust_ParamsPalm.h"
using namespace Faust;
namespace Faust
{
template<typename FPP, Device DEVICE, typename FPP2 = double>
class ParamsPalmFFT : public Faust::ParamsPalm<FPP,DEVICE,FPP2>
{
public:
//ctor definitions in header because it consists mainly to call parent ctor
ParamsPalmFFT(const Faust::MatDense<FPP,DEVICE>& data_,
const int nbFact_,
const std::vector<const Faust::ConstraintGeneric*>& cons_,
const std::vector<Faust::MatDense<FPP,DEVICE> >& init_fact_,
const Faust::StoppingCriterion<FPP2> & stop_crit_ = StoppingCriterion<FPP2>(ParamsPalm<FPP,DEVICE,FPP2>::defaultNiter),
const bool isVerbose_ = ParamsPalm<FPP,DEVICE,FPP2>::defaultVerbosity ,
const bool isUpdateWayR2L_ = ParamsPalm<FPP,DEVICE,FPP2>::defaultUpdateWayR2L ,
const FPP init_lambda_ = ParamsPalm<FPP,DEVICE,FPP2>::defaultLambda,
const bool constant_step_size_ = ParamsPalm<FPP,DEVICE,FPP2>::defaultConstantStepSize,
const FPP step_size_ = ParamsPalm<FPP,DEVICE,FPP2>::defaultStepSize) : ParamsPalm<FPP, DEVICE, FPP2>(data_, nbFact_, cons_, init_fact_, stop_crit_, isVerbose_, isUpdateWayR2L_, init_lambda_, constant_step_size_, step_size_) {}
ParamsPalmFFT() : ParamsPalm<FPP,DEVICE,FPP2>() {}
MatDense<FPP,DEVICE> init_D;
};
#include "faust_ParamsPalmFFT.hpp"
}
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment