From fc319f8f83849c855e07d730aef82010253510f4 Mon Sep 17 00:00:00 2001 From: Jana Pazurikova Date: Wed, 25 May 2016 13:19:16 +0200 Subject: [PATCH] Move methods for kappa_data copy to subset.c --- src/diffevolution.c | 31 ------------------------------- src/diffevolution.h | 2 -- src/subset.c | 31 +++++++++++++++++++++++++++++++ src/subset.h | 2 ++ 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/diffevolution.c b/src/diffevolution.c index 50a625c..abb7118 100644 --- a/src/diffevolution.c +++ b/src/diffevolution.c @@ -479,34 +479,3 @@ int sum(int* vector, int size) { sum+=vector[i]; return sum; } - -/* Copy data from one kappa_data to another */ -void kd_copy_parameters(struct kappa_data* from, struct kappa_data* to) { - to->kappa = from->kappa; - for (int i = 0; i < ts.atom_types_count; i++) { - to->parameters_alpha[i] = from->parameters_alpha[i]; - to->parameters_beta[i] = from->parameters_beta[i]; - } -} - -/* Copy statistics from one kappa_data to another */ -void kd_copy_statistics(struct kappa_data* from, struct kappa_data* to) { - to->full_stats.R = from->full_stats.R; - to->full_stats.R2 = from->full_stats.R2; - to->full_stats.R_w = from->full_stats.R_w; - to->full_stats.RMSD = from->full_stats.RMSD; - to->full_stats.spearman = from->full_stats.spearman; - to->full_stats.D_avg = from->full_stats.D_avg; - to->full_stats.D_max = from->full_stats.D_max; - - for (int i = 0; i < ts.atom_types_count; i++) { - to->per_at_stats[i].R = from->per_at_stats[i].R; - to->per_at_stats[i].R2 = from->per_at_stats[i].R2; - to->per_at_stats[i].R_w = from->per_at_stats[i].R_w; - to->per_at_stats[i].RMSD = from->per_at_stats[i].RMSD; - to->per_at_stats[i].spearman = from->per_at_stats[i].spearman; - to->per_at_stats[i].D_avg = from->per_at_stats[i].D_avg; - to->per_at_stats[i].D_max = from->per_at_stats[i].D_max; - } - -} diff --git a/src/diffevolution.h b/src/diffevolution.h index 6acfdf1..971ca90 100644 --- a/src/diffevolution.h +++ b/src/diffevolution.h @@ -20,8 +20,6 @@ void compute_parameters_bounds(float* bounds, int by_atom_type); float get_random_float(float low, float high); float interpolate_to_different_bounds(float x, float low, float high); int sum(int* vector, int size); -void kd_copy_parameters(struct kappa_data* from, struct kappa_data* to); -void kd_copy_statistics(struct kappa_data* from, struct kappa_data* to); void minimize_locally(struct kappa_data* trial, int max_calls); extern void newuoa_(int* n, int* npt, double* x, double* rhobeg, double* rhoend, int* iprint, int* maxfun, double* w); extern void calfun_(int n, double*x, double* f); diff --git a/src/subset.c b/src/subset.c index 6ce23de..69a2079 100644 --- a/src/subset.c +++ b/src/subset.c @@ -60,6 +60,37 @@ void kd_init(struct kappa_data * const kd) { kd->per_molecule_stats = (struct stats *) calloc(ts.molecules_count, sizeof(struct stats)); } +/* Copy data from one kappa_data to another */ +void kd_copy_parameters(struct kappa_data* from, struct kappa_data* to) { + to->kappa = from->kappa; + for (int i = 0; i < ts.atom_types_count; i++) { + to->parameters_alpha[i] = from->parameters_alpha[i]; + to->parameters_beta[i] = from->parameters_beta[i]; + } +} + +/* Copy statistics from one kappa_data to another */ +void kd_copy_statistics(struct kappa_data* from, struct kappa_data* to) { + to->full_stats.R = from->full_stats.R; + to->full_stats.R2 = from->full_stats.R2; + to->full_stats.R_w = from->full_stats.R_w; + to->full_stats.RMSD = from->full_stats.RMSD; + to->full_stats.spearman = from->full_stats.spearman; + to->full_stats.D_avg = from->full_stats.D_avg; + to->full_stats.D_max = from->full_stats.D_max; + + for (int i = 0; i < ts.atom_types_count; i++) { + to->per_at_stats[i].R = from->per_at_stats[i].R; + to->per_at_stats[i].R2 = from->per_at_stats[i].R2; + to->per_at_stats[i].R_w = from->per_at_stats[i].R_w; + to->per_at_stats[i].RMSD = from->per_at_stats[i].RMSD; + to->per_at_stats[i].spearman = from->per_at_stats[i].spearman; + to->per_at_stats[i].D_avg = from->per_at_stats[i].D_avg; + to->per_at_stats[i].D_max = from->per_at_stats[i].D_max; + } + +} + /* Destroy contents of the kappa_data structure */ void kd_destroy(struct kappa_data * const kd) { diff --git a/src/subset.h b/src/subset.h index eb4bf6b..720dfdd 100644 --- a/src/subset.h +++ b/src/subset.h @@ -40,6 +40,8 @@ struct kappa_data { }; void kd_init(struct kappa_data * const kd); +void kd_copy_parameters(struct kappa_data* from, struct kappa_data* to); +void kd_copy_statistics(struct kappa_data* from, struct kappa_data* to); void kd_destroy(struct kappa_data * const kd); void kd_print_stats(const struct kappa_data * const kd); void kd_print_results(const struct kappa_data * const kd);