Gromacs
2026.0-dev-20241106-9ba7f4d
|
#include "gmxpre.h"
#include <cmath>
#include <cstdio>
#include "gromacs/math/utilities.h"
#include "gromacs/selection/indexutil.h"
#include "gromacs/selection/selparam.h"
#include "gromacs/selection/selvalue.h"
#include "gromacs/utility/arraysize.h"
#include "gromacs/utility/basedefinitions.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/real.h"
#include "gromacs/utility/smalloc.h"
#include "keywords.h"
#include "selmethod.h"
Implements internal selection method for comparison expressions.
Classes | |
struct | t_compare_value |
Data structure for comparison expression operand values. More... | |
struct | t_methoddata_compare |
Data structure for comparison expression evaluation. More... | |
Macros | |
#define | CMP_SINGLEVAL 1 |
The operand has a single value. More... | |
#define | CMP_DYNAMICVAL 2 |
The operand value is dynamic. More... | |
#define | CMP_REALVAL 4 |
The value is real. More... | |
#define | CMP_ALLOCINT 16 |
The integer array is allocated. More... | |
#define | CMP_ALLOCREAL 32 |
The real array is allocated. More... | |
Enumerations | |
enum | e_comparison_t { CMP_INVALID, CMP_LESS, CMP_LEQ, CMP_GTR, CMP_GEQ, CMP_EQUAL, CMP_NEQ } |
Defines the comparison operator for comparison expressions. More... | |
Functions | |
static void * | init_data_compare (int npar, gmx_ana_selparam_t *param) |
Allocates data for comparison expression evaluation. More... | |
static void | init_compare (const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *data) |
Initializes data for comparison expression evaluation. More... | |
static void | free_data_compare (void *data) |
Frees the memory allocated for comparison expression evaluation. More... | |
static void | evaluate_compare (const gmx::SelMethodEvalContext &context, gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data) |
Evaluates comparison expressions. More... | |
static e_comparison_t | comparison_type (const char *str) |
Returns a e_comparison_t value corresponding to an operator. More... | |
static const char * | comparison_type_str (e_comparison_t cmpt) |
Returns a string corresponding to a e_comparison_t value. More... | |
void | _gmx_selelem_print_compare_info (FILE *fp, void *data) |
Prints information about a comparison expression. More... | |
static e_comparison_t | reverse_comparison_type (e_comparison_t type) |
Reverses a comparison operator. More... | |
static int | init_comparison_value (t_compare_value *val, gmx_ana_selparam_t param[2]) |
Initializes the value storage for comparison expression. More... | |
static void | convert_int_real (int n, t_compare_value *val) |
Converts an integer value to floating point. More... | |
static void | convert_real_int (int n, t_compare_value *val, e_comparison_t cmpt, bool bRight) |
Converts a floating point value to integer. More... | |
static void | evaluate_compare_int (gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data) |
Implementation for evaluate_compare() for integer values. More... | |
static void | evaluate_compare_real (gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data) |
Implementation for evaluate_compare() if either value is non-integer. More... | |
Variables | |
static gmx_ana_selparam_t | smparams_compare [] |
Parameters for comparison expression evaluation. More... | |
gmx_ana_selmethod_t | sm_compare |
Selection method data for comparison expression evaluation. More... | |
#define CMP_ALLOCINT 16 |
The integer array is allocated.
#define CMP_ALLOCREAL 32 |
The real array is allocated.
#define CMP_DYNAMICVAL 2 |
The operand value is dynamic.
#define CMP_REALVAL 4 |
The value is real.
#define CMP_SINGLEVAL 1 |
The operand has a single value.
enum e_comparison_t |
void _gmx_selelem_print_compare_info | ( | FILE * | fp, |
void * | data | ||
) |
Prints information about a comparison expression.
[in] | fp | File to receive the output. |
[in] | data | Should point to a t_methoddata_compare . |
|
static |
Returns a e_comparison_t
value corresponding to an operator.
[in] | str | String to process. |
str
.str
can contain any number of characters; only the first two are used. If the beginning of str
does not match any of the recognized types, CMP_INVALID is returned.
|
static |
Returns a string corresponding to a e_comparison_t
value.
[in] | cmpt | Comparison type to convert. |
cmpt
.The return value points to a string constant and should not be free'd
.
The function returns NULL if cmpt
is not one of the valid values.
|
static |
Converts an integer value to floating point.
[in] | n | Number of values in the val->u array. |
[in,out] | val | Value to convert. |
|
static |
Converts a floating point value to integer.
[in] | n | Number of values in the val->u array. |
[in,out] | val | Value to convert. |
[in] | cmpt | Comparison operator type. |
[in] | bRight | true if val appears on the right hand size of cmpt . |
The values are rounded such that the same comparison operator can be used.
|
static |
Evaluates comparison expressions.
[in] | context | Not used. |
[in] | g | Evaluation index group. |
[out] | out | Output data structure (out->u.g is used). |
[in] | data | Should point to a t_methoddata_compare . |
|
static |
Implementation for evaluate_compare() for integer values.
[in] | g | Evaluation index group. |
[out] | out | Output data structure (out->u.g is used). |
[in] | data | Should point to a t_methoddata_compare . |
|
static |
Implementation for evaluate_compare() if either value is non-integer.
[in] | g | Evaluation index group. |
[out] | out | Output data structure (out->u.g is used). |
[in] | data | Should point to a t_methoddata_compare . |
Left value is assumed to be real-valued; right value can be either. This is ensured by the initialization method.
|
static |
Frees the memory allocated for comparison expression evaluation.
data | Data to free (should point to a t_methoddata_compare ). |
Frees the memory allocated for t_methoddata_compare
.
|
static |
Initializes data for comparison expression evaluation.
[in] | top | Not used. |
[in] | npar | Not used (should be 5). |
[in] | param | Method parameters (should point to smparams_compare). |
[in] | data | Should point to a t_methoddata_compare . |
|
static |
Initializes the value storage for comparison expression.
[out] | val | Value structure to initialize. |
[in] | param | Parameters to use for initialization. |
|
static |
Allocates data for comparison expression evaluation.
[in] | npar | Not used (should be 5). |
[in,out] | param | Method parameters (should point to a copy of smparams_compare). |
t_methoddata_compare
).Allocates memory for a t_methoddata_compare
structure.
|
static |
Reverses a comparison operator.
[in] | type | Comparison operator to reverse. |
type
when the left and right sides are interchanged. gmx_ana_selmethod_t sm_compare |
Selection method data for comparison expression evaluation.
Selection method data for comparison expression evaluation.
|
static |
Parameters for comparison expression evaluation.