Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 79146493 authored by Adrien Leman's avatar Adrien Leman Committed by hhakim
Browse files

remplacement des fichiers Hier Palm Stopping

parent 734734e9
Branches
Tags
No related merge requests found
#ifndef __FAUST_HIERARCHICAL_FACT_H__
#define __FAUST_HIERARCHICAL_FACT_H__
#include "faust_constant.h"
#include <vector>
#include "Palm4MSA.h"
#include "faust_Params.h"
#ifdef __COMPILE_FPPIMERS__
#include "faust_Timer.h"
#endif
/*! \class HierarchicalFact
* \brief template class implementing hierarchical factorisation algorithm
: <br> factorization of a data matrix into multiple factors using Palm4MSA algorithm mixed with a hierarchical approach.
*\tparam FPP scalar numeric type, e.g float or double
*/
template<typename FPP,Device DEVICE> class ConstraintGeneric;
template<typename FPP,Device DEVICE> class Palm4MSA;
template<typename FPP,Device DEVICE> class MatDense;
template<typename FPP,Device DEVICE> class MatSparse;
template<typename FPP,Device DEVICE> class Transform;
template<typename FPP> class StoppingCriterion;
template<Device DEVICE> class BlasHandle;
template<Device DEVICE> class SpBlasHandle;
template<typename FPP,Device DEVICE>
class HierarchicalFact
{
public:
HierarchicalFact(const Faust::Params<FPP,DEVICE>& params_, BlasHandle<DEVICE> cublasHandle, SpBlasHandle<DEVICE> cusparseHandle);
void get_facts(Faust::Transform<FPP,DEVICE> &)const;
void get_facts(std::vector<Faust::MatSparse<FPP,DEVICE> >&)const;
void get_facts(std::vector<Faust::MatDense<FPP,DEVICE> >& fact)const{fact = palm_global.get_facts();}
void compute_facts();
FPP get_lambda()const{return palm_global.get_lambda();}
const std::vector<std::vector< FPP> >& get_errors()const;
private:
void init();
void next_step();
void compute_errors();
private:
const std::vector< std::vector<const Faust::ConstraintGeneric<FPP,DEVICE>*> > cons;
bool isUpdateWayR2L;
bool isFactSideLeft;
bool isVerbose;
int ind_fact ; //indice de factorisation (!= Palm4MSA::ind_fact : indice de facteur)
int nb_fact; // nombre de factorisations (!= Palm4MSA::nb_fact : nombre de facteurs)
Palm4MSA<FPP,DEVICE> palm_2;
Palm4MSA<FPP,DEVICE> palm_global;
const FPP default_lambda; // initial value of lambda for factorization into two factors
//std::vector<Faust::MatDense<FPP,DEVICE> > S;
std::vector<const Faust::ConstraintGeneric<FPP,DEVICE>*> cons_tmp_global;
bool isFactorizationComputed;
std::vector<std::vector<FPP> > errors;
static const char * class_name;
BlasHandle<DEVICE> cublas_handle;
SpBlasHandle<DEVICE> cusparse_handle;
#ifdef __COMPILE_TIMERS__
public:
static Faust::Timer t_init;
static Faust::Timer t_next_step;
void print_timers()const;
//void print_prox_timers()const;
#endif
};
#include "HierarchicalFact.hpp"
#endif
#ifndef __HIERARCHICAL_FACT_CU_HPP__
#define __HIERARCHICAL_FACT_CU_HPP__
//#include "HierarchicalFact.h"
#ifdef __COMPILE_TIMERS__
#include "faust_Timer.h"
#endif
#ifdef __COMPILE_GPU__
#include "faust_MatSparse_gpu.h"
#include "faust_Transform_gpu.h"
#else
#include "faust_MatSparse.h"
#include "faust_Transform.h"
#endif
#include "faust_exception.h"
using namespace std;
//HierarchicalFact::HierarchicalFact(){} // voir avec Luc les parametres par defaut
template<typename FPP,Device DEVICE>
const char * HierarchicalFact<FPP,DEVICE>::class_name="HierarchicalFact";
template<typename FPP,Device DEVICE>
HierarchicalFact<FPP,DEVICE>::HierarchicalFact(const Faust::Params<FPP,DEVICE>& params_, BlasHandle<DEVICE> cublasHandle, SpBlasHandle<DEVICE> cusparseHandle):
ind_fact(0),
cons(params_.cons),
isUpdateWayR2L(params_.isUpdateWayR2L),
isFactSideLeft(params_.isFactSideLeft),
isVerbose(params_.isVerbose),
nb_fact(params_.nb_fact-1),
palm_2(Palm4MSA<FPP,DEVICE>(params_, cublasHandle, false)),
palm_global(Palm4MSA<FPP,DEVICE>(params_, cublasHandle, true)),
cons_tmp_global(vector<const Faust::ConstraintGeneric<FPP,DEVICE>*>()),
default_lambda(params_.init_lambda),
isFactorizationComputed(false),
errors(std::vector<std::vector<FPP> >(2,std::vector<FPP >(params_.nb_fact-1,0.0))),
cublas_handle(cublasHandle),
cusparse_handle(cusparseHandle){}
template<typename FPP,Device DEVICE>
void HierarchicalFact<FPP,DEVICE>::init()
{
#ifdef __COMPILE_TIMERS__
t_init.start();
#endif
cons_tmp_global.clear();
if(isFactSideLeft)
cons_tmp_global.push_back(cons[0][ind_fact]);
else
cons_tmp_global.push_back(cons[1][ind_fact]);
palm_global.set_constraint(cons_tmp_global);
palm_global.init_fact(1);
#ifdef __COMPILE_TIMERS__
t_init.stop();
#endif
}
template<typename FPP,Device DEVICE>
void HierarchicalFact<FPP,DEVICE>::next_step()
{
#ifdef __COMPILE_TIMERS__
t_next_step.start();
#endif
if(isFactorizationComputed)
{
handleError(class_name,"next_step : factorization has already been computed");
}
vector<const Faust::ConstraintGeneric<FPP,DEVICE>*> cons_tmp_2(2);
cons_tmp_2[0]=cons[0][ind_fact];
cons_tmp_2[1]=cons[1][ind_fact];
palm_2.set_constraint(cons_tmp_2);
palm_2.init_fact(2);
palm_2.set_lambda(default_lambda);
#ifdef __COMPILE_TIMERS__
palm_2.init_local_timers();
#endif
//while(palm_2.do_continue())
// palm_2.next_step();
palm_2.compute_facts();
#ifdef __COMPILE_TIMERS__
palm_2.print_local_timers();
#endif
palm_global.update_lambda_from_palm(palm_2);
if (isFactSideLeft)
{
cons_tmp_global[0]=cons[0][ind_fact];
typename vector<const Faust::ConstraintGeneric<FPP,DEVICE>*>::iterator it;
it = cons_tmp_global.begin();
cons_tmp_global.insert(it+1,cons[1][ind_fact]);
}
else
{
typename vector<const Faust::ConstraintGeneric<FPP,DEVICE>*>::iterator it;
it = cons_tmp_global.begin();
cons_tmp_global.insert(it+ind_fact,cons[0][ind_fact]);
cons_tmp_global[ind_fact+1]=cons[1][ind_fact];
}
palm_global.set_constraint(cons_tmp_global);
palm_global.init_fact_from_palm(palm_2, isFactSideLeft);
#ifdef __COMPILE_TIMERS__
palm_global.init_local_timers();
#endif
//while(palm_global.do_continue())
// palm_global.next_step();
palm_global.compute_facts();
#ifdef __COMPILE_TIMERS__
palm_global.print_local_timers();
#endif
palm_2.set_data(palm_global.get_res(isFactSideLeft, ind_fact));
compute_errors();
ind_fact++;
#ifdef __COMPILE_TIMERS__
t_next_step.stop();
palm_2.print_prox_timers();
#endif
}
template<typename FPP,Device DEVICE>
void HierarchicalFact<FPP,DEVICE>::get_facts(Faust::Transform<FPP,DEVICE> & fact)const
{
std::vector<Faust::MatSparse<FPP,DEVICE> > spfacts;
get_facts(spfacts);
Faust::Transform<FPP,DEVICE> res(spfacts);
fact = res;
}
template<typename FPP,Device DEVICE>
void HierarchicalFact<FPP,DEVICE>::get_facts(std::vector<Faust::MatSparse<FPP,DEVICE> >& sparse_facts)const
{
/*if(!isFactorizationComputed)
{
cerr << "Error in HierarchicalFact<FPP,DEVICE>::get_facts : factorization has not been computed" << endl;
exit(EXIT_FAILURE);
}*/
const std::vector<Faust::MatDense<FPP,DEVICE> >& full_facts = palm_global.get_facts();
sparse_facts.resize(full_facts.size());
for (int i=0 ; i<sparse_facts.size() ; i++)
{
sparse_facts[i].init(full_facts[i],cusparse_handle);
}
}
template<typename FPP,Device DEVICE>
void HierarchicalFact<FPP,DEVICE>::compute_facts()
{
if(isFactorizationComputed)
{
handleError(class_name,"compute_facts : factorization has already been computed");
}
init();
for (int i=0 ; i<=nb_fact-1 ; i++)
{
cout << "HierarchicalFact<FPP,DEVICE>::compute_facts : factorisation "<<i+1<<"/"<<nb_fact <<endl;
next_step();
}
isFactorizationComputed = true;
}
template<typename FPP,Device DEVICE>
const std::vector<std::vector< FPP> >& HierarchicalFact<FPP,DEVICE>::get_errors()const
{
if(!isFactorizationComputed)
{
handleError(class_name,"get_errors() : Factorization has not been computed");
}
return errors;
}
template<typename FPP,Device DEVICE>
void HierarchicalFact<FPP,DEVICE>::compute_errors()
{
vector<Faust::MatSparse<FPP,DEVICE> > sp_facts;
get_facts(sp_facts);
Faust::Transform<FPP,DEVICE> faust_Transform_tmp(sp_facts, get_lambda());
const Faust::MatDense<FPP,DEVICE> estimate_mat = faust_Transform_tmp.get_product(cublas_handle, cusparse_handle);
Faust::MatDense<FPP,DEVICE> data(palm_global.get_data());
FPP data_norm = data.norm();
data -= estimate_mat;
errors[0][ind_fact] = estimate_mat.norm()/data_norm;
errors[1][ind_fact] = faust_Transform_tmp.get_total_nnz()/data.getNbRow()/data.getNbCol();
}
#ifdef __COMPILE_TIMERS__
template<typename FPP,Device DEVICE> Faust::Timer HierarchicalFact<FPP,DEVICE>::t_init;
template<typename FPP,Device DEVICE> Faust::Timer HierarchicalFact<FPP,DEVICE>::t_next_step;
template<typename FPP,Device DEVICE>
void HierarchicalFact<FPP,DEVICE>::print_timers()const
{
palm_global.print_global_timers();
cout << "timers in HierarchicalFact :" << endl;
cout << "t_init = " << t_init.get_time() << " s for "<< t_init.get_nb_call() << " calls" << endl;
cout << "t_next_step = " << t_next_step.get_time() << " s for "<< t_next_step.get_nb_call() << " calls" << endl<<endl;
Faust::MatDense<FPP,DEVICE> M_tmp;
Faust::MatSparse<FPP,DEVICE> S_tmp;
M_tmp.print_timers();
S_tmp.print_timers();
}
#endif
#endif
#ifndef __FAUST_PALM4MSA_H__
#define __FAUST_PALM4MSA_H__
#include <iostream>
#include "faust_constant.h"
#include <vector>
#include "StoppingCriterion.h"
#ifdef __COMPILE_TIMERS__
#include "faust_Timer.h"
#endif
#include "faust_MatDense.h"
template<typename FPP,Device DEVICE> class MatDense;
template<typename FPP,Device DEVICE> class Transform;
template<typename FPP,Device DEVICE> class ConstraintGeneric;
template<typename FPP,Device DEVICE> class Params;
template<typename FPP,Device DEVICE> class ParamsPalm;
template<typename FPP> class StoppingCriterion;
template<Device DEVICE> class BlasHandle;
/*! \class Palm4MSA
* \brief template class implementing Palm4MSA (PALM for Multi-layer Sparse Approximation) factorization algorithm
: <br>
factorization of a data matrix (dense) into multiple factors (sparse) using PALM
*
*\tparam FPP scalar numeric type, e.g float or double
*/
template<typename FPP,Device DEVICE>
class Palm4MSA
{
public:
/*!
* \brief
* initialize Palm4MSA from Faust::Params (HierarchicalFact parameter)
*\tparam isGlobal_ : if true, the Palm4MSA StoppingCriterion stop_crit attribute is initialize from params_.stop_crit_global <br> and if false, it is initialize from stop_crit_2facts
*/
Palm4MSA(const Faust::Params<FPP,DEVICE>& params_, const BlasHandle<DEVICE> blasHandle, const bool isGlobal_);
Palm4MSA(const Faust::ParamsPalm<FPP,DEVICE>& params_palm_, const BlasHandle<DEVICE> blasHandle, const bool isGlobal_=false);
void set_constraint(const std::vector<const Faust::ConstraintGeneric<FPP,DEVICE>*> const_vec_){const_vec=const_vec_;isConstraintSet=true;}
void set_data(const Faust::MatDense<FPP,DEVICE>& data_){data=data_;}
void set_lambda(const FPP lambda_){lambda = lambda_;}
/*!
* \brief
* useful in HierarchicalFact, update lambda of palm_global from palm_2
*/
void update_lambda_from_palm(const Palm4MSA& palm){lambda *= palm.lambda;}
/*!
* \brief
* compute the factorisation
*/
void compute_facts();
/*!
* \brief
* return the multiplicative scalar lambda
*/
FPP get_lambda()const{return lambda;}
FPP get_RMSE()const{return error.norm()/sqrt((double)(data.getNbRow()*data.getNbCol()));}
const Faust::MatDense<FPP,DEVICE>& get_res(bool isFactSideLeft_, int ind_)const{return isFactSideLeft_ ? S[0] : S[ind_+1];}
const Faust::MatDense<FPP,DEVICE>& get_data()const{return data;}
void get_facts(Faust::Transform<FPP,DEVICE> & faust_fact) const;
/*!
* \brief
* initialize the factors to the default value,
* the first factor to be factorised is set to zero matrix
* whereas all the other are set to identity
*/
void init_fact(int nb_facts_);
void next_step();
bool do_continue(){bool cont=stop_crit.do_continue(++ind_ite); if(!cont){ind_ite=-1;isConstraintSet=false;}return cont;} // CAUTION !!! pre-increment of ind_ite: the value in stop_crit.do_continue is ind_ite+1, not ind_ite
//bool do_continue()const{return stop_crit.do_continue(++ind_ite, error);};
/*!
* \brief
* useful in HierarchicalFact, update the factors of palm_global from palm_2
*/
void init_fact_from_palm(const Palm4MSA& palm, bool isFactSideLeft);
const std::vector<Faust::MatDense<FPP,DEVICE> >& get_facts()const {return S;}
~Palm4MSA(){}
private:
void check_constraint_validity();
void compute_c();
void compute_grad_over_c();
void compute_projection();
void update_L();
void update_R();
void compute_lambda();
static const char * class_name;
static const FPP lipschitz_multiplicator;
public:
StoppingCriterion<FPP> stop_crit;
private:
// modif AL AL
Faust::MatDense<FPP,DEVICE> data;
FPP lambda;
int nb_fact; // number of factors
std::vector<Faust::MatDense<FPP,DEVICE> > S; // contains S_0^i, S_1^i, ...
// RorL_vec matches R if (!isUpdateWayR2L)
// RorL_vec matches L if (isUpdateWayR2L)
std::vector<Faust::MatDense<FPP,DEVICE> > RorL;
// LorR_mat matches L if (!isUpdateWayR2L)
// LorR_mat matches R if (isUpdateWayR2L)
// modif AL AL
Faust::MatDense<FPP,DEVICE> LorR;
//Faust::MatDense<FPP,DEVICE>& LorR;
std::vector<const Faust::ConstraintGeneric<FPP,DEVICE>*> const_vec; // vector of constraints of size nfact
int ind_fact; //indice de facteur (!= HierarchicalFact::ind_fact : indice de factorisation)
int ind_ite;
// FPP lipschitz_multiplicator;
const bool verbose;
const bool isUpdateWayR2L;
const bool isConstantStepSize;
bool isCComputed;
bool isGradComputed;
bool isProjectionComputed;
bool isLastFact;
bool isConstraintSet;
const bool isGlobal;
bool isInit; // only used for global factorization (if isGlobal)
Faust::MatDense<FPP,DEVICE> grad_over_c;
FPP c;
Faust::MatDense<FPP,DEVICE> error; // error = lambda*L*S*R - data
BlasHandle<DEVICE> blas_handle;
#ifdef __COMPILE_TIMERS__
public:
Faust::Timer_gpu t_local_compute_projection;
Faust::Timer_gpu t_local_compute_grad_over_c;
Faust::Timer_gpu t_local_compute_c;
Faust::Timer_gpu t_local_compute_lambda;
Faust::Timer_gpu t_local_update_R;
Faust::Timer_gpu t_local_update_L;
Faust::Timer_gpu t_local_check;
Faust::Timer_gpu t_local_init_fact;
Faust::Timer_gpu t_local_next_step;
Faust::Timer_gpu t_local_init_fact_from_palm;
static Faust::Timer_gpu t_global_compute_projection;
static Faust::Timer_gpu t_global_compute_grad_over_c;
static Faust::Timer_gpu t_global_compute_c;
static Faust::Timer_gpu t_global_compute_lambda;
static Faust::Timer_gpu t_global_update_R;
static Faust::Timer_gpu t_global_update_L;
static Faust::Timer_gpu t_global_check;
static Faust::Timer_gpu t_global_init_fact;
static Faust::Timer_gpu t_global_next_step;
static Faust::Timer_gpu t_global_init_fact_from_palm;
static Faust::Timer_gpu t_prox_const;
static Faust::Timer_gpu t_prox_sp;
static Faust::Timer_gpu t_prox_spcol;
static Faust::Timer_gpu t_prox_splin;
static Faust::Timer_gpu t_prox_normcol;
static int nb_call_prox_const;
static int nb_call_prox_sp;
static int nb_call_prox_spcol;
static int nb_call_prox_splin;
static int nb_call_prox_normcol;
void init_local_timers();
void print_global_timers()const;
void print_local_timers()const;
void print_prox_timers() const;
#endif
};
#include "Palm4MSA.hpp"
#endif
This diff is collapsed.
#ifndef __FAUST_STOPPING_CRITERION__
#define __FAUST_STOPPING_CRITERION__
#include "faust_constant.h"
#include <iostream>
template<typename T>
class StoppingCriterion
{
public:
StoppingCriterion():
isCriterionError(false),
nb_it(500){}
StoppingCriterion(int nb_it_):
isCriterionError(false),nb_it(nb_it_){check_validity();}
StoppingCriterion(T errorThreshold_, int maxIteration_=10000):
isCriterionError(true),errorThreshold(errorThreshold_),maxIteration(maxIteration_){check_validity();}
StoppingCriterion(bool isCriterionError_);
~StoppingCriterion(){}
bool do_continue(int current_ite, T error=-2.0)const;
int get_crit() const{return nb_it;}
private:
void check_validity()const;
private:
// if isCriterionError then criterion is error else criterion is number of iteration
bool isCriterionError;
int nb_it; // number of iterations if !isCriterionError
T errorThreshold;
int maxIteration;
// only used as stopping criterion, if isCriterionError, when error is still greater than
static const char * class_name;
};
#include "StoppingCriterion.hpp"
#endif
#ifndef __STOPPING_CRITERION_HPP__
#define __STOPPING_CRITERION_HPP__
//#include "StoppingCriterion.h"
#include <iostream>
#include <cstdlib>
#include "faust_exception.h"
template<typename T>
const char * StoppingCriterion<T>::class_name="StoppingCriterion::";
template<typename T>
StoppingCriterion<T>::StoppingCriterion(bool isCriterionError_) : isCriterionError(isCriterionError_)
{
if (isCriterionError_)
{
errorThreshold = 0.3;
maxIteration = 10000;
}
else
nb_it = 500;
}
template<typename T>
void StoppingCriterion<T>::check_validity()const
{
if (isCriterionError)
{
if (errorThreshold>1 || maxIteration < 0)
{
handleError(class_name,"check_validity : errorThreshold must be strictly greater than 1 and maxIteration must be strictly positive");
}
}
else if (nb_it < 0)
{
handleError(class_name,"::check_validity : nb_it must be positive");
}
}
// current_ite in zero-based indexing
template<typename T>
bool StoppingCriterion<T>::do_continue(int current_ite, T current_error /* = -2.0 */)const
{
if (!isCriterionError) // if criterion is number of iteration, current_error does not matter
return current_ite<nb_it ? true : false;
else if (isCriterionError && current_error != -2.0)
if (current_error < errorThreshold)
return false;
else if (current_ite < maxIteration) // and current_error >= errorThreshold
return true;
else // if current_error >= errorThreshold and current_ite >= maxIteration
{
std::cerr << "warning in StoppingCriterion<T>::do_continue : number of maximum iterations has been reached and current error is still greater than the threshold" << std::endl;
return true;
}
else // if criterion is error and current_error has not been initialized
{
handleError(class_name,"check_validity : when stopping criterion is error, the current error needs to be given as second parameter");
}
}
#endif
......@@ -8,7 +8,7 @@
#else
#include "faust_MatDense.h"
#endif
#include "StoppingCriterion.h"
#include "faust_StoppingCriterion.h"
#include "faust_ConstraintGeneric.h"
/*! \class Faust::Params
......@@ -36,8 +36,8 @@ namespace Faust
const unsigned int nb_fact_,
const std::vector<const Faust::ConstraintGeneric<FPP,DEVICE>*> & cons_,
const std::vector<Faust::MatDense<FPP,DEVICE> >& init_fact_,
const StoppingCriterion<FPP>& stop_crit_2facts_ = StoppingCriterion<FPP>(defaultNiter1),
const StoppingCriterion<FPP>& stop_crit_global_ = StoppingCriterion<FPP>(defaultNiter2),
const Faust::StoppingCriterion<FPP>& stop_crit_2facts_ = Faust::StoppingCriterion<FPP>(defaultNiter1),
const Faust::StoppingCriterion<FPP>& stop_crit_global_ = Faust::StoppingCriterion<FPP>(defaultNiter2),
const FPP residuum_decrease_speed = defaultDecreaseSpeed,
const FPP residuum_prcent = defaultResiduumPercent,
const bool isVerbose_ = defaultVerbosity ,
......@@ -58,8 +58,8 @@ namespace Faust
- cons_[1][j] specifies the constraints for the left factor and<br>
- cons[2][j] for the right factor.<br>
* \param init_fact_ : specifying the initial factors, could be an empty std::vector (not specifying the factors) <br>
* \param stop_crit_2facts : (optional) StoppingCriterion for each 2 factors factorization step <br>
* \param stop_crit_global : (optional) StoppingCriterion for the factorization each global factorization step <br>
* \param stop_crit_2facts : (optional) Faust::StoppingCriterion for each 2 factors factorization step <br>
* \param stop_crit_global : (optional) Faust::StoppingCriterion for the factorization each global factorization step <br>
* \param isVerbose : (optional) - if true the function outputs the error at each iteration <br>
- if false, hierarchical_fact run silent mode<br>
(default value is false) <br>
......@@ -85,8 +85,8 @@ namespace Faust
const unsigned int nb_fact_,
const std::vector<std::vector<const Faust::ConstraintGeneric<FPP,DEVICE>*> >& cons_,
const std::vector<Faust::MatDense<FPP,DEVICE> >& init_fact_,
const StoppingCriterion<FPP>& stop_crit_2facts_ = StoppingCriterion<FPP>(defaultNiter1),
const StoppingCriterion<FPP>& stop_crit_global_ = StoppingCriterion<FPP>(defaultNiter2),
const Faust::StoppingCriterion<FPP>& stop_crit_2facts_ = Faust::StoppingCriterion<FPP>(defaultNiter1),
const Faust::StoppingCriterion<FPP>& stop_crit_global_ = Faust::StoppingCriterion<FPP>(defaultNiter2),
const bool isVerbose_ = defaultVerbosity ,
const bool isUpdateWayR2L_ = defaultUpdateWayR2L ,
const bool isFactSideLeft_ = defaultFactSideLeft ,
......@@ -113,8 +113,8 @@ namespace Faust
std::vector<Faust::MatDense<FPP,DEVICE> > init_fact;
// Optional members (set to default values if not defined)
StoppingCriterion<FPP> stop_crit_2facts;
StoppingCriterion<FPP> stop_crit_global;
Faust::StoppingCriterion<FPP> stop_crit_2facts;
Faust::StoppingCriterion<FPP> stop_crit_global;
bool isVerbose;
bool isUpdateWayR2L;
bool isFactSideLeft;
......@@ -140,10 +140,10 @@ namespace Faust
//const int nb_cols; // number of columns of the last factor
/*const int nb_it; // number of iterations
// if isStoppingCriterionError then criterion is error else criterion is number of iteration
bool isStoppingCriterionError;
// if isFaust::StoppingCriterionError then criterion is error else criterion is number of iteration
bool isFaust::StoppingCriterionError;
const faust_real errorThreshold;
// only used as stopping criterion, if isStoppingCriterionError, when error is still greater than
// only used as stopping criterion, if isFaust::StoppingCriterionError, when error is still greater than
int maxIteration;*/
static const char* class_name;
private :
......
......@@ -2,7 +2,7 @@
#define __FAUST_PARAMS_HPP__
//#include "Faust::Params.h"
#include "StoppingCriterion.h"
#include "faust_StoppingCriterion.h"
#include <iostream>
#include "faust_ConstraintInt.h"
#include "faust_ConstraintFPP.h"
......@@ -74,8 +74,8 @@ Faust::Params<FPP,DEVICE>::Params(
const unsigned int nb_fact_,
const std::vector<const Faust::ConstraintGeneric<FPP,DEVICE>*> & cons_,
const std::vector<Faust::MatDense<FPP,DEVICE> >& init_fact_,
const StoppingCriterion<FPP>& stop_crit_2facts_,
const StoppingCriterion<FPP>& stop_crit_global_,
const Faust::StoppingCriterion<FPP>& stop_crit_2facts_,
const Faust::StoppingCriterion<FPP>& stop_crit_global_,
const FPP residuum_decrease_speed /* = 1.25 */,
const FPP residuum_prcent /* = 1.4 */,
const bool isVerbose_ , /* = false */
......@@ -184,8 +184,8 @@ Faust::Params<FPP,DEVICE>::Params(
const unsigned int nb_fact_,
const std::vector<std::vector<const Faust::ConstraintGeneric<FPP,DEVICE>*> >& cons_,
const std::vector<Faust::MatDense<FPP,DEVICE> >& init_fact_,
const StoppingCriterion<FPP>& stop_crit_2facts_ /* = StoppingCriterion<FPP>() */,
const StoppingCriterion<FPP>& stop_crit_global_ /* = StoppingCriterion<FPP>() */,
const Faust::StoppingCriterion<FPP>& stop_crit_2facts_ /* = Faust::StoppingCriterion<FPP>() */,
const Faust::StoppingCriterion<FPP>& stop_crit_global_ /* = Faust::StoppingCriterion<FPP>() */,
const bool isVerbose_ /* = false */,
const bool isUpdateWayR2L_ /* = false */,
const bool isFactSideLeft_ /* = false */,
......@@ -364,13 +364,13 @@ void Faust::Params<FPP,DEVICE>::init_from_file(const char* filename)
handleError(class_name,"init_from_file : premature end of file");
fscanf(fp,"%d\n",&niter1);
std::cout<<"niter1 : "<<niter1<<std::endl;
StoppingCriterion<FPP> stopcrit2facts(niter1);
Faust::StoppingCriterion<FPP> stopcrit2facts(niter1);
stop_crit_2facts = stopcrit2facts;
if (feof(fp))
handleError(class_name,"init_from_file : premature end of file");
fscanf(fp,"%d\n",&niter2);
std::cout<<"niter2 : "<<niter2<<std::endl;
StoppingCriterion<FPP> stopcritglobal(niter2);
Faust::StoppingCriterion<FPP> stopcritglobal(niter2);
stop_crit_global = stopcritglobal;
vector<const Faust::ConstraintGeneric<FPP,DEVICE> *> consS;
......
......@@ -8,7 +8,7 @@
#else
#include "faust_MatDense.h"
#endif
#include "StoppingCriterion.h"
#include "faust_StoppingCriterion.h"
#include "faust_ConstraintGeneric.h"
......@@ -36,7 +36,7 @@ namespace Faust
const int nb_fact_,
const std::vector<const Faust::ConstraintGeneric<FPP,DEVICE>*>& cons_,
const std::vector<Faust::MatDense<FPP,DEVICE> >& init_fact_,
const StoppingCriterion<FPP> & stop_crit_ = StoppingCriterion<FPP>(defaultNiter),
const Faust::StoppingCriterion<FPP> & stop_crit_ = Faust::StoppingCriterion<FPP>(defaultNiter),
const bool isVerbose_ = defaultVerbosity ,
const bool isUpdateWayR2L_ = defaultUpdateWayR2L ,
const FPP init_lambda_ = defaultLambda,
......@@ -56,7 +56,7 @@ namespace Faust
// Optional members (set to default values if not defined)
std::vector<Faust::MatDense<FPP,DEVICE> > init_fact;
StoppingCriterion<FPP> stop_crit;
Faust::StoppingCriterion<FPP> stop_crit;
bool isVerbose;
bool isUpdateWayR2L;
bool isConstantStepSize;
......@@ -76,7 +76,7 @@ namespace Faust
/*const int nb_it; // number of iterations
// if isStoppingCriterionError then criterion is error else criterion is number of iteration
// if isFaust::StoppingCriterionError then criterion is error else criterion is number of iteration
bool isStoppingCriterionError;
const FPP errorThreshold;
// only used as stopping criterion, if isStoppingCriterionError, when error is still greater than
......
......@@ -2,7 +2,7 @@
#define __FAUST_PARAMS_PALM_HPP__
//#include "faust_ParamsPalm.h"
#include "StoppingCriterion.h"
#include "faust_StoppingCriterion.h"
#include <iostream>
#include <stdexcept>
#include "faust_exception.h"
......@@ -47,7 +47,7 @@ Faust::ParamsPalm<FPP,DEVICE>::ParamsPalm(
const int nb_fact_,
const std::vector<const Faust::ConstraintGeneric<FPP,DEVICE> *>& cons_,
const std::vector<Faust::MatDense<FPP,DEVICE> > & init_fact_,
const StoppingCriterion<FPP> & stop_crit_ /* = StoppingCriterion() */,
const Faust::StoppingCriterion<FPP> & stop_crit_ /* = Faust::StoppingCriterion() */,
const bool isVerbose_ /* = false */,
const bool isUpdateWayR2L_ /* = false */,
const FPP init_lambda_ /* = 1.0 */,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment