Remove duplicate .nr members from selection structs.
authorTeemu Murtola <teemu.murtola@gmail.com>
Wed, 28 Aug 2013 18:04:54 +0000 (21:04 +0300)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Sun, 8 Sep 2013 19:31:20 +0000 (21:31 +0200)
gmx_ana_indexmap_t::nr and gmx_ana_pos_t::nr were leftovers from C times
when these structures were directly exposed to user tools, and the
number of positions was provided as convenience in these members.
Both duplicated the value of (m.)mapb.nr.

Change-Id: If5211d7b513eb3ebcd87d4293d19c19c78952564

16 files changed:
src/gromacs/selection/compiler.cpp
src/gromacs/selection/indexutil.cpp
src/gromacs/selection/indexutil.h
src/gromacs/selection/params.cpp
src/gromacs/selection/poscalc.cpp
src/gromacs/selection/position.cpp
src/gromacs/selection/position.h
src/gromacs/selection/selection.cpp
src/gromacs/selection/selection.h
src/gromacs/selection/sm_distance.cpp
src/gromacs/selection/sm_insolidangle.cpp
src/gromacs/selection/sm_merge.cpp
src/gromacs/selection/sm_permute.cpp
src/gromacs/selection/sm_simple.cpp
src/gromacs/selection/tests/indexutil.cpp
src/gromacs/selection/tests/poscalc.cpp

index a903f995c70956ed7b44154f7af6fcb3b41a43f0..60acf693f4f93c87b78f7cd10eee86ee66fabb51 100644 (file)
@@ -565,7 +565,7 @@ alloc_selection_pos_data(const SelectionTreeElementPointer &sel)
         GMX_RELEASE_ASSERT(child,
                            "Subexpression elements should always have a child element");
     }
-    nalloc = child->v.u.p->nr;
+    nalloc = child->v.u.p->count();
     isize  = child->v.u.p->m.b.nra;
 
     /* For positions, we want to allocate just a single structure
index df6535a4fd6faa7946f17b6b338e1ac8a0eed38d..7a68a034b66cd6ea0966e837360fa467a96ec18c 100644 (file)
@@ -1024,7 +1024,6 @@ void
 gmx_ana_indexmap_clear(gmx_ana_indexmap_t *m)
 {
     m->type              = INDEX_UNKNOWN;
-    m->nr                = 0;
     m->refid             = NULL;
     m->mapid             = NULL;
     m->mapb.nr           = 0;
@@ -1091,8 +1090,7 @@ gmx_ana_indexmap_init(gmx_ana_indexmap_t *m, gmx_ana_index_t *g,
     m->type   = type;
     gmx_ana_index_make_block(&m->b, top, g, type, false);
     gmx_ana_indexmap_reserve(m, m->b.nr, m->b.nra);
-    m->nr = m->b.nr;
-    for (i = mi = 0; i < m->nr; ++i)
+    for (i = mi = 0; i < m->b.nr; ++i)
     {
         ii = (type == INDEX_UNKNOWN ? 0 : m->b.a[m->b.index[i]]);
         switch (type)
@@ -1116,15 +1114,15 @@ gmx_ana_indexmap_init(gmx_ana_indexmap_t *m, gmx_ana_index_t *g,
                 break;
         }
     }
-    for (i = 0; i < m->nr; ++i)
+    for (i = 0; i < m->b.nr; ++i)
     {
         m->refid[i] = i;
         m->mapid[i] = m->orgid[i];
     }
-    m->mapb.nr  = m->nr;
+    m->mapb.nr  = m->b.nr;
     m->mapb.nra = m->b.nra;
     m->mapb.a   = m->b.a;
-    std::memcpy(m->mapb.index, m->b.index, (m->nr+1)*sizeof(*(m->mapb.index)));
+    std::memcpy(m->mapb.index, m->b.index, (m->b.nr+1)*sizeof(*(m->mapb.index)));
     m->bStatic  = true;
 }
 
@@ -1183,7 +1181,6 @@ gmx_ana_indexmap_copy(gmx_ana_indexmap_t *dest, gmx_ana_indexmap_t *src, bool bF
         std::memcpy(dest->b.index,    src->b.index,   (dest->b.nr+1)*sizeof(*dest->b.index));
         std::memcpy(dest->b.a,        src->b.a,        dest->b.nra*sizeof(*dest->b.a));
     }
-    dest->nr         = src->nr;
     dest->mapb.nr    = src->mapb.nr;
     dest->mapb.nra   = src->mapb.nra;
     if (src->mapb.nalloc_a > 0)
@@ -1199,8 +1196,8 @@ gmx_ana_indexmap_copy(gmx_ana_indexmap_t *dest, gmx_ana_indexmap_t *src, bool bF
     {
         dest->mapb.a = src->mapb.a;
     }
-    std::memcpy(dest->refid,      src->refid,      dest->nr*sizeof(*dest->refid));
-    std::memcpy(dest->mapid,      src->mapid,      dest->nr*sizeof(*dest->mapid));
+    std::memcpy(dest->refid,      src->refid,      dest->mapb.nr*sizeof(*dest->refid));
+    std::memcpy(dest->mapid,      src->mapid,      dest->mapb.nr*sizeof(*dest->mapid));
     std::memcpy(dest->mapb.index, src->mapb.index, (dest->mapb.nr+1)*sizeof(*dest->mapb.index));
     dest->bStatic = src->bStatic;
 }
@@ -1283,7 +1280,7 @@ gmx_ana_indexmap_update(gmx_ana_indexmap_t *m, gmx_ana_index_t *g,
             }
         }
         set_atoms(m, m->b.nra, m->b.a);
-        m->nr = m->mapb.nr = m->b.nr;
+        m->mapb.nr = m->b.nr;
     }
     /* Exit immediately if the group is static */
     if (bToFull)
@@ -1294,7 +1291,6 @@ gmx_ana_indexmap_update(gmx_ana_indexmap_t *m, gmx_ana_index_t *g,
 
     if (bMaskOnly)
     {
-        m->nr = m->b.nr;
         for (i = j = bj = 0; i < g->isize; ++i, ++j)
         {
             /* Find the next atom in the block */
@@ -1345,9 +1341,8 @@ gmx_ana_indexmap_update(gmx_ana_indexmap_t *m, gmx_ana_index_t *g,
         }
         /* Update the number of blocks */
         m->mapb.index[bi] = g->isize;
-        m->nr             = bi;
+        m->mapb.nr        = bi;
     }
-    m->mapb.nr = m->nr;
     m->bStatic = false;
 }
 
index 52d99f6bdfdf5572eb2632cf95eab23ed2797551..01f5eafebe4a3a2f4f1e2a3a5d781668f461b32d 100644 (file)
@@ -102,16 +102,6 @@ typedef struct gmx_ana_indexmap_t
 {
     /** Type of the mapping. */
     e_index_t           type;
-    /*! \brief
-     * Current number of mapped values.
-     *
-     * This is the current number of values in the \p refid and \p mapid
-     * arrays.
-     * If \p bMaskOnly is provided to gmx_ana_indexmap_update(), this
-     * is always equal to \p b.nr, i.e., the number of blocks in the
-     * original index group.
-     */
-    int                 nr;
     /*! \brief
      * Current reference IDs.
      *
index f88a5f6fd109c2270ad1a3641b53cc4ca629ebd3..18dc7560ece0c75966d06bff05746d47f9359ae7 100644 (file)
@@ -495,8 +495,8 @@ parse_values_varnum(const SelectionParserValueList    &values,
     if (param->val.type == POS_VALUE)
     {
         gmx_ana_pos_reserve(param->val.u.p, valueCount, 0);
-        gmx_ana_pos_set_nr(param->val.u.p, valueCount);
         gmx_ana_indexmap_init(&param->val.u.p->m, NULL, NULL, INDEX_UNKNOWN);
+        gmx_ana_pos_set_nr(param->val.u.p, valueCount);
     }
     else
     {
index bbdbdbf15e9312d988a2e3eb4e855ceecd71dc67..6eedac6d08913674fbe9ae523b4a1d8ea03b18c5 100644 (file)
@@ -1043,7 +1043,7 @@ gmx_ana_poscalc_init_pos(gmx_ana_poscalc_t *pc, gmx_ana_pos_t *p)
     {
         gmx_ana_indexmap_set_static(&p->m, &pc->b);
     }
-    gmx_ana_pos_reserve(p, p->m.nr, 0);
+    gmx_ana_pos_reserve(p, p->m.mapb.nr, 0);
     if (pc->flags & POS_VELOCITIES)
     {
         gmx_ana_pos_reserve_velocities(p);
@@ -1052,7 +1052,6 @@ gmx_ana_poscalc_init_pos(gmx_ana_poscalc_t *pc, gmx_ana_pos_t *p)
     {
         gmx_ana_pos_reserve_forces(p);
     }
-    gmx_ana_pos_set_nr(p, p->m.nr);
 }
 
 /*!
@@ -1153,7 +1152,6 @@ gmx_ana_poscalc_update(gmx_ana_poscalc_t *pc, gmx_ana_pos_t *p,
     if (pc->flags & POS_DYNAMIC)
     {
         gmx_ana_indexmap_update(&p->m, g, false);
-        p->nr = p->m.nr;
     }
     else if (pc->flags & POS_MASKONLY)
     {
@@ -1175,14 +1173,14 @@ gmx_ana_poscalc_update(gmx_ana_poscalc_t *pc, gmx_ana_pos_t *p,
          * loop instead of in the beginning. */
         if (pc->flags & POS_DYNAMIC)
         {
-            for (bi = 0; bi < p->nr; ++bi)
+            for (bi = 0; bi < p->count(); ++bi)
             {
                 bj = pc->baseid[p->m.refid[bi]];
                 copy_rvec(pc->sbase->p->x[bj], p->x[bi]);
             }
             if (p->v)
             {
-                for (bi = 0; bi < p->nr; ++bi)
+                for (bi = 0; bi < p->count(); ++bi)
                 {
                     bj = pc->baseid[p->m.refid[bi]];
                     copy_rvec(pc->sbase->p->v[bj], p->v[bi]);
@@ -1190,7 +1188,7 @@ gmx_ana_poscalc_update(gmx_ana_poscalc_t *pc, gmx_ana_pos_t *p,
             }
             if (p->f)
             {
-                for (bi = 0; bi < p->nr; ++bi)
+                for (bi = 0; bi < p->count(); ++bi)
                 {
                     bj = pc->baseid[p->m.refid[bi]];
                     copy_rvec(pc->sbase->p->f[bj], p->f[bi]);
@@ -1199,14 +1197,14 @@ gmx_ana_poscalc_update(gmx_ana_poscalc_t *pc, gmx_ana_pos_t *p,
         }
         else
         {
-            for (bi = 0; bi < p->nr; ++bi)
+            for (bi = 0; bi < p->count(); ++bi)
             {
                 bj = pc->baseid[bi];
                 copy_rvec(pc->sbase->p->x[bj], p->x[bi]);
             }
             if (p->v)
             {
-                for (bi = 0; bi < p->nr; ++bi)
+                for (bi = 0; bi < p->count(); ++bi)
                 {
                     bj = pc->baseid[bi];
                     copy_rvec(pc->sbase->p->v[bj], p->v[bi]);
@@ -1214,7 +1212,7 @@ gmx_ana_poscalc_update(gmx_ana_poscalc_t *pc, gmx_ana_pos_t *p,
             }
             if (p->f)
             {
-                for (bi = 0; bi < p->nr; ++bi)
+                for (bi = 0; bi < p->count(); ++bi)
                 {
                     bj = pc->baseid[bi];
                     copy_rvec(pc->sbase->p->f[bj], p->f[bi]);
index 554fefc8435568d5f29718d92a4dbc0a91acfd5b..4bdcf46e4cfcfb5c2320be67ba1fa7eba3b9c4a8 100644 (file)
@@ -57,7 +57,6 @@
 void
 gmx_ana_pos_clear(gmx_ana_pos_t *pos)
 {
-    pos->nr = 0;
     pos->x  = NULL;
     pos->v  = NULL;
     pos->f  = NULL;
@@ -175,7 +174,6 @@ void
 gmx_ana_pos_init_const(gmx_ana_pos_t *pos, const rvec x)
 {
     gmx_ana_pos_clear(pos);
-    pos->nr = 1;
     snew(pos->x, 1);
     snew(pos->v, 1);
     snew(pos->f, 1);
@@ -197,7 +195,6 @@ gmx_ana_pos_init_const(gmx_ana_pos_t *pos, const rvec x)
 void
 gmx_ana_pos_deinit(gmx_ana_pos_t *pos)
 {
-    pos->nr               = 0;
     sfree(pos->x); pos->x = NULL;
     sfree(pos->v); pos->v = NULL;
     sfree(pos->f); pos->f = NULL;
@@ -234,7 +231,7 @@ gmx_ana_pos_copy(gmx_ana_pos_t *dest, gmx_ana_pos_t *src, bool bFirst)
 {
     if (bFirst)
     {
-        gmx_ana_pos_reserve(dest, src->nr, 0);
+        gmx_ana_pos_reserve(dest, src->count(), 0);
         if (src->v)
         {
             gmx_ana_pos_reserve_velocities(dest);
@@ -244,17 +241,16 @@ gmx_ana_pos_copy(gmx_ana_pos_t *dest, gmx_ana_pos_t *src, bool bFirst)
             gmx_ana_pos_reserve_forces(dest);
         }
     }
-    dest->nr = src->nr;
-    memcpy(dest->x, src->x, dest->nr*sizeof(*dest->x));
+    memcpy(dest->x, src->x, src->count()*sizeof(*dest->x));
     if (dest->v)
     {
         GMX_ASSERT(src->v, "src velocities should be non-null if dest velocities are allocated");
-        memcpy(dest->v, src->v, dest->nr*sizeof(*dest->v));
+        memcpy(dest->v, src->v, src->count()*sizeof(*dest->v));
     }
     if (dest->f)
     {
         GMX_ASSERT(src->f, "src forces should be non-null if dest forces are allocated");
-        memcpy(dest->f, src->f, dest->nr*sizeof(*dest->f));
+        memcpy(dest->f, src->f, src->count()*sizeof(*dest->f));
     }
     gmx_ana_indexmap_copy(&dest->m, &src->m, bFirst);
 }
@@ -266,7 +262,8 @@ gmx_ana_pos_copy(gmx_ana_pos_t *dest, gmx_ana_pos_t *src, bool bFirst)
 void
 gmx_ana_pos_set_nr(gmx_ana_pos_t *pos, int nr)
 {
-    pos->nr = nr;
+    // TODO: This puts the mapping in a somewhat inconsistent state.
+    pos->m.mapb.nr = nr;
 }
 
 /*!
@@ -277,8 +274,6 @@ gmx_ana_pos_set_nr(gmx_ana_pos_t *pos, int nr)
 void
 gmx_ana_pos_empty_init(gmx_ana_pos_t *pos)
 {
-    pos->nr         = 0;
-    pos->m.nr       = 0;
     pos->m.mapb.nr  = 0;
     pos->m.mapb.nra = 0;
     pos->m.b.nr     = 0;
@@ -299,8 +294,6 @@ gmx_ana_pos_empty_init(gmx_ana_pos_t *pos)
 void
 gmx_ana_pos_empty(gmx_ana_pos_t *pos)
 {
-    pos->nr         = 0;
-    pos->m.nr       = 0;
     pos->m.mapb.nr  = 0;
     pos->m.mapb.nra = 0;
     /* This should not really be necessary, but do it for safety... */
@@ -322,7 +315,7 @@ gmx_ana_pos_append_init(gmx_ana_pos_t *dest, gmx_ana_pos_t *src, int i)
 {
     int  j, k;
 
-    j = dest->nr;
+    j = dest->count();
     copy_rvec(src->x[i], dest->x[j]);
     if (dest->v)
     {
@@ -356,10 +349,8 @@ gmx_ana_pos_append_init(gmx_ana_pos_t *dest, gmx_ana_pos_t *src, int i)
     }
     dest->m.mapb.index[j+1] = dest->m.mapb.nra;
     dest->m.b.index[j+1]    = dest->m.mapb.nra;
-    dest->nr++;
-    dest->m.nr      = dest->nr;
-    dest->m.mapb.nr = dest->nr;
-    dest->m.b.nr    = dest->nr;
+    dest->m.mapb.nr++;
+    dest->m.b.nr++;
 }
 
 /*!
@@ -376,7 +367,7 @@ gmx_ana_pos_append(gmx_ana_pos_t *dest, gmx_ana_pos_t *src, int i, int refid)
     {
         dest->m.mapb.a[dest->m.mapb.nra++] = src->m.mapb.a[k];
     }
-    const int j = dest->nr;
+    const int j = dest->count();
     if (dest->v)
     {
         if (src->v)
@@ -419,9 +410,7 @@ gmx_ana_pos_append(gmx_ana_pos_t *dest, gmx_ana_pos_t *src, int i, int refid)
         dest->m.mapid[j] = dest->m.orgid[refid];
     }
     dest->m.mapb.index[j+1] = dest->m.mapb.nra;
-    dest->nr++;
-    dest->m.nr      = dest->nr;
-    dest->m.mapb.nr = dest->nr;
+    dest->m.mapb.nr++;
 }
 
 /*!
@@ -434,7 +423,7 @@ gmx_ana_pos_append(gmx_ana_pos_t *dest, gmx_ana_pos_t *src, int i, int refid)
 void
 gmx_ana_pos_append_finish(gmx_ana_pos_t *pos)
 {
-    if (pos->m.nr != pos->m.b.nr)
+    if (pos->m.mapb.nr != pos->m.b.nr)
     {
         pos->m.bStatic = false;
     }
index 37397008a1e86af987f5267f14c22083736d06fa..f671dfc464df074fe85f18c96c9f631552d7a753 100644 (file)
  */
 typedef struct gmx_ana_pos_t
 {
-    /*! \brief
-     * Number of positions.
-     */
-    int                 nr;
+    //! Returns the number of positions.
+    int count() const { return m.mapb.nr; }
+
     /*! \brief
      * Array of positions.
      */
index c3c61bd5c5b80b4b63bb7155f6edb00ea7811dcb..8155a2b4dd95ac3af8cbb02b848279c006dabb57 100644 (file)
@@ -153,7 +153,7 @@ void computeMassesAndCharges(const t_topology *top, const gmx_ana_pos_t &pos,
     GMX_ASSERT(top != NULL, "Should not have been called with NULL topology");
     masses->clear();
     charges->clear();
-    for (int b = 0; b < pos.nr; ++b)
+    for (int b = 0; b < pos.count(); ++b)
     {
         real mass   = 0.0;
         real charge = 0.0;
@@ -236,7 +236,6 @@ SelectionData::restoreOriginalPositions(const t_topology *top)
         gmx_ana_pos_t &p = rawPositions_;
         gmx_ana_indexmap_update(&p.m, rootElement().v.u.g,
                                 hasFlag(gmx::efSelection_DynamicMask));
-        p.nr = p.m.nr;
         refreshMassesAndCharges(top);
     }
 }
@@ -250,7 +249,7 @@ SelectionData::restoreOriginalPositions(const t_topology *top)
 Selection::operator AnalysisNeighborhoodPositions() const
 {
     return AnalysisNeighborhoodPositions(data().rawPositions_.x,
-                                         data().rawPositions_.nr);
+                                         data().rawPositions_.count());
 }
 
 
@@ -350,7 +349,7 @@ Selection::printDebugInfo(FILE *fp, int nmaxind) const
 SelectionPosition::operator AnalysisNeighborhoodPositions() const
 {
     return AnalysisNeighborhoodPositions(sel_->rawPositions_.x,
-                                         sel_->rawPositions_.nr)
+                                         sel_->rawPositions_.count())
                .selectSingleFromArray(i_);
 }
 
index d681c50d4843e9b2f46acae044522b2121baf6a7..13119da58c5b6a740adaaa4325d33f9e9d34f1fc 100644 (file)
@@ -106,7 +106,7 @@ class SelectionData
         e_index_t type() const { return rawPositions_.m.type; }
 
         //! Number of positions in the selection.
-        int posCount() const { return rawPositions_.nr; }
+        int posCount() const { return rawPositions_.count(); }
         //! Returns the root of the evaluation tree for this selection.
         SelectionTreeElement &rootElement() { return rootElement_; }
 
index 44bda5be25b84f829049901dbced13f45325f31d..8d3d0e7732c9254d6e972503114be0056a0a6c04 100644 (file)
@@ -251,7 +251,7 @@ init_frame_common(t_topology *top, t_trxframe *fr, t_pbc *pbc, void *data)
     t_methoddata_distance *d = (t_methoddata_distance *)data;
 
     d->nbsearch.reset();
-    gmx::AnalysisNeighborhoodPositions pos(d->p.x, d->p.nr);
+    gmx::AnalysisNeighborhoodPositions pos(d->p.x, d->p.count());
     d->nbsearch = d->nb.initSearch(pbc, pos);
 }
 
@@ -269,7 +269,7 @@ evaluate_distance(t_topology *top, t_trxframe *fr, t_pbc *pbc,
     t_methoddata_distance *d = (t_methoddata_distance *)data;
 
     out->nr = pos->m.mapb.nra;
-    for (int b = 0; b < pos->nr; ++b)
+    for (int b = 0; b < pos->count(); ++b)
     {
         real dist = d->nbsearch.minimumDistance(pos->x[b]);
         for (int i = pos->m.mapb.index[b]; i < pos->m.mapb.index[b+1]; ++i)
@@ -293,7 +293,7 @@ evaluate_within(t_topology *top, t_trxframe *fr, t_pbc *pbc,
     t_methoddata_distance *d = (t_methoddata_distance *)data;
 
     out->u.g->isize = 0;
-    for (int b = 0; b < pos->nr; ++b)
+    for (int b = 0; b < pos->count(); ++b)
     {
         if (d->nbsearch.isWithin(pos->x[b]))
         {
index 16ae2a5f3df47003a722ffa4f9ca29815f757811..61300e01d68193dc6b1916586a679017a50a1e4c 100644 (file)
@@ -427,7 +427,7 @@ init_frame_insolidangle(t_topology *top, t_trxframe *fr, t_pbc *pbc, void *data)
 
     free_surface_points(d);
     clear_surface_points(d);
-    for (i = 0; i < d->span.nr; ++i)
+    for (i = 0; i < d->span.count(); ++i)
     {
         if (pbc)
         {
@@ -480,10 +480,8 @@ static void
 evaluate_insolidangle(t_topology *top, t_trxframe *fr, t_pbc *pbc,
                       gmx_ana_pos_t *pos, gmx_ana_selvalue_t *out, void *data)
 {
-    int                        b;
-
     out->u.g->isize = 0;
-    for (b = 0; b < pos->nr; ++b)
+    for (int b = 0; b < pos->count(); ++b)
     {
         if (accept_insolidangle(pos->x[b], pbc, data))
         {
index 61bcb085ffabf0656d48caec6f9d8bcd5dc2c4a5..2ad9f02dc56bca2c2ec7090812235e49c28bca08 100644 (file)
@@ -190,9 +190,9 @@ init_merge(t_topology *top, int npar, gmx_ana_selparam_t *param, void *data)
     /* If no stride given, deduce it from the input sizes */
     if (d->stride == 0)
     {
-        d->stride = d->p1.nr / d->p2.nr;
+        d->stride = d->p1.count() / d->p2.count();
     }
-    if (d->p1.nr != d->stride*d->p2.nr)
+    if (d->p1.count() != d->stride*d->p2.count())
     {
         GMX_THROW(gmx::InconsistentInputError("The number of positions to be merged are not compatible"));
     }
@@ -219,7 +219,7 @@ init_output_common(t_topology *top, gmx_ana_selvalue_t *out, void *data)
     {
         out->u.p->m.type = d->p1.m.type;
     }
-    gmx_ana_pos_reserve_for_append(out->u.p, d->p1.nr + d->p2.nr,
+    gmx_ana_pos_reserve_for_append(out->u.p, d->p1.count() + d->p2.count(),
                                    d->p1.m.b.nra + d->p2.m.b.nra,
                                    d->p1.v != NULL, d->p1.f != NULL);
     gmx_ana_pos_empty_init(out->u.p);
@@ -237,7 +237,7 @@ init_output_merge(t_topology *top, gmx_ana_selvalue_t *out, void *data)
     int                 i, j;
 
     init_output_common(top, out, data);
-    for (i = 0; i < d->p2.nr; ++i)
+    for (i = 0; i < d->p2.count(); ++i)
     {
         for (j = 0; j < d->stride; ++j)
         {
@@ -259,11 +259,11 @@ init_output_plus(t_topology *top, gmx_ana_selvalue_t *out, void *data)
     int                 i;
 
     init_output_common(top, out, data);
-    for (i = 0; i < d->p1.nr; ++i)
+    for (i = 0; i < d->p1.count(); ++i)
     {
         gmx_ana_pos_append_init(out->u.p, &d->p1, i);
     }
-    for (i = 0; i < d->p2.nr; ++i)
+    for (i = 0; i < d->p2.count(); ++i)
     {
         gmx_ana_pos_append_init(out->u.p, &d->p2, i);
     }
@@ -298,12 +298,12 @@ evaluate_merge(t_topology *top, t_trxframe *fr, t_pbc *pbc,
     int                 i, j;
     int                 refid;
 
-    if (d->p1.nr != d->stride*d->p2.nr)
+    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.nr; ++i)
+    for (i = 0; i < d->p2.count(); ++i)
     {
         for (j = 0; j < d->stride; ++j)
         {
@@ -337,12 +337,12 @@ evaluate_plus(t_topology *top, t_trxframe *fr, t_pbc *pbc,
     int                 refid;
 
     gmx_ana_pos_empty(out->u.p);
-    for (i = 0; i < d->p1.nr; ++i)
+    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.nr; ++i)
+    for (i = 0; i < d->p2.count(); ++i)
     {
         refid = d->p2.m.refid[i];
         if (refid != -1)
index da741d26bd2c84ab669bed3daed15bac7c971eab..cc84bf5c31a84fc2d6aff4be586923e28e97770b 100644 (file)
@@ -153,7 +153,7 @@ init_permute(t_topology *top, int npar, gmx_ana_selparam_t *param, void *data)
 
     d->n    = param[1].val.nr;
     d->perm = param[1].val.u.i;
-    if (d->p.nr % d->n != 0)
+    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)));
@@ -190,10 +190,10 @@ init_output_permute(t_topology *top, gmx_ana_selvalue_t *out, void *data)
     int                   i, j, b;
 
     out->u.p->m.type = d->p.m.type;
-    gmx_ana_pos_reserve_for_append(out->u.p, d->p.nr, d->p.m.b.nra,
+    gmx_ana_pos_reserve_for_append(out->u.p, d->p.count(), d->p.m.b.nra,
                                    d->p.v != NULL, d->p.f != NULL);
     gmx_ana_pos_empty_init(out->u.p);
-    for (i = 0; i < d->p.nr; i += d->n)
+    for (i = 0; i < d->p.count(); i += d->n)
     {
         for (j = 0; j < d->n; ++j)
         {
@@ -237,13 +237,13 @@ evaluate_permute(t_topology *top, t_trxframe *fr, t_pbc *pbc,
     int                   i, j, b;
     int                   refid;
 
-    if (d->p.nr % d->n != 0)
+    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.nr; i += d->n)
+    for (i = 0; i < d->p.count(); i += d->n)
     {
         for (j = 0; j < d->n; ++j)
         {
index f510e1ed90bf227bacc349612d20e70520c7f443..c14c357f6610ff0a00c5feaf1451e644f9f013b7 100644 (file)
@@ -848,7 +848,7 @@ evaluate_betafactor(t_topology *top, t_trxframe *fr, t_pbc *pbc,
 static void
 evaluate_coord(real out[], gmx_ana_pos_t *pos, int d)
 {
-    for (int b = 0; b < pos->nr; ++b)
+    for (int b = 0; b < pos->count(); ++b)
     {
         const real v = pos->x[b][d];
         for (int i = pos->m.mapb.index[b]; i < pos->m.mapb.index[b+1]; ++i)
index 12998ba02b89830869bb03dd17016d75854d3f44..76ee4dbbd91c9ebc9d4357e5e374494f0c4df316 100644 (file)
@@ -418,12 +418,11 @@ void IndexMapTest::testUpdate(int atomCount, const int atoms[], bool bMaskOnly,
 void IndexMapTest::checkMapping(int atomCount, const int atoms[],
                                 const char *name)
 {
-    ASSERT_EQ(map_.nr, map_.mapb.nr);
     gmx::test::TestReferenceChecker compound(
             checker_.checkCompound("IndexMapping", name));
     compound.checkSequenceArray(atomCount, atoms, "Input");
-    compound.checkInteger(map_.nr, "Count");
-    for (int i = 0; i < map_.nr; ++i)
+    compound.checkInteger(map_.mapb.nr, "Count");
+    for (int i = 0; i < map_.mapb.nr; ++i)
     {
         gmx::test::TestReferenceChecker blockCompound(
                 compound.checkCompound("Block", NULL));
index cd74475a564b850499d9c227debf283e8c1e9815..40ffa76ef4514af4761dfd485c8396f7115bc032 100644 (file)
@@ -311,11 +311,9 @@ void PositionCalculationTest::checkPositions(
         gmx::test::TestReferenceChecker *checker,
         const char *name, gmx_ana_pos_t *p, bool bCoordinates)
 {
-    EXPECT_EQ(p->nr, p->m.nr);
-    EXPECT_EQ(p->nr, p->m.mapb.nr);
     gmx::test::TestReferenceChecker compound(
             checker->checkCompound("Positions", name));
-    compound.checkInteger(p->nr, "Count");
+    compound.checkInteger(p->count(), "Count");
     const char *type = "???";
     switch (p->m.type)
     {
@@ -326,8 +324,8 @@ void PositionCalculationTest::checkPositions(
         case INDEX_ALL:     type = "single";    break;
     }
     compound.checkString(type, "Type");
-    compound.checkSequenceArray(p->nr + 1, p->m.mapb.index, "Block");
-    for (int i = 0; i < p->nr; ++i)
+    compound.checkSequenceArray(p->count() + 1, p->m.mapb.index, "Block");
+    for (int i = 0; i < p->count(); ++i)
     {
         gmx::test::TestReferenceChecker posCompound(
                 compound.checkCompound("Position", NULL));