1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-01-29 02:14:51 +00:00

Pass parameters by reference instead of by value (improves effieciency)

This commit is contained in:
Carles Fernandez 2018-08-21 14:57:22 +02:00
parent a833abbb8a
commit 388d1623ed
2 changed files with 52 additions and 56 deletions

View File

@ -63,7 +63,7 @@ Bayesian_estimator::Bayesian_estimator(int ny)
Psi_est = Psi_prior;
}
Bayesian_estimator::Bayesian_estimator(arma::vec mu_prior_0, int kappa_prior_0, int nu_prior_0, arma::mat Psi_prior_0)
Bayesian_estimator::Bayesian_estimator(const arma::vec& mu_prior_0, int kappa_prior_0, int nu_prior_0, const arma::mat& Psi_prior_0)
{
mu_prior = mu_prior_0;
kappa_prior = kappa_prior_0;
@ -78,7 +78,7 @@ Bayesian_estimator::~Bayesian_estimator()
{
}
void Bayesian_estimator::init(arma::vec mu_prior_0, int kappa_prior_0, int nu_prior_0, arma::mat Psi_prior_0)
void Bayesian_estimator::init(const arma::mat& mu_prior_0, int kappa_prior_0, int nu_prior_0, const arma::mat& Psi_prior_0)
{
mu_prior = mu_prior_0;
kappa_prior = kappa_prior_0;
@ -93,7 +93,7 @@ void Bayesian_estimator::init(arma::vec mu_prior_0, int kappa_prior_0, int nu_pr
* Perform Bayesian noise estimation using the normal-inverse-Wishart priors stored in
* the class structure, and update the priors according to the computed posteriors
*/
void Bayesian_estimator::update_sequential(arma::vec data)
void Bayesian_estimator::update_sequential(const arma::vec& data)
{
int K = data.n_cols;
int ny = data.n_rows;
@ -142,9 +142,8 @@ void Bayesian_estimator::update_sequential(arma::vec data)
* Perform Bayesian noise estimation using a new set of normal-inverse-Wishart priors
* and update the priors according to the computed posteriors
*/
void Bayesian_estimator::update_sequential(arma::vec data, arma::vec mu_prior_0, int kappa_prior_0, int nu_prior_0, arma::mat Psi_prior_0)
void Bayesian_estimator::update_sequential(const arma::vec& data, const arma::vec& mu_prior_0, int kappa_prior_0, int nu_prior_0, const arma::mat& Psi_prior_0)
{
int K = data.n_cols;
int ny = data.n_rows;
@ -186,4 +185,3 @@ arma::mat Bayesian_estimator::get_Psi_est()
{
return Psi_est;
}

View File

@ -58,17 +58,16 @@
class Bayesian_estimator
{
public:
Bayesian_estimator();
Bayesian_estimator(int ny);
Bayesian_estimator(arma::vec mu_prior_0, int kappa_prior_0, int nu_prior_0, arma::mat Psi_prior_0);
Bayesian_estimator(const arma::vec& mu_prior_0, int kappa_prior_0, int nu_prior_0, const arma::mat& Psi_prior_0);
~Bayesian_estimator();
void init(arma::vec mu_prior_0, int kappa_prior_0, int nu_prior_0, arma::mat Psi_prior_0);
void init(const arma::mat& mu_prior_0, int kappa_prior_0, int nu_prior_0, const arma::mat& Psi_prior_0);
void update_sequential(arma::vec data);
void update_sequential(arma::vec data, arma::vec mu_prior_0, int kappa_prior_0, int nu_prior_0, arma::mat Psi_prior_0);
void update_sequential(const arma::vec& data);
void update_sequential(const arma::vec& data, const arma::vec& mu_prior_0, int kappa_prior_0, int nu_prior_0, const arma::mat& Psi_prior_0);
arma::mat get_mu_est();
arma::mat get_Psi_est();
@ -81,7 +80,6 @@ private:
int kappa_prior;
int nu_prior;
arma::mat Psi_prior;
};
#endif