static void evaluate_permute(t_topology * /* top */, t_trxframe * /* fr */, t_pbc * /* pbc */, gmx_ana_pos_t *p, gmx_ana_selvalue_t *out, void *data) { t_methoddata_permute *d = (t_methoddata_permute *)data; int i, j, b; int refid; if (d->p.count() % d->n != 0) { GMX_THROW(gmx::InconsistentInputError( gmx::formatString("The number of positions to be permuted is not divisible by %d", d->n))); } gmx_ana_pos_empty(out->u.p); for (i = 0; i < d->p.count(); i += d->n) { for (j = 0; j < d->n; ++j) { b = i + d->rperm[j]; refid = d->p.m.refid[b]; if (refid != -1) { /* De-permute the reference ID */ refid = refid - (refid % d->n) + d->perm[refid % d->n]; } gmx_ana_pos_append(out->u.p, p, b, refid); } } gmx_ana_pos_append_finish(out->u.p); }
static void evaluate_merge(t_topology * /* top */, t_trxframe * /* fr */, t_pbc * /* pbc */, gmx_ana_pos_t * /* p */, gmx_ana_selvalue_t *out, void *data) { t_methoddata_merge *d = (t_methoddata_merge *)data; int i, j; int refid; if (d->p1.count() != d->stride*d->p2.count()) { GMX_THROW(gmx::InconsistentInputError("The number of positions to be merged are not compatible")); } gmx_ana_pos_empty(out->u.p); for (i = 0; i < d->p2.count(); ++i) { for (j = 0; j < d->stride; ++j) { refid = d->p1.m.refid[d->stride*i+j]; if (refid != -1) { refid = (d->stride+1) * (refid / d->stride) + (refid % d->stride); } gmx_ana_pos_append(out->u.p, &d->p1, d->stride*i+j, refid); } refid = (d->stride+1)*d->p2.m.refid[i] + d->stride; gmx_ana_pos_append(out->u.p, &d->p2, i, refid); } gmx_ana_pos_append_finish(out->u.p); }
static void evaluate_plus(t_topology * /* top */, t_trxframe * /* fr */, t_pbc * /* pbc */, gmx_ana_pos_t * /* p */, gmx_ana_selvalue_t *out, void *data) { t_methoddata_merge *d = (t_methoddata_merge *)data; int i; int refid; gmx_ana_pos_empty(out->u.p); for (i = 0; i < d->p1.count(); ++i) { refid = d->p1.m.refid[i]; gmx_ana_pos_append(out->u.p, &d->p1, i, refid); } for (i = 0; i < d->p2.count(); ++i) { refid = d->p2.m.refid[i]; if (refid != -1) { refid += d->p1.m.b.nr; } gmx_ana_pos_append(out->u.p, &d->p2, i, refid); } gmx_ana_pos_append_finish(out->u.p); }
/*! * \param[in] top Not used. * \param[in] fr Not used. * \param[in] pbc Not used. * \param[in] p Positions to permute (should point to \p data->p). * \param[out] out Output data structure (\p out->u.p is used). * \param[in] data Should point to a \p t_methoddata_permute. * \returns 0 if \p p could be permuted, -1 on error. * * Returns -1 if the size of \p p is not divisible by the number of * elements in the permutation. */ static int evaluate_permute(t_topology *top, t_trxframe *fr, t_pbc *pbc, gmx_ana_pos_t *p, gmx_ana_selvalue_t *out, void *data) { t_methoddata_permute *d = (t_methoddata_permute *)data; int i, j, b, k; int refid; if (d->p.nr % d->n != 0) { fprintf(stderr, "error: the number of positions to be permuted is not divisible by %d\n", d->n); return -1; } d->g.isize = 0; gmx_ana_pos_empty(out->u.p); for (i = 0; i < d->p.nr; i += d->n) { for (j = 0; j < d->n; ++j) { b = i + d->rperm[j]; refid = d->p.m.refid[b]; if (refid != -1) { /* De-permute the reference ID */ refid = refid - (refid % d->n) + d->perm[refid % d->n]; } gmx_ana_pos_append(out->u.p, &d->g, p, b, refid); } } gmx_ana_pos_append_finish(out->u.p); return 0; }