Mentions légales du service

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

Add a skeleton for Palm4MSAFFT with the two methods to override from parent...

Add a skeleton for Palm4MSAFFT with the two methods to override from parent class Palm4MSA: compute_grad_over_c() and compute_lambda().

- Also completing the baseline test (test_palm4MSAFFT.cpp.in), and
- ParamsPalmFFT parameters for initialization of default init_D (eye() matrix).
parent a7fe01d4
Branches
Tags
No related merge requests found
......@@ -44,7 +44,7 @@
#include "faust_StoppingCriterion.h"
#include "faust_init_from_matio.h"
#include "faust_init_from_matio_mat.h"
#include "faust_Palm4MSA.h"
#include "faust_Palm4MSAFFT.h"
#include "faust_BlasHandle.h"
#include <iostream>
......@@ -115,24 +115,28 @@ int main()
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;
Faust::Palm4MSAFFT<FPP,Cpu,FPP2> palm2(params,blasHandle,true);
// Faust::MatDense<FPP,Cpu> eye = Faust::MatDense<FPP,Cpu>::eye(10,10);
// eye.Display();
// 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;
......
......@@ -136,14 +136,14 @@ namespace Faust
void compute_xhatt_xhat(MatDense<FPP,DEVICE>& Xt_Xhat);
~Palm4MSA(){}
private:
protected:
void check_constraint_validity();
void compute_c();
void compute_grad_over_c();
virtual void compute_grad_over_c();
void compute_projection();
void update_L();
void update_R();
void compute_lambda();
virtual void compute_lambda();
static const char * m_className;
static const FPP lipschitz_multiplicator;
......
......@@ -318,7 +318,7 @@ sprintf(nomFichier,"error_1_%d_device.tmp",cmpt);*/
}
}
//false is for disabling evaluation (because the transpose do it later)
//false is for disabling evaluation (because the transpose does it later)
LorR.conjugate(false);
RorL[m_indFact].conjugate(false);
......
#include "faust_ParamsPalmFFT.h"
#include "faust_Palm4MSA.h"
#ifndef __FAUST_PALM4MSA_FFT_H__
#define __FAUST_PALM4MSA_FFT_H__
using namespace Faust;
namespace Faust {
template<typename FPP, Device DEVICE, typename FPP2 = double>
class Palm4MSAFFT : public Palm4MSA<FPP, DEVICE, FPP2>
{
public:
//TODO: another ctor (like in Palm4MSA) for hierarchical algo. use
Palm4MSAFFT(const ParamsPalmFFT<FPP, DEVICE, FPP2>& params, const BlasHandle<DEVICE> blasHandle, const bool isGlobal=false);
private:
virtual void compute_grad_over_c();
virtual void compute_lambda();
};
#include "faust_Palm4MSAFFT.hpp"
}
#endif
template <typename FPP, Device DEVICE, typename FPP2>
Palm4MSAFFT<FPP,DEVICE,FPP2>::Palm4MSAFFT(const ParamsPalmFFT<FPP, DEVICE, FPP2>& params, const BlasHandle<DEVICE> blasHandle, const bool isGlobal) : Palm4MSA<FPP,DEVICE,FPP2>(params, blasHandle, isGlobal)
{
//TODO: manage init_D ?
}
template <typename FPP, Device DEVICE, typename FPP2>
void Palm4MSAFFT<FPP,DEVICE,FPP2>::compute_grad_over_c()
{
//TODO: override parent's method
Palm4MSA<FPP,DEVICE,FPP2>::compute_grad_over_c();
}
template <typename FPP, Device DEVICE, typename FPP2>
void Palm4MSAFFT<FPP,DEVICE,FPP2>::compute_lambda()
{
//TODO: override parent's method
Palm4MSA<FPP,DEVICE,FPP2>::compute_lambda();
}
......@@ -15,7 +15,6 @@ namespace Faust
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_,
......@@ -25,12 +24,14 @@ namespace Faust
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_) {}
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_), init_D(MatDense<FPP,DEVICE>::eye(data_.getNbRow(), data_.getNbCol())) {}
ParamsPalmFFT() : ParamsPalm<FPP,DEVICE,FPP2>() {}
ParamsPalmFFT() : ParamsPalm<FPP,DEVICE,FPP2>(), init_D(0,0) {}
MatDense<FPP,DEVICE> init_D;
};
#include "faust_ParamsPalmFFT.hpp"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment