Mentions légales du service

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

Minor change: properly rename Faust::HierarchicalFactFFT to...

Minor change: properly rename Faust::HierarchicalFactFFT to HierarchicalFactFGFT, Palm4MSAFFT to Palm4MSAFGFT and their params classes too.
parent ff1b04b2
Branches
Tags
No related merge requests found
Showing
with 93 additions and 93 deletions
#include "faust_MatSparse.h" #include "faust_MatSparse.h"
#include "faust_HierarchicalFactFFT.h" #include "faust_HierarchicalFactFGFT.h"
#include "faust_Timer.h" #include "faust_Timer.h"
#include "faust_Transform.h" #include "faust_Transform.h"
#include "faust_init_from_matio_params.h" #include "faust_init_from_matio_params.h"
#include "faust_init_from_matio_core.h" #include "faust_init_from_matio_core.h"
#include "faust_ParamsFFT.h" #include "faust_ParamsFGFT.h"
#include <string> #include <string>
#include <sstream> #include <sstream>
#include "faust_BlasHandle.h" #include "faust_BlasHandle.h"
...@@ -103,7 +103,7 @@ int main(int argc, char* argv[]) ...@@ -103,7 +103,7 @@ int main(int argc, char* argv[])
Faust::SpBlasHandle<Cpu> spblasHandle; Faust::SpBlasHandle<Cpu> spblasHandle;
// parameter setting // parameter setting
Faust::ParamsFFT<FPP,Cpu,FPP2> params; Faust::ParamsFGFT<FPP,Cpu,FPP2> params;
init_params_from_matiofile<FPP,Cpu,FPP2>(params,configFilename.c_str(),"params"); init_params_from_matiofile<FPP,Cpu,FPP2>(params,configFilename.c_str(),"params");
// params.init_D = Faust::MatDense<FPP,Cpu>::eye(params.m_nbRow, params.m_nbCol); // params.init_D = Faust::MatDense<FPP,Cpu>::eye(params.m_nbRow, params.m_nbCol);
// init_faust_mat_from_matio(params.init_D,U_Filename.c_str(),"init_D"); // init_faust_mat_from_matio(params.init_D,U_Filename.c_str(),"init_D");
...@@ -143,7 +143,7 @@ int main(int argc, char* argv[]) ...@@ -143,7 +143,7 @@ int main(int argc, char* argv[])
U.transpose(); U.transpose();
//algorithm //algorithm
Faust::HierarchicalFactFFT<FPP,Cpu,FPP2> hierFact(U,Lap,params,blasHandle,spblasHandle); Faust::HierarchicalFactFGFT<FPP,Cpu,FPP2> hierFact(U,Lap,params,blasHandle,spblasHandle);
Faust::HierarchicalFact<FPP,Cpu,FPP2> hierFact_(U,params,blasHandle,spblasHandle); Faust::HierarchicalFact<FPP,Cpu,FPP2> hierFact_(U,params,blasHandle,spblasHandle);
doit(&hierFact, argc, expectedLambda, epsilon, U, Lap, ref_facts); doit(&hierFact, argc, expectedLambda, epsilon, U, Lap, ref_facts);
...@@ -215,8 +215,8 @@ void doit(HierarchicalFact<FPP,Cpu,FPP2>* hierFact, int argc, FPP expectedLambda ...@@ -215,8 +215,8 @@ void doit(HierarchicalFact<FPP,Cpu,FPP2>* hierFact, int argc, FPP expectedLambda
std::cout<<std::endl; std::cout<<std::endl;
std::cout<<"**************** RELATIVE ERROR BETWEEN FAUST AND Fourier MATRIX **************** "<<std::endl; std::cout<<"**************** RELATIVE ERROR BETWEEN FAUST AND Fourier MATRIX **************** "<<std::endl;
std::cout<<" "<<relativeError<<std::endl<<std::endl; std::cout<<" "<<relativeError<<std::endl<<std::endl;
HierarchicalFactFFT<FPP,Cpu,FPP2> *hierFactFFT; HierarchicalFactFGFT<FPP,Cpu,FPP2> *hierFactFFT;
if(hierFactFFT = dynamic_cast<HierarchicalFactFFT<FPP,Cpu, FPP2>*>(hierFact)) if(hierFactFFT = dynamic_cast<HierarchicalFactFGFT<FPP,Cpu, FPP2>*>(hierFact))
{ {
//relativeError 2 //relativeError 2
......
...@@ -40,11 +40,11 @@ ...@@ -40,11 +40,11 @@
/****************************************************************************//*}}}*//*}}}*//*}}}*/ /****************************************************************************//*}}}*//*}}}*//*}}}*/
#include "faust_MatDense.h" #include "faust_MatDense.h"
#include "faust_Params.h" #include "faust_Params.h"
#include "faust_ParamsPalmFFT.h" #include "faust_ParamsPalmFGFT.h"
#include "faust_StoppingCriterion.h" #include "faust_StoppingCriterion.h"
#include "faust_init_from_matio.h" #include "faust_init_from_matio.h"
#include "faust_init_from_matio_mat.h" #include "faust_init_from_matio_mat.h"
#include "faust_Palm4MSAFFT.h" #include "faust_Palm4MSAFGFT.h"
#include "faust_BlasHandle.h" #include "faust_BlasHandle.h"
#include <iostream> #include <iostream>
...@@ -120,7 +120,7 @@ int main() ...@@ -120,7 +120,7 @@ int main()
Faust::StoppingCriterion<FPP2> crit(niter); Faust::StoppingCriterion<FPP2> crit(niter);
Faust::ParamsPalmFFT<FPP,Cpu,FPP2> params(data, nfacts, cons, initFact, init_D, crit, verbose, updateWay, initLambda, step_size); Faust::ParamsPalmFGFT<FPP,Cpu,FPP2> params(data, nfacts, cons, initFact, init_D, crit, verbose, updateWay, initLambda, step_size);
params.isVerbose = true; params.isVerbose = true;
#ifdef DEBUG #ifdef DEBUG
...@@ -135,7 +135,7 @@ int main() ...@@ -135,7 +135,7 @@ int main()
Faust::BlasHandle<Cpu> blasHandle; Faust::BlasHandle<Cpu> blasHandle;
Faust::Palm4MSAFFT<FPP,Cpu,FPP2> palm2(params,blasHandle,true); Faust::Palm4MSAFGFT<FPP,Cpu,FPP2> palm2(params,blasHandle,true);
......
template<typename FPP,Device DEVICE,typename FPP2>
const char * Faust::HierarchicalFactFFT<FPP,DEVICE,FPP2>::m_className="Faust::HierarchicalFactFFT";
template<typename FPP,Device DEVICE,typename FPP2>
void Faust::HierarchicalFactFFT<FPP,DEVICE,FPP2>::get_D(FPP* out_diag) const
{
return dynamic_cast<Palm4MSAFFT<FPP,Cpu,FPP2>*>(this->palm_global)->get_D(out_diag);
}
template<typename FPP,Device DEVICE,typename FPP2>
const Faust::MatDense<FPP, DEVICE>& Faust::HierarchicalFactFFT<FPP,DEVICE,FPP2>::get_D()
{
return dynamic_cast<Palm4MSAFFT<FPP,Cpu,FPP2>*>(this->palm_global)->get_D();
}
#ifndef __FAUST_HIERARCHICAL_FACT_FFT_H__ #ifndef __FAUST_HIERARCHICAL_FACT_FGFT_H__
#define __FAUST_HIERARCHICAL_FACT_FFT_H__ #define __FAUST_HIERARCHICAL_FACT_FGFT_H__
#include "faust_Palm4MSAFFT.h" #include "faust_Palm4MSAFGFT.h"
#include "faust_ParamsFFT.h" #include "faust_ParamsFGFT.h"
#include "faust_HierarchicalFact.h" #include "faust_HierarchicalFact.h"
using namespace Faust; using namespace Faust;
...@@ -9,21 +9,21 @@ using namespace Faust; ...@@ -9,21 +9,21 @@ using namespace Faust;
namespace Faust namespace Faust
{ {
template<typename FPP,Device DEVICE,typename FPP2 = double> template<typename FPP,Device DEVICE,typename FPP2 = double>
class HierarchicalFactFFT : public HierarchicalFact<FPP, DEVICE, FPP2> class HierarchicalFactFGFT : public HierarchicalFact<FPP, DEVICE, FPP2>
{ {
static const char * m_className; static const char * m_className;
public: public:
//TODO: move def. code in .hpp //TODO: move def. code in .hpp
HierarchicalFactFFT(const MatDense<FPP,DEVICE>& U, const MatDense<FPP,DEVICE>& Lap, const ParamsFFT<FPP,DEVICE,FPP2>& params, BlasHandle<DEVICE> cublasHandle, SpBlasHandle<DEVICE> cusparseHandle): HierarchicalFact<FPP, DEVICE, FPP2>(U, params, cublasHandle, cusparseHandle) HierarchicalFactFGFT(const MatDense<FPP,DEVICE>& U, const MatDense<FPP,DEVICE>& Lap, const ParamsFGFT<FPP,DEVICE,FPP2>& params, BlasHandle<DEVICE> cublasHandle, SpBlasHandle<DEVICE> cusparseHandle): HierarchicalFact<FPP, DEVICE, FPP2>(U, params, cublasHandle, cusparseHandle)
{ {
if ((U.getNbRow() != params.m_nbRow) | (U.getNbCol() != params.m_nbCol)) if ((U.getNbRow() != params.m_nbRow) | (U.getNbCol() != params.m_nbCol))
handleError(m_className,"constructor : params and Fourier matrix U haven't compatible size"); handleError(m_className,"constructor : params and Fourier matrix U haven't compatible size");
if((Lap.getNbRow() != params.m_nbRow) | (Lap.getNbCol() != params.m_nbCol)) if((Lap.getNbRow() != params.m_nbRow) | (Lap.getNbCol() != params.m_nbCol))
handleError(m_className,"constructor : params and Laplacian matrix Lap haven't compatible size"); handleError(m_className,"constructor : params and Laplacian matrix Lap haven't compatible size");
delete this->palm_global; delete this->palm_global;
this->palm_global = new Palm4MSAFFT<FPP,DEVICE,FPP2>(Lap, params, cublasHandle, true); this->palm_global = new Palm4MSAFGFT<FPP,DEVICE,FPP2>(Lap, params, cublasHandle, true);
} }
...@@ -41,6 +41,6 @@ namespace Faust ...@@ -41,6 +41,6 @@ namespace Faust
}; };
} }
#include "faust_HierarchicalFactFFT.hpp" #include "faust_HierarchicalFactFGFT.hpp"
#endif #endif
template<typename FPP,Device DEVICE,typename FPP2>
const char * Faust::HierarchicalFactFGFT<FPP,DEVICE,FPP2>::m_className="Faust::HierarchicalFactFGFT";
template<typename FPP,Device DEVICE,typename FPP2>
void Faust::HierarchicalFactFGFT<FPP,DEVICE,FPP2>::get_D(FPP* out_diag) const
{
return dynamic_cast<Palm4MSAFGFT<FPP,Cpu,FPP2>*>(this->palm_global)->get_D(out_diag);
}
template<typename FPP,Device DEVICE,typename FPP2>
const Faust::MatDense<FPP, DEVICE>& Faust::HierarchicalFactFGFT<FPP,DEVICE,FPP2>::get_D()
{
return dynamic_cast<Palm4MSAFGFT<FPP,Cpu,FPP2>*>(this->palm_global)->get_D();
}
...@@ -57,7 +57,7 @@ namespace Faust ...@@ -57,7 +57,7 @@ namespace Faust
template<typename FPP,Device DEVICE> class MatDense; template<typename FPP,Device DEVICE> class MatDense;
template<typename FPP,Device DEVICE> class Transform; template<typename FPP,Device DEVICE> class Transform;
template<typename FPP, Device DEVICE, typename FPP2> class HierarchicalFactFFT; template<typename FPP, Device DEVICE, typename FPP2> class HierarchicalFactFGFT;
class ConstraintGeneric; class ConstraintGeneric;
template<typename FPP,Device DEVICE, typename FPP2> class Params; template<typename FPP,Device DEVICE, typename FPP2> class Params;
...@@ -77,7 +77,7 @@ namespace Faust ...@@ -77,7 +77,7 @@ namespace Faust
template<typename FPP,Device DEVICE,typename FPP2 = double> template<typename FPP,Device DEVICE,typename FPP2 = double>
class Palm4MSA class Palm4MSA
{ {
// friend class Faust::HierarchicalFactFFT<FPP,DEVICE, FPP2>; // friend class Faust::HierarchicalFactFGFT<FPP,DEVICE, FPP2>;
public: public:
/*! /*!
......
#include "faust_ParamsPalmFFT.h" #include "faust_ParamsPalmFGFT.h"
#include "faust_Palm4MSA.h" #include "faust_Palm4MSA.h"
#include "faust_ParamsFFT.h" #include "faust_ParamsFGFT.h"
#ifndef __FAUST_PALM4MSA_FFT_H__ #ifndef __FAUST_PALM4MSA_FGFT_H__
#define __FAUST_PALM4MSA_FFT_H__ #define __FAUST_PALM4MSA_FGFT_H__
using namespace Faust; using namespace Faust;
namespace Faust { namespace Faust {
template<typename FPP, Device DEVICE, typename FPP2 = double> template<typename FPP, Device DEVICE, typename FPP2 = double>
class Palm4MSAFFT : public Palm4MSA<FPP, DEVICE, FPP2> class Palm4MSAFGFT : public Palm4MSA<FPP, DEVICE, FPP2>
{ {
MatDense<FPP, DEVICE> D; //TODO: later it will need to be Sparse (which needs to add a prototype overload for multiplication in faust_linear_algebra.h) MatDense<FPP, DEVICE> D; //TODO: later it will need to be Sparse (which needs to add a prototype overload for multiplication in faust_linear_algebra.h)
MatDense<FPP,DEVICE> D_grad_over_c; //TODO: move to sparse mat later MatDense<FPP,DEVICE> D_grad_over_c; //TODO: move to sparse mat later
public: public:
//TODO: another ctor (like in Palm4MSA) for hierarchical algo. use //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); Palm4MSAFGFT(const ParamsPalmFGFT<FPP, DEVICE, FPP2>& params, const BlasHandle<DEVICE> blasHandle, const bool isGlobal=false);
Palm4MSAFFT(const MatDense<FPP,DEVICE>& Lap, const ParamsFFT<FPP,DEVICE,FPP2> & params, const BlasHandle<DEVICE> blasHandle, const bool isGlobal); Palm4MSAFGFT(const MatDense<FPP,DEVICE>& Lap, const ParamsFGFT<FPP,DEVICE,FPP2> & params, const BlasHandle<DEVICE> blasHandle, const bool isGlobal);
void next_step(); void next_step();
const MatDense<FPP, DEVICE>& get_D(); const MatDense<FPP, DEVICE>& get_D();
void get_D(FPP* diag_data); void get_D(FPP* diag_data);
...@@ -29,7 +29,7 @@ namespace Faust { ...@@ -29,7 +29,7 @@ namespace Faust {
void compute_c(); void compute_c();
}; };
#include "faust_Palm4MSAFFT.hpp" #include "faust_Palm4MSAFGFT.hpp"
} }
......
#include <cstring> #include <cstring>
template <typename FPP, Device DEVICE, typename FPP2> 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), D(params.init_D) Palm4MSAFGFT<FPP,DEVICE,FPP2>::Palm4MSAFGFT(const ParamsPalmFGFT<FPP, DEVICE, FPP2>& params, const BlasHandle<DEVICE> blasHandle, const bool isGlobal) : Palm4MSA<FPP,DEVICE,FPP2>(params, blasHandle, isGlobal), D(params.init_D)
{ {
//TODO: is there something to check additionally to what parent's ctor checks ? //TODO: is there something to check additionally to what parent's ctor checks ?
} }
template<typename FPP,Device DEVICE,typename FPP2> template<typename FPP,Device DEVICE,typename FPP2>
Palm4MSAFFT<FPP,DEVICE,FPP2>::Palm4MSAFFT(const MatDense<FPP,DEVICE>& Lap, const ParamsFFT<FPP,DEVICE,FPP2> & params, const BlasHandle<DEVICE> blasHandle, const bool isGlobal) : Palm4MSA<FPP,DEVICE,FPP2>(Lap, params, blasHandle, isGlobal), D(params.init_D) Palm4MSAFGFT<FPP,DEVICE,FPP2>::Palm4MSAFGFT(const MatDense<FPP,DEVICE>& Lap, const ParamsFGFT<FPP,DEVICE,FPP2> & params, const BlasHandle<DEVICE> blasHandle, const bool isGlobal) : Palm4MSA<FPP,DEVICE,FPP2>(Lap, params, blasHandle, isGlobal), D(params.init_D)
{ {
} }
template <typename FPP, Device DEVICE, typename FPP2> template <typename FPP, Device DEVICE, typename FPP2>
void Palm4MSAFFT<FPP,DEVICE,FPP2>::compute_grad_over_c() void Palm4MSAFGFT<FPP,DEVICE,FPP2>::compute_grad_over_c()
{ {
if(!this->isCComputed) if(!this->isCComputed)
...@@ -147,7 +147,7 @@ void Palm4MSAFFT<FPP,DEVICE,FPP2>::compute_grad_over_c() ...@@ -147,7 +147,7 @@ void Palm4MSAFFT<FPP,DEVICE,FPP2>::compute_grad_over_c()
template <typename FPP, Device DEVICE, typename FPP2> template <typename FPP, Device DEVICE, typename FPP2>
void Palm4MSAFFT<FPP,DEVICE,FPP2>::compute_lambda() void Palm4MSAFGFT<FPP,DEVICE,FPP2>::compute_lambda()
{ {
// override parent's method // override parent's method
// Xhat = (S[0]*...*S[nfact-1])*D*(S[0]*...*S[nfact-1])' // Xhat = (S[0]*...*S[nfact-1])*D*(S[0]*...*S[nfact-1])'
...@@ -168,11 +168,11 @@ void Palm4MSAFFT<FPP,DEVICE,FPP2>::compute_lambda() ...@@ -168,11 +168,11 @@ void Palm4MSAFFT<FPP,DEVICE,FPP2>::compute_lambda()
this->LorR = tmp; this->LorR = tmp;
//then we finish the lambda computation with a sqrt() (Fro. norm) //then we finish the lambda computation with a sqrt() (Fro. norm)
this->m_lambda = std::sqrt(/*Faust::abs(*/this->m_lambda);//); this->m_lambda = std::sqrt(/*Faust::abs(*/this->m_lambda);//);
// (that's an additional operation in Palm4MSAFFT) // (that's an additional operation in Palm4MSAFGFT)
} }
template <typename FPP, Device DEVICE, typename FPP2> template <typename FPP, Device DEVICE, typename FPP2>
void Palm4MSAFFT<FPP,DEVICE,FPP2>::next_step() void Palm4MSAFGFT<FPP,DEVICE,FPP2>::next_step()
{ {
Palm4MSA<FPP, Cpu, FPP2>::next_step(); Palm4MSA<FPP, Cpu, FPP2>::next_step();
// besides to what the parent has done // besides to what the parent has done
...@@ -184,7 +184,7 @@ void Palm4MSAFFT<FPP,DEVICE,FPP2>::next_step() ...@@ -184,7 +184,7 @@ void Palm4MSAFFT<FPP,DEVICE,FPP2>::next_step()
template <typename FPP, Device DEVICE, typename FPP2> template <typename FPP, Device DEVICE, typename FPP2>
void Palm4MSAFFT<FPP,DEVICE,FPP2>::compute_D() void Palm4MSAFGFT<FPP,DEVICE,FPP2>::compute_D()
{ {
// besides to what the parent has done // besides to what the parent has done
// we need to update D // we need to update D
...@@ -200,7 +200,7 @@ void Palm4MSAFFT<FPP,DEVICE,FPP2>::compute_D() ...@@ -200,7 +200,7 @@ void Palm4MSAFFT<FPP,DEVICE,FPP2>::compute_D()
} }
template <typename FPP, Device DEVICE, typename FPP2> template <typename FPP, Device DEVICE, typename FPP2>
void Palm4MSAFFT<FPP,DEVICE,FPP2>::compute_D_grad_over_c() void Palm4MSAFGFT<FPP,DEVICE,FPP2>::compute_D_grad_over_c()
{ {
// Uhat = lambda*LorR // Uhat = lambda*LorR
// grad = 0.5*Uhat'*(Uhat*D*Uhat' - X)*Uhat // grad = 0.5*Uhat'*(Uhat*D*Uhat' - X)*Uhat
...@@ -216,13 +216,13 @@ void Palm4MSAFFT<FPP,DEVICE,FPP2>::compute_D_grad_over_c() ...@@ -216,13 +216,13 @@ void Palm4MSAFFT<FPP,DEVICE,FPP2>::compute_D_grad_over_c()
} }
template <typename FPP, Device DEVICE, typename FPP2> template <typename FPP, Device DEVICE, typename FPP2>
const MatDense<FPP, DEVICE>& Palm4MSAFFT<FPP,DEVICE,FPP2>::get_D() const MatDense<FPP, DEVICE>& Palm4MSAFGFT<FPP,DEVICE,FPP2>::get_D()
{ {
return this->D; return this->D;
} }
template <typename FPP, Device DEVICE, typename FPP2> template <typename FPP, Device DEVICE, typename FPP2>
void Palm4MSAFFT<FPP,DEVICE,FPP2>::get_D(FPP* diag_data) void Palm4MSAFGFT<FPP,DEVICE,FPP2>::get_D(FPP* diag_data)
{ {
for(int i=0;i<D.getNbRow();i++) for(int i=0;i<D.getNbRow();i++)
diag_data[i] = D.getData()[i*D.getNbRow()+i]; diag_data[i] = D.getData()[i*D.getNbRow()+i];
...@@ -230,9 +230,9 @@ void Palm4MSAFFT<FPP,DEVICE,FPP2>::get_D(FPP* diag_data) ...@@ -230,9 +230,9 @@ void Palm4MSAFFT<FPP,DEVICE,FPP2>::get_D(FPP* diag_data)
} }
template <typename FPP, Device DEVICE, typename FPP2> template <typename FPP, Device DEVICE, typename FPP2>
void Palm4MSAFFT<FPP,DEVICE,FPP2>::compute_c() void Palm4MSAFGFT<FPP,DEVICE,FPP2>::compute_c()
{ {
//do nothing because the Palm4MSAFFT has always a constant step size //do nothing because the Palm4MSAFGFT has always a constant step size
this->isCComputed = true; this->isCComputed = true;
} }
#ifndef __FAUST_PARAMSFFT_H__ #ifndef __FAUST_PARAMSFGFT_H__
#define __FAUST_PARAMSFFT_H__ #define __FAUST_PARAMSFGFT_H__
#include "faust_Params.h" #include "faust_Params.h"
...@@ -9,14 +9,14 @@ using namespace Faust; ...@@ -9,14 +9,14 @@ using namespace Faust;
namespace Faust namespace Faust
{ {
template<typename FPP, Device DEVICE, typename FPP2 = double> template<typename FPP, Device DEVICE, typename FPP2 = double>
class ParamsFFT : public Params<FPP, DEVICE, FPP2> class ParamsFGFT : public Params<FPP, DEVICE, FPP2>
{ {
public: public:
MatDense<FPP, DEVICE> init_D; //TODO: convert to Sparse or Diag repres. and set private or protected MatDense<FPP, DEVICE> init_D; //TODO: convert to Sparse or Diag repres. and set private or protected
//TODO: does it really need to be public //TODO: does it really need to be public
//TODO: move the ctor def into .hpp //TODO: move the ctor def into .hpp
ParamsFFT( ParamsFGFT(
const faust_unsigned_int nbRow, const faust_unsigned_int nbRow,
const faust_unsigned_int nbCol, const faust_unsigned_int nbCol,
const unsigned int nbFact, const unsigned int nbFact,
...@@ -35,7 +35,7 @@ namespace Faust ...@@ -35,7 +35,7 @@ namespace Faust
} }
ParamsFFT( ParamsFGFT(
const faust_unsigned_int nbRow, const faust_unsigned_int nbRow,
const faust_unsigned_int nbCol, const faust_unsigned_int nbCol,
const unsigned int nbFact, const unsigned int nbFact,
...@@ -57,7 +57,7 @@ namespace Faust ...@@ -57,7 +57,7 @@ namespace Faust
init_D.getData()[i*nbRow+i] = init_D_diag.getData()[i]; init_D.getData()[i*nbRow+i] = init_D_diag.getData()[i];
} }
ParamsFFT( ParamsFGFT(
const faust_unsigned_int nbRow, const faust_unsigned_int nbRow,
const faust_unsigned_int nbCol, const faust_unsigned_int nbCol,
const unsigned int nbFact, const unsigned int nbFact,
...@@ -71,14 +71,14 @@ namespace Faust ...@@ -71,14 +71,14 @@ namespace Faust
const bool isFactSideLeft = Params<FPP,DEVICE,FPP2>::defaultFactSideLeft, const bool isFactSideLeft = Params<FPP,DEVICE,FPP2>::defaultFactSideLeft,
const FPP init_lambda = Params<FPP,DEVICE,FPP2>::defaultLambda, const FPP init_lambda = Params<FPP,DEVICE,FPP2>::defaultLambda,
const bool constant_step_size = Params<FPP,DEVICE,FPP2>::defaultConstantStepSize, const bool constant_step_size = Params<FPP,DEVICE,FPP2>::defaultConstantStepSize,
const FPP step_size = Params<FPP,DEVICE,FPP2>::defaultStepSize): ParamsFFT<FPP, DEVICE, FPP2>(nbRow, nbCol, nbFact, cons, init_fact, Faust::Vect<FPP,DEVICE>(nbRow, init_D_diag), stop_crit_2facts, stop_crit_global, isVerbose, isUpdateWayR2L, isFactSideLeft, init_lambda, constant_step_size, step_size) const FPP step_size = Params<FPP,DEVICE,FPP2>::defaultStepSize): ParamsFGFT<FPP, DEVICE, FPP2>(nbRow, nbCol, nbFact, cons, init_fact, Faust::Vect<FPP,DEVICE>(nbRow, init_D_diag), stop_crit_2facts, stop_crit_global, isVerbose, isUpdateWayR2L, isFactSideLeft, init_lambda, constant_step_size, step_size)
{ {
} }
ParamsFFT() {} ParamsFGFT() {}
void Display() const; void Display() const;
...@@ -86,6 +86,6 @@ namespace Faust ...@@ -86,6 +86,6 @@ namespace Faust
}; };
} }
#include "faust_ParamsFFT.hpp" #include "faust_ParamsFGFT.hpp"
#endif #endif
template<typename FPP,Device DEVICE,typename FPP2> template<typename FPP,Device DEVICE,typename FPP2>
void Faust::ParamsFFT<FPP,DEVICE,FPP2>::Display() const void Faust::ParamsFGFT<FPP,DEVICE,FPP2>::Display() const
{ {
Faust::Params<FPP,DEVICE,FPP2>::Display(); Faust::Params<FPP,DEVICE,FPP2>::Display();
cout << "init_D isIdentity:" << init_D.estIdentite() << endl; cout << "init_D isIdentity:" << init_D.estIdentite() << endl;
cout << "init_D info:" << endl; cout << "init_D info:" << endl;
init_D.Display(); init_D.Display();
cout << "ParamsFFT init_D norm: " << init_D.norm() << endl; cout << "ParamsFGFT init_D norm: " << init_D.norm() << endl;
} }
#ifndef __FAUST_PARAMS_PALM_FFT_H__ #ifndef __FAUST_PARAMS_PALM_FGFT_H__
#define __FAUST_PARAMS_PALM_FFT_H__ #define __FAUST_PARAMS_PALM_FGFT_H__
#include "faust_ParamsPalm.h" #include "faust_ParamsPalm.h"
...@@ -10,13 +10,13 @@ namespace Faust ...@@ -10,13 +10,13 @@ namespace Faust
template<typename FPP, Device DEVICE, typename FPP2 = double> template<typename FPP, Device DEVICE, typename FPP2 = double>
class ParamsPalmFFT : public Faust::ParamsPalm<FPP,DEVICE,FPP2> class ParamsPalmFGFT : public Faust::ParamsPalm<FPP,DEVICE,FPP2>
{ {
public: public:
//ctor definitions in header because it consists mainly to call parent ctor //ctor definitions in header because it consists mainly to call parent ctor
ParamsPalmFFT(const Faust::MatDense<FPP,DEVICE>& data_, ParamsPalmFGFT(const Faust::MatDense<FPP,DEVICE>& data_,
const int nbFact_, const int nbFact_,
const std::vector<const Faust::ConstraintGeneric*>& cons_, const std::vector<const Faust::ConstraintGeneric*>& cons_,
const std::vector<Faust::MatDense<FPP,DEVICE> >& init_fact_, const std::vector<Faust::MatDense<FPP,DEVICE> >& init_fact_,
...@@ -25,11 +25,11 @@ namespace Faust ...@@ -25,11 +25,11 @@ namespace Faust
const bool isVerbose_ = ParamsPalm<FPP,DEVICE,FPP2>::defaultVerbosity , const bool isVerbose_ = ParamsPalm<FPP,DEVICE,FPP2>::defaultVerbosity ,
const bool isUpdateWayR2L_ = ParamsPalm<FPP,DEVICE,FPP2>::defaultUpdateWayR2L , const bool isUpdateWayR2L_ = ParamsPalm<FPP,DEVICE,FPP2>::defaultUpdateWayR2L ,
const FPP init_lambda_ = ParamsPalm<FPP,DEVICE,FPP2>::defaultLambda, const FPP init_lambda_ = ParamsPalm<FPP,DEVICE,FPP2>::defaultLambda,
const FPP step_size_ = ParamsPalm<FPP,DEVICE,FPP2>::defaultStepSize) : ParamsPalm<FPP, DEVICE, FPP2>(data_, nbFact_, cons_, init_fact_, stop_crit_, isVerbose_, isUpdateWayR2L_, init_lambda_, true /*constant_step_size is always true for Palm4MSAFFT */, step_size_), init_D(init_D) {} const FPP step_size_ = ParamsPalm<FPP,DEVICE,FPP2>::defaultStepSize) : ParamsPalm<FPP, DEVICE, FPP2>(data_, nbFact_, cons_, init_fact_, stop_crit_, isVerbose_, isUpdateWayR2L_, init_lambda_, true /*constant_step_size is always true for Palm4MSAFGFT */, step_size_), init_D(init_D) {}
ParamsPalmFFT() : ParamsPalm<FPP,DEVICE,FPP2>(), init_D(0,0) {} ParamsPalmFGFT() : ParamsPalm<FPP,DEVICE,FPP2>(), init_D(0,0) {}
ParamsPalmFFT(const Faust::MatDense<FPP,DEVICE>& data_, ParamsPalmFGFT(const Faust::MatDense<FPP,DEVICE>& data_,
const int nbFact_, const int nbFact_,
const std::vector<const Faust::ConstraintGeneric*>& cons_, const std::vector<const Faust::ConstraintGeneric*>& cons_,
const std::vector<Faust::MatDense<FPP,DEVICE> >& init_fact_, const std::vector<Faust::MatDense<FPP,DEVICE> >& init_fact_,
...@@ -40,7 +40,7 @@ namespace Faust ...@@ -40,7 +40,7 @@ namespace Faust
const FPP init_lambda_ = ParamsPalm<FPP,DEVICE,FPP2>::defaultLambda, const FPP init_lambda_ = ParamsPalm<FPP,DEVICE,FPP2>::defaultLambda,
const FPP step_size_ = ParamsPalm<FPP,DEVICE,FPP2>::defaultStepSize); const FPP step_size_ = ParamsPalm<FPP,DEVICE,FPP2>::defaultStepSize);
ParamsPalmFFT(const Faust::MatDense<FPP,DEVICE>& data_, ParamsPalmFGFT(const Faust::MatDense<FPP,DEVICE>& data_,
const int nbFact_, const int nbFact_,
const std::vector<const Faust::ConstraintGeneric*>& cons_, const std::vector<const Faust::ConstraintGeneric*>& cons_,
const std::vector<Faust::MatDense<FPP,DEVICE> >& init_fact_, const std::vector<Faust::MatDense<FPP,DEVICE> >& init_fact_,
...@@ -49,7 +49,7 @@ namespace Faust ...@@ -49,7 +49,7 @@ namespace Faust
const bool isVerbose_ = ParamsPalm<FPP,DEVICE,FPP2>::defaultVerbosity , const bool isVerbose_ = ParamsPalm<FPP,DEVICE,FPP2>::defaultVerbosity ,
const bool isUpdateWayR2L_ = ParamsPalm<FPP,DEVICE,FPP2>::defaultUpdateWayR2L , const bool isUpdateWayR2L_ = ParamsPalm<FPP,DEVICE,FPP2>::defaultUpdateWayR2L ,
const FPP init_lambda_ = ParamsPalm<FPP,DEVICE,FPP2>::defaultLambda, const FPP init_lambda_ = ParamsPalm<FPP,DEVICE,FPP2>::defaultLambda,
const FPP step_size_ = ParamsPalm<FPP,DEVICE,FPP2>::defaultStepSize) : ParamsPalmFFT<FPP,DEVICE,FPP2>(data_, nbFact_, cons_, init_fact_, Faust::Vect<FPP,DEVICE>(data_.getNbRow(), init_D_diag), stop_crit_, isVerbose_, isUpdateWayR2L_, init_lambda_, step_size_) {} const FPP step_size_ = ParamsPalm<FPP,DEVICE,FPP2>::defaultStepSize) : ParamsPalmFGFT<FPP,DEVICE,FPP2>(data_, nbFact_, cons_, init_fact_, Faust::Vect<FPP,DEVICE>(data_.getNbRow(), init_D_diag), stop_crit_, isVerbose_, isUpdateWayR2L_, init_lambda_, step_size_) {}
MatDense<FPP,DEVICE> init_D; MatDense<FPP,DEVICE> init_D;
...@@ -57,7 +57,7 @@ namespace Faust ...@@ -57,7 +57,7 @@ namespace Faust
}; };
#include "faust_ParamsPalmFFT.hpp" #include "faust_ParamsPalmFGFT.hpp"
} }
#endif #endif
template<typename FPP,Device DEVICE,typename FPP2> template<typename FPP,Device DEVICE,typename FPP2>
ParamsPalmFFT<FPP,DEVICE,FPP2>::ParamsPalmFFT(const Faust::MatDense<FPP,DEVICE>& data_, ParamsPalmFGFT<FPP,DEVICE,FPP2>::ParamsPalmFGFT(const Faust::MatDense<FPP,DEVICE>& data_,
const int nbFact_, const int nbFact_,
const std::vector<const Faust::ConstraintGeneric*>& cons_, const std::vector<const Faust::ConstraintGeneric*>& cons_,
const std::vector<Faust::MatDense<FPP,DEVICE> >& init_fact_, const std::vector<Faust::MatDense<FPP,DEVICE> >& init_fact_,
...@@ -8,7 +8,7 @@ template<typename FPP,Device DEVICE,typename FPP2> ...@@ -8,7 +8,7 @@ template<typename FPP,Device DEVICE,typename FPP2>
const bool isVerbose_ , const bool isVerbose_ ,
const bool isUpdateWayR2L_ , const bool isUpdateWayR2L_ ,
const FPP init_lambda_ , const FPP init_lambda_ ,
const FPP step_size_) : ParamsPalm<FPP, DEVICE, FPP2>(data_, nbFact_, cons_, init_fact_, stop_crit_, isVerbose_, isUpdateWayR2L_, init_lambda_, true /*constant_step_size is always true for Palm4MSAFFT */, step_size_), init_D(data_.getNbRow(), data_.getNbCol()) const FPP step_size_) : ParamsPalm<FPP, DEVICE, FPP2>(data_, nbFact_, cons_, init_fact_, stop_crit_, isVerbose_, isUpdateWayR2L_, init_lambda_, true /*constant_step_size is always true for Palm4MSAFGFT */, step_size_), init_D(data_.getNbRow(), data_.getNbCol())
{ {
init_D.setZeros(); init_D.setZeros();
// set init_D from diagonal vector init_D_diag // set init_D from diagonal vector init_D_diag
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
#include "mex.h" #include "mex.h"
#include "faust_HierarchicalFact.h" #include "faust_HierarchicalFact.h"
#include "faust_HierarchicalFactFFT.h" #include "faust_HierarchicalFactFGFT.h"
#include "faust_TransformHelper.h" #include "faust_TransformHelper.h"
#include "class_handle.hpp" #include "class_handle.hpp"
#include <vector> #include <vector>
...@@ -104,14 +104,14 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) ...@@ -104,14 +104,14 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Faust::HierarchicalFact<SCALAR,Cpu, FPP2>* hier_fact; Faust::HierarchicalFact<SCALAR,Cpu, FPP2>* hier_fact;
if(dynamic_cast<const ParamsFFT<SCALAR,Cpu,FPP2>*>(params)) if(dynamic_cast<const ParamsFGFT<SCALAR,Cpu,FPP2>*>(params))
{ {
if(! is_fgft) mexErrMsgTxt("Bad Number of inputs arguments for PALM FGFT."); if(! is_fgft) mexErrMsgTxt("Bad Number of inputs arguments for PALM FGFT.");
Faust::MatDense<SCALAR,Cpu> laplacian_mat; Faust::MatDense<SCALAR,Cpu> laplacian_mat;
const mxArray* matlab_lap_mat = prhs[2]; const mxArray* matlab_lap_mat = prhs[2];
mxArray2FaustMat(matlab_lap_mat,laplacian_mat); mxArray2FaustMat(matlab_lap_mat,laplacian_mat);
// params->Display(); // params->Display();
hier_fact = new Faust::HierarchicalFactFFT<SCALAR,Cpu,FPP2>(matrix,laplacian_mat,*dynamic_cast<const ParamsFFT<SCALAR,Cpu,FPP2>*>(params),blas_handle,spblas_handle); hier_fact = new Faust::HierarchicalFactFGFT<SCALAR,Cpu,FPP2>(matrix,laplacian_mat,*dynamic_cast<const ParamsFGFT<SCALAR,Cpu,FPP2>*>(params),blas_handle,spblas_handle);
} }
else else
hier_fact = new Faust::HierarchicalFact<SCALAR,Cpu,FPP2>(matrix,*params,blas_handle,spblas_handle); hier_fact = new Faust::HierarchicalFact<SCALAR,Cpu,FPP2>(matrix,*params,blas_handle,spblas_handle);
...@@ -141,7 +141,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) ...@@ -141,7 +141,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
if(is_fgft) if(is_fgft)
{ {
Faust::Vect<SCALAR,Cpu> D(matrix.getNbRow()); Faust::Vect<SCALAR,Cpu> D(matrix.getNbRow());
(dynamic_cast<Faust::HierarchicalFactFFT<SCALAR,Cpu,FPP2>*>(hier_fact))->get_D(const_cast<SCALAR*>(D.getData())); // not respecting constness for optimiation (saving a vector copy) (dynamic_cast<Faust::HierarchicalFactFGFT<SCALAR,Cpu,FPP2>*>(hier_fact))->get_D(const_cast<SCALAR*>(D.getData())); // not respecting constness for optimiation (saving a vector copy)
plhs[2] = FaustVec2mxArray(D); plhs[2] = FaustVec2mxArray(D);
} }
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
#include "faust_ConstraintMat.h" #include "faust_ConstraintMat.h"
#include "faust_ConstraintInt.h" #include "faust_ConstraintInt.h"
#include "faust_Params.h" #include "faust_Params.h"
#include "faust_ParamsFFT.h" #include "faust_ParamsFGFT.h"
#include "faust_MatDense.h" #include "faust_MatDense.h"
#include "faust_MatSparse.h" #include "faust_MatSparse.h"
#include "faust_Vect.h" #include "faust_Vect.h"
...@@ -771,7 +771,7 @@ const Params<SCALAR, Cpu, FPP2>* mxArray2FaustParams(const mxArray* matlab_param ...@@ -771,7 +771,7 @@ const Params<SCALAR, Cpu, FPP2>* mxArray2FaustParams(const mxArray* matlab_param
SCALAR* init_D = new SCALAR[nb_row]; //nb_col == nb_row when using FactHierarchicalF(G)FT SCALAR* init_D = new SCALAR[nb_row]; //nb_col == nb_row when using FactHierarchicalF(G)FT
mxCurrentField = mxGetField(matlab_params,0,mat_field_type2str(INIT_D).c_str()); mxCurrentField = mxGetField(matlab_params,0,mat_field_type2str(INIT_D).c_str());
mxArray2Ptr<SCALAR>(const_cast<const mxArray*>(mxCurrentField), init_D); mxArray2Ptr<SCALAR>(const_cast<const mxArray*>(mxCurrentField), init_D);
params = new ParamsFFT<SCALAR,Cpu,FPP2>(nb_row,nb_col,nbFact,consSS, init_facts, init_D, crit1,crit2,isVerbose,updateway,factside,init_lambda); params = new ParamsFGFT<SCALAR,Cpu,FPP2>(nb_row,nb_col,nbFact,consSS, init_facts, init_D, crit1,crit2,isVerbose,updateway,factside,init_lambda);
delete init_D; delete init_D;
} }
else else
......
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
#include "faust_MatDense.h" #include "faust_MatDense.h"
#include "faust_MatSparse.h" #include "faust_MatSparse.h"
#include "faust_Params.h" #include "faust_Params.h"
#include "faust_ParamsFFT.h" #include "faust_ParamsFGFT.h"
#include "faust_ParamsPalm.h" #include "faust_ParamsPalm.h"
#include "faust_StoppingCriterion.h" #include "faust_StoppingCriterion.h"
#include "faust_Palm4MSA.h" #include "faust_Palm4MSA.h"
#include "faust_Palm4MSAFFT.h" #include "faust_Palm4MSAFGFT.h"
#include "faust_HierarchicalFact.h" #include "faust_HierarchicalFact.h"
#include "faust_HierarchicalFactFFT.h" #include "faust_HierarchicalFactFGFT.h"
#include "faust_BlasHandle.h" #include "faust_BlasHandle.h"
#include "faust_ConstraintGeneric.h" #include "faust_ConstraintGeneric.h"
...@@ -226,9 +226,9 @@ FaustCoreCpp<FPP>* fact_palm4MSA_gen(FPP* mat, unsigned int num_rows, unsigned i ...@@ -226,9 +226,9 @@ FaustCoreCpp<FPP>* fact_palm4MSA_gen(FPP* mat, unsigned int num_rows, unsigned i
if(p_fft = dynamic_cast<PyxParamsFactPalm4MSAFFT<FPP,FPP2>*>(p)) if(p_fft = dynamic_cast<PyxParamsFactPalm4MSAFFT<FPP,FPP2>*>(p))
{ {
params = new ParamsPalmFFT<FPP,Cpu,FPP2>(inMat, p->num_facts, cons, initFacts, p_fft->init_D, crit, p->is_verbose, p->is_update_way_R2L, p->init_lambda, p->step_size); params = new ParamsPalmFGFT<FPP,Cpu,FPP2>(inMat, p->num_facts, cons, initFacts, p_fft->init_D, crit, p->is_verbose, p->is_update_way_R2L, p->init_lambda, p->step_size);
palm = new Palm4MSAFFT<FPP,Cpu,FPP2>(*static_cast<ParamsPalmFFT<FPP,Cpu,FPP2>*>(params),blasHandle,true); palm = new Palm4MSAFGFT<FPP,Cpu,FPP2>(*static_cast<ParamsPalmFGFT<FPP,Cpu,FPP2>*>(params),blasHandle,true);
} }
else { else {
params = new ParamsPalm<FPP,Cpu,FPP2>(inMat, p->num_facts, cons, initFacts, crit, p->is_verbose, p->is_update_way_R2L, p->init_lambda, p->constant_step_size, p->step_size); params = new ParamsPalm<FPP,Cpu,FPP2>(inMat, p->num_facts, cons, initFacts, crit, p->is_verbose, p->is_update_way_R2L, p->init_lambda, p->constant_step_size, p->step_size);
...@@ -274,7 +274,7 @@ FaustCoreCpp<FPP>* fact_palm4MSA_gen(FPP* mat, unsigned int num_rows, unsigned i ...@@ -274,7 +274,7 @@ FaustCoreCpp<FPP>* fact_palm4MSA_gen(FPP* mat, unsigned int num_rows, unsigned i
{ {
// retrieve D matrix from Palm4MSAFFT // retrieve D matrix from Palm4MSAFFT
// out buffer must have been allocated from outside // out buffer must have been allocated from outside
dynamic_cast<Palm4MSAFFT<FPP,Cpu,FPP2>*>(palm)->get_D(out_buf+1); dynamic_cast<Palm4MSAFGFT<FPP,Cpu,FPP2>*>(palm)->get_D(out_buf+1);
// add lambda at the first position // add lambda at the first position
out_buf[0] = lambda; out_buf[0] = lambda;
} }
...@@ -347,8 +347,8 @@ FaustCoreCpp<FPP>* fact_hierarchical_gen(FPP* mat, FPP* mat2, unsigned int num_r ...@@ -347,8 +347,8 @@ FaustCoreCpp<FPP>* fact_hierarchical_gen(FPP* mat, FPP* mat2, unsigned int num_r
if(p_fft = dynamic_cast<PyxParamsHierarchicalFactFFT<FPP,FPP2>*>(p)) if(p_fft = dynamic_cast<PyxParamsHierarchicalFactFFT<FPP,FPP2>*>(p))
{ {
inMat2 = new Faust::MatDense<FPP,Cpu>(mat2, num_rows, num_cols); inMat2 = new Faust::MatDense<FPP,Cpu>(mat2, num_rows, num_cols);
params = new Faust::ParamsFFT<FPP,Cpu,FPP2>(p->num_rows, p->num_cols, p->num_facts, cons_, initFacts_deft, p_fft->init_D, crit0, crit1, p->is_verbose, p->is_update_way_R2L, p->is_fact_side_left, p->init_lambda, p->constant_step_size, p->step_size); params = new Faust::ParamsFGFT<FPP,Cpu,FPP2>(p->num_rows, p->num_cols, p->num_facts, cons_, initFacts_deft, p_fft->init_D, crit0, crit1, p->is_verbose, p->is_update_way_R2L, p->is_fact_side_left, p->init_lambda, p->constant_step_size, p->step_size);
hierFact = new HierarchicalFactFFT<FPP,Cpu,FPP2>(inMat, *inMat2, *(static_cast<ParamsFFT<FPP,Cpu,FPP2>*>(params)), blasHandle, spblasHandle); hierFact = new HierarchicalFactFGFT<FPP,Cpu,FPP2>(inMat, *inMat2, *(static_cast<ParamsFGFT<FPP,Cpu,FPP2>*>(params)), blasHandle, spblasHandle);
} }
else else
{ {
...@@ -393,7 +393,7 @@ FaustCoreCpp<FPP>* fact_hierarchical_gen(FPP* mat, FPP* mat2, unsigned int num_r ...@@ -393,7 +393,7 @@ FaustCoreCpp<FPP>* fact_hierarchical_gen(FPP* mat, FPP* mat2, unsigned int num_r
{ {
// retrieve D matrix from HierarchicalFactFFT // retrieve D matrix from HierarchicalFactFFT
// out buffer must have been allocated from outside // out buffer must have been allocated from outside
dynamic_cast<HierarchicalFactFFT<FPP,Cpu,FPP2>*>(hierFact)->get_D(out_buf+1); dynamic_cast<HierarchicalFactFGFT<FPP,Cpu,FPP2>*>(hierFact)->get_D(out_buf+1);
// add lambda at the first position // add lambda at the first position
out_buf[0] = lambda; out_buf[0] = lambda;
delete inMat2; delete inMat2;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment