/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2009,2010,2011,2012,2013, by the GROMACS development team, led by
- * David van der Spoel, Berk Hess, Erik Lindahl, and including many
- * others, as listed in the AUTHORS file in the top-level source
- * directory and at http://www.gromacs.org.
+ * Copyright (c) 2009,2010,2011,2012,2013,2014, by the GROMACS development team, led by
+ * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+ * and including many others, as listed in the AUTHORS file in the
+ * top-level source directory and at http://www.gromacs.org.
*
* GROMACS is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* \author Teemu Murtola <teemu.murtola@gmail.com>
* \ingroup module_selection
*/
-#include <string.h>
+#include "gmxpre.h"
+
+#include "evaluate.h"
-#include "gromacs/legacyheaders/maths.h"
-#include "gromacs/legacyheaders/smalloc.h"
-#include "gromacs/legacyheaders/vec.h"
+#include <string.h>
+#include "gromacs/math/utilities.h"
+#include "gromacs/math/vec.h"
#include "gromacs/selection/indexutil.h"
-#include "gromacs/selection/poscalc.h"
#include "gromacs/selection/selection.h"
-#include "gromacs/selection/selmethod.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/gmxassert.h"
+#include "gromacs/utility/smalloc.h"
-#include "evaluate.h"
#include "mempool.h"
+#include "poscalc.h"
#include "selectioncollection-impl.h"
#include "selelem.h"
+#include "selmethod.h"
using gmx::SelectionTreeElement;
using gmx::SelectionTreeElementPointer;
* Evaluates each child of \p sel in \p g.
*/
void
-_gmx_sel_evaluate_children(gmx_sel_evaluate_t *data,
- const SelectionTreeElementPointer &sel,
- gmx_ana_index_t *g)
+_gmx_sel_evaluate_children(gmx_sel_evaluate_t *data,
+ const gmx::SelectionTreeElementPointer &sel,
+ gmx_ana_index_t *g)
{
SelectionTreeElementPointer child = sel->child;
while (child)
}
}
-/*!
- * \param[in] data Data for the current frame.
- * \param[in] sel Selection element being evaluated.
- * \param[in] g Group for which \p sel should be evaluated
- * (not used, can be NULL).
- * \returns 0 on success, a non-zero error code on error.
- *
- * Evaluates the first child element in the group defined by \p sel->u.cgrp.
- * If \p sel->u.cgrp is empty, nothing is done.
- * The value of \p sel is not touched (root elements do not evaluate to
- * values).
- *
- * This function can be used as gmx::SelectionTreeElement::evaluate for
- * \ref SEL_ROOT elements.
- */
void
-_gmx_sel_evaluate_root(gmx_sel_evaluate_t *data,
- const SelectionTreeElementPointer &sel,
- gmx_ana_index_t *g)
+_gmx_sel_evaluate_root(gmx_sel_evaluate_t *data,
+ const gmx::SelectionTreeElementPointer &sel,
+ gmx_ana_index_t * /* g */)
{
if (sel->u.cgrp.isize == 0 || !sel->child->evaluate)
{
sel->u.cgrp.isize < 0 ? NULL : &sel->u.cgrp);
}
-/*!
- * \param[in] data Data for the current frame.
- * \param[in] sel Selection element being evaluated.
- * \param[in] g Group for which \p sel should be evaluated.
- * \returns 0 for success.
- *
- * Sets the value of \p sel to the intersection of \p g and \p sel->u.cgrp.
- *
- * This function can be used as gmx::SelectionTreeElement::evaluate for
- * \ref SEL_CONST elements with value type \ref GROUP_VALUE.
- */
void
-_gmx_sel_evaluate_static(gmx_sel_evaluate_t *data,
- const SelectionTreeElementPointer &sel,
- gmx_ana_index_t *g)
+_gmx_sel_evaluate_static(gmx_sel_evaluate_t * /* data */,
+ const gmx::SelectionTreeElementPointer &sel,
+ gmx_ana_index_t *g)
{
- gmx_ana_index_intersection(sel->v.u.g, &sel->u.cgrp, g);
+ if (sel->flags & SEL_UNSORTED)
+ {
+ // This only works if g contains all the atoms, but that is currently
+ // the only supported case.
+ gmx_ana_index_copy(sel->v.u.g, &sel->u.cgrp, false);
+ }
+ else
+ {
+ gmx_ana_index_intersection(sel->v.u.g, &sel->u.cgrp, g);
+ }
}
* full subexpression handling.
*/
void
-_gmx_sel_evaluate_subexpr_simple(gmx_sel_evaluate_t *data,
- const SelectionTreeElementPointer &sel,
- gmx_ana_index_t *g)
+_gmx_sel_evaluate_subexpr_simple(gmx_sel_evaluate_t *data,
+ const gmx::SelectionTreeElementPointer &sel,
+ gmx_ana_index_t *g)
{
if (sel->child->evaluate)
{
* not need full subexpression handling.
*/
void
-_gmx_sel_evaluate_subexpr_staticeval(gmx_sel_evaluate_t *data,
- const SelectionTreeElementPointer &sel,
- gmx_ana_index_t *g)
+_gmx_sel_evaluate_subexpr_staticeval(gmx_sel_evaluate_t *data,
+ const gmx::SelectionTreeElementPointer &sel,
+ gmx_ana_index_t *g)
{
if (sel->u.cgrp.isize == 0)
{
* major problem.
*/
void
-_gmx_sel_evaluate_subexpr(gmx_sel_evaluate_t *data,
- const SelectionTreeElementPointer &sel,
- gmx_ana_index_t *g)
+_gmx_sel_evaluate_subexpr(gmx_sel_evaluate_t *data,
+ const gmx::SelectionTreeElementPointer &sel,
+ gmx_ana_index_t *g)
{
gmx_ana_index_t gmiss;
* other references.
*/
void
-_gmx_sel_evaluate_subexprref_simple(gmx_sel_evaluate_t *data,
- const SelectionTreeElementPointer &sel,
- gmx_ana_index_t *g)
+_gmx_sel_evaluate_subexprref_simple(gmx_sel_evaluate_t *data,
+ const gmx::SelectionTreeElementPointer &sel,
+ gmx_ana_index_t *g)
{
if (g)
{
* \ref SEL_SUBEXPRREF elements.
*/
void
-_gmx_sel_evaluate_subexprref(gmx_sel_evaluate_t *data,
- const SelectionTreeElementPointer &sel,
- gmx_ana_index_t *g)
+_gmx_sel_evaluate_subexprref(gmx_sel_evaluate_t *data,
+ const gmx::SelectionTreeElementPointer &sel,
+ gmx_ana_index_t *g)
{
int i, j;
* but is used internally.
*/
void
-_gmx_sel_evaluate_method_params(gmx_sel_evaluate_t *data,
- const SelectionTreeElementPointer &sel,
- gmx_ana_index_t *g)
+_gmx_sel_evaluate_method_params(gmx_sel_evaluate_t *data,
+ const gmx::SelectionTreeElementPointer &sel,
+ gmx_ana_index_t *g)
{
SelectionTreeElementPointer child = sel->child;
while (child)
* \ref SEL_EXPRESSION elements.
*/
void
-_gmx_sel_evaluate_method(gmx_sel_evaluate_t *data,
- const SelectionTreeElementPointer &sel,
- gmx_ana_index_t *g)
+_gmx_sel_evaluate_method(gmx_sel_evaluate_t *data,
+ const gmx::SelectionTreeElementPointer &sel,
+ gmx_ana_index_t *g)
{
_gmx_sel_evaluate_method_params(data, sel, g);
if (sel->flags & SEL_INITFRAME)
* \ref SEL_MODIFIER elements.
*/
void
-_gmx_sel_evaluate_modifier(gmx_sel_evaluate_t *data,
- const SelectionTreeElementPointer &sel,
- gmx_ana_index_t *g)
+_gmx_sel_evaluate_modifier(gmx_sel_evaluate_t *data,
+ const gmx::SelectionTreeElementPointer &sel,
+ gmx_ana_index_t *g)
{
_gmx_sel_evaluate_method_params(data, sel, g);
if (sel->flags & SEL_INITFRAME)
* \ref SEL_BOOLEAN elements with \ref BOOL_NOT.
*/
void
-_gmx_sel_evaluate_not(gmx_sel_evaluate_t *data,
- const SelectionTreeElementPointer &sel,
- gmx_ana_index_t *g)
+_gmx_sel_evaluate_not(gmx_sel_evaluate_t *data,
+ const gmx::SelectionTreeElementPointer &sel,
+ gmx_ana_index_t *g)
{
MempoolSelelemReserver reserver(sel->child, g->isize);
sel->child->evaluate(data, sel->child, g);
* \ref SEL_BOOLEAN elements with \ref BOOL_AND.
*/
void
-_gmx_sel_evaluate_and(gmx_sel_evaluate_t *data,
- const SelectionTreeElementPointer &sel,
- gmx_ana_index_t *g)
+_gmx_sel_evaluate_and(gmx_sel_evaluate_t *data,
+ const gmx::SelectionTreeElementPointer &sel,
+ gmx_ana_index_t *g)
{
SelectionTreeElementPointer child = sel->child;
/* Skip the first child if it does not have an evaluation function. */
* \ref SEL_BOOLEAN elements with \ref BOOL_OR.
*/
void
-_gmx_sel_evaluate_or(gmx_sel_evaluate_t *data,
- const SelectionTreeElementPointer &sel,
- gmx_ana_index_t *g)
+_gmx_sel_evaluate_or(gmx_sel_evaluate_t *data,
+ const gmx::SelectionTreeElementPointer &sel,
+ gmx_ana_index_t *g)
{
gmx_ana_index_t tmp, tmp2;
* \returns 0 on success, a non-zero error code on error.
*/
void
-_gmx_sel_evaluate_arithmetic(gmx_sel_evaluate_t *data,
- const SelectionTreeElementPointer &sel,
- gmx_ana_index_t *g)
+_gmx_sel_evaluate_arithmetic(gmx_sel_evaluate_t *data,
+ const gmx::SelectionTreeElementPointer &sel,
+ gmx_ana_index_t *g)
{
int n, i, i1, i2;
real lval, rval = 0., val = 0.;