Skip to content

Commit

Permalink
more stuff into classes
Browse files Browse the repository at this point in the history
  • Loading branch information
osorensen committed Nov 21, 2023
1 parent 721ce8f commit ed0a842
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 40 deletions.
23 changes: 0 additions & 23 deletions src/mixtures.cpp

This file was deleted.

11 changes: 0 additions & 11 deletions src/mixtures.h

This file was deleted.

9 changes: 9 additions & 0 deletions src/parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,3 +241,12 @@ void Clustering::update_wcd(const int t){

within_cluster_distance.col(t) = wcd;
}

void Clustering::update_dist_mat(const Data& dat, const Parameters& pars){

if(!clustering & !include_wcd) return;

for(int i = 0; i < pars.n_clusters; ++i)
dist_mat.col(i) = rank_dist_vec(dat.rankings, pars.rho_old.col(i),
pars.metric, dat.observation_frequency);
}
2 changes: 1 addition & 1 deletion src/parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "distances.h"
#include "partitionfuns.h"
#include "missing_data.h"
#include "mixtures.h"
#include "sample.h"

template <typename T>
Expand Down Expand Up @@ -141,6 +140,7 @@ struct Clustering {
const Rcpp::List& logz_list);

void update_wcd(const int t);
void update_dist_mat(const Data& dat, const Parameters& pars);


};
Expand Down
8 changes: 3 additions & 5 deletions src/run_mcmc.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include <RcppArmadillo.h>
#include "misc.h"
#include "mixtures.h"
#include "distances.h"
#include "missing_data.h"
#include "pairwise_comparisons.h"
Expand All @@ -27,7 +26,7 @@ Rcpp::List run_mcmc(Rcpp::List data,
Parameters pars{model, compute_options, initial_values, dat.n_items};
Clustering clus{pars, compute_options, dat.n_assessors};

update_dist_mat(clus.dist_mat, dat.rankings, pars.rho_old, pars.metric, dat.observation_frequency);
clus.update_dist_mat(dat, pars);

int alpha_index = 0, rho_index = 0, aug_index = 0, cluster_assignment_index = 0;

Expand Down Expand Up @@ -92,9 +91,8 @@ Rcpp::List run_mcmc(Rcpp::List data,
dat.augmented_data.slice(aug_index) = dat.rankings;
}

if(clus.clustering | clus.include_wcd){
update_dist_mat(clus.dist_mat, dat.rankings, pars.rho_old, pars.metric, dat.observation_frequency);
}
clus.update_dist_mat(dat, pars);

}

// Return everything that might be of interest
Expand Down

0 comments on commit ed0a842

Please sign in to comment.