Skip to content

Commit

Permalink
Move methods for kappa_data copy to subset.c
Browse files Browse the repository at this point in the history
  • Loading branch information
Jana Pazurikova committed Jun 2, 2016
1 parent 0bcabe1 commit fc319f8
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 33 deletions.
31 changes: 0 additions & 31 deletions src/diffevolution.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}
2 changes: 0 additions & 2 deletions src/diffevolution.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
31 changes: 31 additions & 0 deletions src/subset.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down
2 changes: 2 additions & 0 deletions src/subset.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit fc319f8

Please sign in to comment.