Page MenuHomec4science

ReferenceComputer.cpp
No OneTemporary

File Metadata

Created
Sat, Nov 16, 13:35

ReferenceComputer.cpp

#include <ReferenceComputer.hpp>
#include <Matrix2D.hpp>
#include <Matrix4D.hpp>
// some typdef
#include <typedef.hpp>
ReferenceComputer::ReferenceComputer(const Matrix2D<int>& data,
const Matrix4D<double>& posterior_prob,
size_t n_threads)
: EMEngine(data,
posterior_prob.get_dim()[1],
1,
posterior_prob.get_dim()[2],
posterior_prob.get_dim()[3] == 2,
EMEngine::seeding_codes::RANDOM,
"",
n_threads)
{
// copy the data
this->data = matrix2d_i(this->n_row, v_i(this->n_col)) ;
for(size_t i=0; i<this->n_row; i++)
{ for(size_t j=0; j<this->n_col; j++)
{ this->data[i][j] = data(i,j) ; }
}
// compute window means
this->window_mean = matrix2d_d(this->n_row, v_d(this->n_shift, 0.)) ;
this->compute_window_means() ;
// initialise, copy and compute probs
this->post_prob = matrix4d_d(this->n_row,
matrix3d_d(this->n_class,
matrix2d_d(this->n_shift,
v_d(this->n_flip, 0.)))) ;
this->class_prob = matrix3d_d(this->n_class,
matrix2d_d(this->n_shift,
v_d(this->n_flip, 0.))) ;
this->class_prob_tot = v_d(this->n_class, 0.) ;
this->post_prob_class = v_d(this->n_class, 0.) ;
for(size_t i=0; i<this->n_row; i++)
{ for(size_t j=0; j<this->n_class; j++)
{ for(size_t s=0; s<this->n_shift; s++)
{ for(size_t f=0; f<this->n_flip; f++)
{ double p = posterior_prob(i,j,s,f) ;
this->post_prob[i][j][s][f] = p ;
this->post_prob_class[j] += p ;
this->post_prob_tot += p ;
}
}
}
}
this->compute_class_prob() ;
// compute the references
this->references = matrix2d_d(this->n_class,
v_d(this->l_slice, 0.)) ;
this->compute_references() ;
}
ReferenceComputer::~ReferenceComputer()
{ ; }
Matrix2D<double> ReferenceComputer::get_references() const
{
// add a 1st column with the class probabilities
Matrix2D<double> references(this->n_class, this->l_slice+1, 0.) ;
for(size_t i=0; i<this->n_class; i++)
{ // class prob
references(i,0) = this->class_prob_tot[i] ;
// signal
for(size_t j=0; j<this->l_slice; j++)
{ references(i,j+1) = this->references[i][j] ; }
}
return references ;
}

Event Timeline