Mentions légales du service

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

Add the normalizing attribute to the Constraint class hierarchy along with an associated setter.

The project functions are updated to use the attribute when it applies.
parent 29b693d1
No related branches found
No related tags found
No related merge requests found
......@@ -133,6 +133,7 @@ void Faust::ConstraintFPP<FPP,DEVICE,FPP2>::set_default_parameter()
template<typename FPP,FDevice DEVICE,typename FPP2>
void Faust::ConstraintFPP<FPP,DEVICE,FPP2>::project(Faust::MatDense<FPP,DEVICE> & mat)const
{
// no normalization on the whole matrix for this kind of constraint/prox (normalizing attribute ignored)
switch (this->m_constraintName)
{
case CONSTRAINT_NAME_NORMCOL:
......
......@@ -80,20 +80,23 @@ namespace Faust
class ConstraintGeneric
{
public:
ConstraintGeneric() : m_constraintName(CONSTRAINT_NAME_SP),m_nbRows(32),m_nbCols(32) {} // contrainte par defaut (a voir avec Luc)
ConstraintGeneric() : m_constraintName(CONSTRAINT_NAME_SP),m_nbRows(32),m_nbCols(32), normalizing(true) {} // contrainte par defaut (a voir avec Luc)
ConstraintGeneric(
const faust_constraint_name& constraintName_,
const faust_unsigned_int nbRows_,
const faust_unsigned_int nbCols_) :
const faust_unsigned_int nbCols_,
const bool normalizing=true) :
m_constraintName(constraintName_),
m_nbRows(nbRows_),
m_nbCols(nbCols_){}
m_nbCols(nbCols_),
normalizing(normalizing){}
ConstraintGeneric(const ConstraintGeneric& constraint) :
m_constraintName(constraint.m_constraintName),
m_nbRows(constraint.m_nbRows),
m_nbCols(constraint.m_nbCols){}
m_nbCols(constraint.m_nbCols),
normalizing(constraint.normalizing){}
......@@ -115,6 +118,7 @@ namespace Faust
virtual void Display() const;
virtual void set_default_parameter()=0;
virtual void check_constraint_name()const=0;
void set_normalizing(const bool normalizing) {this->normalizing = normalizing;}
template<typename FPP, FDevice DEVICE>
/*virtual*/ void project(MatDense<FPP,DEVICE> & mat)const;//=0; //template with (pure) virtual not authorized (otherwise it must be templates from class, not function)
template<typename FPP, FDevice DEVICE, typename FPP2>
......@@ -131,6 +135,8 @@ namespace Faust
//const parameter_type parameter;
const faust_unsigned_int m_nbRows;
const faust_unsigned_int m_nbCols;
// \brief if normalizing is true the project function should normalize the result matrix
bool normalizing;
private :
static const char * m_className;
......
......@@ -156,22 +156,22 @@ void Faust::ConstraintInt<FPP,DEVICE>::project(Faust::MatDense<FPP,DEVICE> & mat
switch (this->m_constraintName)
{
case CONSTRAINT_NAME_SP:
Faust::prox_sp(mat,m_parameter);
Faust::prox_sp(mat,m_parameter, normalizing);
break;
case CONSTRAINT_NAME_SPCOL:
Faust::prox_spcol(mat,m_parameter);
Faust::prox_spcol(mat,m_parameter, normalizing);
break;
case CONSTRAINT_NAME_SPLIN:
Faust::prox_splin(mat,m_parameter);
Faust::prox_splin(mat,m_parameter, normalizing);
break;
case CONSTRAINT_NAME_SPLINCOL:
Faust::prox_splincol(mat,m_parameter);
Faust::prox_splincol(mat,m_parameter, normalizing);
break;
case CONSTRAINT_NAME_SP_POS:
Faust::prox_sp_pos(mat,m_parameter);
Faust::prox_sp_pos(mat,m_parameter, normalizing);
break;
case CONSTRAINT_NAME_SKPERM:
Faust::prox_skperm(mat,m_parameter);
Faust::prox_skperm(mat,m_parameter, normalizing);
break;
default:
handleError(m_className,"project : cannot project with this constraint name");
......@@ -185,17 +185,17 @@ Faust::MatGeneric<FPP,DEVICE>* Faust::ConstraintInt<FPP,DEVICE>::project_gen(Fau
switch (this->m_constraintName)
{
case CONSTRAINT_NAME_SP:
return Faust::prox_sp_gen(mat,m_parameter);
return Faust::prox_sp_gen(mat,m_parameter, normalizing);
case CONSTRAINT_NAME_SPCOL:
return Faust::prox_spcol_gen(mat,m_parameter);
return Faust::prox_spcol_gen(mat,m_parameter, normalizing);
case CONSTRAINT_NAME_SPLIN:
return Faust::prox_splin_gen(mat,m_parameter);
return Faust::prox_splin_gen(mat,m_parameter, normalizing);
case CONSTRAINT_NAME_SPLINCOL:
return Faust::prox_splincol_gen(mat,m_parameter);
return Faust::prox_splincol_gen(mat,m_parameter, normalizing);
case CONSTRAINT_NAME_SP_POS:
return Faust::prox_sp_gen(mat, m_parameter, /*normalized */ true, /*pos*/ true);
return Faust::prox_sp_gen(mat, m_parameter, normalizing, /*pos*/ true);
case CONSTRAINT_NAME_SKPERM:
return Faust::prox_skperm_gen(mat,m_parameter);
return Faust::prox_skperm_gen(mat,m_parameter, normalizing);
default:
handleError(m_className,"project : cannot project with this constraint name");
break;
......
......@@ -147,22 +147,22 @@ void Faust::ConstraintMat<FPP,DEVICE>::project(Faust::MatDense<FPP,DEVICE> & mat
{
case CONSTRAINT_NAME_CONST:
//mat=m_parameter;
Faust::prox_const(mat, m_parameter, false);
Faust::prox_const(mat, m_parameter, false); // normalizing is ignored for the CONST prox
break;
case CONSTRAINT_NAME_SUPP:
Faust::prox_supp(mat,m_parameter, true);
Faust::prox_supp(mat,m_parameter, normalizing);
break;
case CONSTRAINT_NAME_TOEPLITZ:
Faust::prox_toeplitz(mat);
Faust::prox_toeplitz(mat, normalizing);
break;
case CONSTRAINT_NAME_CIRC:
Faust::prox_circ(mat);
Faust::prox_circ(mat, normalizing);
break;
case CONSTRAINT_NAME_HANKEL:
Faust::prox_hankel(mat);
Faust::prox_hankel(mat, normalizing);
break;
case CONSTRAINT_NAME_BLKDIAG:
Faust::prox_blockdiag(mat, m_parameter, true);
Faust::prox_blockdiag(mat, m_parameter, normalizing);
break;
default:
handleError(m_className,"project : invalid constraint_name");
......@@ -177,17 +177,17 @@ Faust::MatGeneric<FPP,DEVICE>* Faust::ConstraintMat<FPP,DEVICE>::project_gen(Fau
{
case CONSTRAINT_NAME_CONST:
//mat=m_parameter;
return Faust::prox_const_gen(mat, m_parameter, false);
return Faust::prox_const_gen(mat, m_parameter, false); // normalizing is ignored for the CONST prox
case CONSTRAINT_NAME_SUPP:
return Faust::prox_supp_gen(mat,m_parameter, true);
return Faust::prox_supp_gen(mat,m_parameter, normalizing);
case CONSTRAINT_NAME_TOEPLITZ:
// return Faust::prox_toeplitz_gen(mat);
return Faust::prox_toeplitz_gen(mat, normalizing);
case CONSTRAINT_NAME_CIRC:
return Faust::prox_circ_gen(mat);
return Faust::prox_circ_gen(mat, normalizing);
case CONSTRAINT_NAME_HANKEL:
return Faust::prox_hankel_gen(mat);
return Faust::prox_hankel_gen(mat, normalizing);
case CONSTRAINT_NAME_BLKDIAG:
return Faust::prox_blockdiag_gen(mat, m_parameter, true);
return Faust::prox_blockdiag_gen(mat, m_parameter, normalizing);
default:
handleError(m_className,"project : invalid constraint_name");
break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment