Mentions légales du service

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

Update GivensFGFT by adding the main loop calling the substeps with a generic function pointer.

parent 1eebc177
Branches
Tags
No related merge requests found
...@@ -14,6 +14,7 @@ int main() ...@@ -14,6 +14,7 @@ int main()
{ {
Faust::MatDense<FPP,Cpu> Lap(10,10); Faust::MatDense<FPP,Cpu> Lap(10,10);
GivensFGFT<FPP,Cpu> algo(Lap,3); GivensFGFT<FPP,Cpu> algo(Lap,3);
algo.compute_facts();
return 0; return 0;
} }
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
namespace Faust { namespace Faust {
template<typename FPP, Device DEVICE, typename FPP2 = float> template<typename FPP, Device DEVICE, typename FPP2 = float>
class GivensFGFT { class GivensFGFT {
...@@ -20,14 +21,33 @@ namespace Faust { ...@@ -20,14 +21,33 @@ namespace Faust {
Faust::MatDense<FPP, DEVICE> Lap; Faust::MatDense<FPP, DEVICE> Lap;
Faust::MatDense<FPP, DEVICE> L; Faust::MatDense<FPP, DEVICE> L;
/**
* Matrix pivot and column indices.
*/
faust_unsigned_int p, q; faust_unsigned_int p, q;
/**
* Current iteration index (pointing to the current factor to update).
*/
unsigned int ite;
/**
* Function pointer to any step of the algorithm.
*/
typedef void (GivensFGFT<FPP,DEVICE,FPP2>::*substep_fun)();
public: public:
GivensFGFT(Faust::MatDense<FPP,DEVICE>& Lap, faust_unsigned_int J); GivensFGFT(Faust::MatDense<FPP,DEVICE>& Lap, faust_unsigned_int J);
/** /**
* \brief Algo. main step. * \brief Algo. main step.
*/ */
void next_step(); void next_step();
/**
* \brief Algo. main loop (facts.size() iterations).
*/
void compute_facts(); void compute_facts();
/** \brief Algo. step 2.1. /** \brief Algo. step 2.1.
*/ */
......
...@@ -4,6 +4,21 @@ template<typename FPP, Device DEVICE, typename FPP2> ...@@ -4,6 +4,21 @@ template<typename FPP, Device DEVICE, typename FPP2>
void GivensFGFT<FPP,DEVICE,FPP2>::next_step() void GivensFGFT<FPP,DEVICE,FPP2>::next_step()
{ {
substep_fun substep[] = {
&GivensFGFT<FPP,DEVICE,FPP2>::choose_pivot,
&GivensFGFT<FPP,DEVICE,FPP2>::sort_L_in_C,
&GivensFGFT<FPP,DEVICE,FPP2>::calc_theta,
&GivensFGFT<FPP,DEVICE,FPP2>::update_fact,
&GivensFGFT<FPP,DEVICE,FPP2>::update_L,
&GivensFGFT<FPP,DEVICE,FPP2>::update_D};
for(int i=0;i<sizeof(substep)/sizeof(substep_fun);i++)
{
#ifdef DEBUG_GIVENS
cout << "GivensFGFT ite=" << ite << " substep i=" << i << endl;
#endif
(this->*substep[i])();
}
} }
template<typename FPP, Device DEVICE, typename FPP2> template<typename FPP, Device DEVICE, typename FPP2>
...@@ -106,7 +121,12 @@ void GivensFGFT<FPP,DEVICE,FPP2>::update_err() ...@@ -106,7 +121,12 @@ void GivensFGFT<FPP,DEVICE,FPP2>::update_err()
template<typename FPP, Device DEVICE, typename FPP2> template<typename FPP, Device DEVICE, typename FPP2>
void GivensFGFT<FPP,DEVICE,FPP2>::compute_facts() void GivensFGFT<FPP,DEVICE,FPP2>::compute_facts()
{ {
ite = 0;
while(ite < facts.size())
{
next_step();
ite++;
}
} }
template<typename FPP, Device DEVICE, typename FPP2> template<typename FPP, Device DEVICE, typename FPP2>
...@@ -121,6 +141,7 @@ GivensFGFT<FPP,DEVICE,FPP2>::GivensFGFT(Faust::MatDense<FPP,DEVICE>& Lap, faust_ ...@@ -121,6 +141,7 @@ GivensFGFT<FPP,DEVICE,FPP2>::GivensFGFT(Faust::MatDense<FPP,DEVICE>& Lap, faust_
* coord_choices = zeros(2,J); * coord_choices = zeros(2,J);
* *
*/ */
//initialization's ok
} }
template<typename FPP, Device DEVICE, typename FPP2> template<typename FPP, Device DEVICE, typename FPP2>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment