Commit 92306760 authored by Jean-Benoist Leger's avatar Jean-Benoist Leger
Browse files

Precalcul for models

parent a9502b8d
......@@ -188,6 +188,9 @@ void wmixnet::precalcul()
itpp::mat m_Pro3 = m_Pro2 * m_V.T();
m_T = itpp::inv(m_V.T()*m_V) * m_V.T();
}
f_precalcul_modele();
clock_t c_end = clock();
double tps = ((double)(c_end-c_start))/CLOCKS_PER_SEC;
std::cerr << "done\t\t\t\t\t";
......@@ -427,6 +430,7 @@ void wmixnet::set_modele(const std::string & s_modele)
if(s_modele == "bernoulli")
{
model_defined = true;
p_f_precalcul_modele = &wmixnet::f_precalcul_nothing;
p_f_init_modele = &wmixnet::f_init_bernoulli;
p_f_E_modele = &wmixnet::f_E_bernoulli;
p_f_M_modele = &wmixnet::f_M_bernoulli;
......@@ -440,6 +444,7 @@ void wmixnet::set_modele(const std::string & s_modele)
if(s_modele == "BI")
{
model_defined = true;
p_f_precalcul_modele = &wmixnet::f_precalcul_nothing;
p_f_init_modele = &wmixnet::f_init_BI;
p_f_E_modele = &wmixnet::f_E_BI;
p_f_M_modele = &wmixnet::f_M_BI;
......@@ -453,6 +458,7 @@ void wmixnet::set_modele(const std::string & s_modele)
if(s_modele == "BH")
{
model_defined = true;
p_f_precalcul_modele = &wmixnet::f_precalcul_nothing;
p_f_init_modele = &wmixnet::f_init_BH;
p_f_E_modele = &wmixnet::f_E_BH;
p_f_M_modele = &wmixnet::f_M_BH;
......@@ -466,6 +472,7 @@ void wmixnet::set_modele(const std::string & s_modele)
if(s_modele == "poisson")
{
model_defined = true;
p_f_precalcul_modele = &wmixnet::f_precalcul_nothing;
p_f_init_modele = &wmixnet::f_init_poisson;
p_f_E_modele = &wmixnet::f_E_poisson;
p_f_M_modele = &wmixnet::f_M_poisson;
......@@ -479,6 +486,7 @@ void wmixnet::set_modele(const std::string & s_modele)
if(s_modele == "gaussian")
{
model_defined = true;
p_f_precalcul_modele = &wmixnet::f_precalcul_nothing;
p_f_init_modele = &wmixnet::f_init_gaussian;
p_f_E_modele = &wmixnet::f_E_gaussian;
p_f_M_modele = &wmixnet::f_M_gaussian;
......@@ -492,6 +500,7 @@ void wmixnet::set_modele(const std::string & s_modele)
if(s_modele == "PRMH")
{
model_defined = true;
p_f_precalcul_modele = &wmixnet::f_precalcul_nothing;
p_f_init_modele = &wmixnet::f_init_PRMH;
p_f_E_modele = &wmixnet::f_E_PRMH;
p_f_M_modele = &wmixnet::f_M_PRMH;
......@@ -505,6 +514,7 @@ void wmixnet::set_modele(const std::string & s_modele)
if(s_modele == "PRMI")
{
model_defined = true;
p_f_precalcul_modele = &wmixnet::f_precalcul_nothing;
p_f_init_modele = &wmixnet::f_init_PRMI;
p_f_E_modele = &wmixnet::f_E_PRMI;
p_f_M_modele = &wmixnet::f_M_PRMI;
......@@ -518,6 +528,7 @@ void wmixnet::set_modele(const std::string & s_modele)
if(s_modele == "GRMH")
{
model_defined = true;
p_f_precalcul_modele = &wmixnet::f_precalcul_nothing;
p_f_init_modele = &wmixnet::f_init_GRMH;
p_f_E_modele = &wmixnet::f_E_GRMH;
p_f_M_modele = &wmixnet::f_M_GRMH;
......@@ -531,6 +542,7 @@ void wmixnet::set_modele(const std::string & s_modele)
if(s_modele == "GRMI")
{
model_defined = true;
p_f_precalcul_modele = &wmixnet::f_precalcul_nothing;
p_f_init_modele = &wmixnet::f_init_GRMI;
p_f_E_modele = &wmixnet::f_E_GRMI;
p_f_M_modele = &wmixnet::f_M_GRMI;
......
......@@ -79,6 +79,7 @@ class wmixnet
itpp::mat m_U;
itpp::mat m_V;
itpp::mat m_T;
itpp::Vec<itpp::mat> vm_precalc_model;
// Flags
......@@ -135,7 +136,7 @@ class wmixnet
ar & m_coords_SC0;
ar & ortho_done;
ar & m_transfm;
ar & m_cov_moyennes;
ar & m_cov_moyennes;
if (Archive::is_loading::value)
{
set_modele(modele);
......@@ -269,7 +270,11 @@ class wmixnet
int f_nb_parameters_GRMI(int Q);
itpp::mat f_residuelle_GRMI(const itpp::mat & m_tau, const itpp::Vec<itpp::mat> & vm_theta);
// fonctions communes
void f_precalcul_nothing(){}
// Pointeurs vers les fonctions du modeles
void (wmixnet::*p_f_precalcul_modele) ();
itpp::Vec<itpp::mat> (wmixnet::*p_f_init_modele) (const itpp::mat &);
void (wmixnet::*p_f_E_modele) ( const itpp::vec &, const itpp::mat &, const itpp::Vec<itpp::mat>, itpp::mat &);
void (wmixnet::*p_f_M_modele) ( const itpp::vec &, const itpp::mat &, const itpp::Vec<itpp::mat> & , itpp::Vec<itpp::mat> &);
......@@ -281,6 +286,7 @@ class wmixnet
public:
// Fonctions avec abstraction du modele
void f_precalcul_modele() { return (this->*p_f_precalcul_modele)(); }
itpp::Vec<itpp::mat> f_init_modele(const itpp::mat &m_tau) { return (this->*p_f_init_modele)(m_tau); }
void f_E_modele(const itpp::vec & v_alpha, const itpp::mat & m_tau, const itpp::Vec<itpp::mat> vm_theta, itpp::mat & m_tau2) { (this->*p_f_E_modele)( v_alpha, m_tau, vm_theta, m_tau2); }
void f_M_modele(const itpp::vec & v_alpha, const itpp::mat & m_tau, const itpp::Vec<itpp::mat> & vm_theta, itpp::Vec<itpp::mat> & vm_theta2 ) { (this->*p_f_M_modele)( v_alpha, m_tau, vm_theta, vm_theta2 ); }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment