Unverified Commit cf11945e authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

get rid of utils::boundsbig() by making it a template function with two specializations

parent 8d2c16ad
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -878,9 +878,6 @@ Argument processing
.. doxygenfunction:: bounds
   :project: progguide

.. doxygenfunction:: boundsbig
   :project: progguide

.. doxygenfunction:: expand_args
   :project: progguide

+2 −2
Original line number Diff line number Diff line
@@ -633,7 +633,7 @@ void Set::selection(int n)
    if (atom->tag_enable == 0)
      error->all(FLERR,"Cannot use set atom with no atom IDs defined");
    bigint nlobig,nhibig;
    utils::boundsbig(FLERR,id,1,MAXTAGINT,nlobig,nhibig,error);
    utils::bounds(FLERR,id,1,MAXTAGINT,nlobig,nhibig,error);

    tagint *tag = atom->tag;
    for (int i = 0; i < n; i++)
@@ -644,7 +644,7 @@ void Set::selection(int n)
    if (atom->molecule_flag == 0)
      error->all(FLERR,"Cannot use set mol with no molecule IDs defined");
    bigint nlobig,nhibig;
    utils::boundsbig(FLERR,id,1,MAXTAGINT,nlobig,nhibig,error);
    utils::bounds(FLERR,id,1,MAXTAGINT,nlobig,nhibig,error);

    tagint *molecule = atom->molecule;
    for (int i = 0; i < n; i++)
+6 −4
Original line number Diff line number Diff line
@@ -359,8 +359,9 @@ tagint utils::tnumeric(const char *file, int line, const char *str,
/* ----------------------------------------------------------------------
   compute bounds implied by numeric str with a possible wildcard asterisk
------------------------------------------------------------------------- */
template<>
void utils::bounds(const char *file, int line, char *str,
                   int nmin, int nmax, int &nlo, int &nhi, Error *error)
                   bigint nmin, bigint nmax, int &nlo, int &nhi, Error *error)
{
  char *ptr = strchr(str,'*');

@@ -398,7 +399,8 @@ void utils::bounds(const char *file, int line, char *str,
/* ----------------------------------------------------------------------
   compute bounds implied by numeric str with a possible wildcard asterisk
------------------------------------------------------------------------- */
void utils::boundsbig(const char *file, int line, char *str,
template <>
void utils::bounds(const char *file, int line, char *str,
                   bigint nmin, bigint nmax, bigint &nlo, bigint &nhi,
                   Error *error)
{
+2 −26
Original line number Diff line number Diff line
@@ -162,33 +162,9 @@ namespace LAMMPS_NS {
     * \param nlo      lower bound
     * \param nhi      upper bound
     * \param error    pointer to Error class for out-of-bounds messages */

    template <typename TYPE>
    void bounds(const char *file, int line, char *str,
                int nmin, int nmax, int &nlo, int &nhi, Error *error);

    /** Compute index bounds derived from a string with a possible wildcard
     *
     * This functions processes the string in *str* and set the values of *nlo*
     * and *nhi* according to the following five cases:
     *
     * - a single number, i: nlo = i; nhi = i;
     * - a single asterisk, \*: nlo = nmin; nhi = nmax;
     * - a single number followed by an asterisk, i\*: nlo = i; nhi = nmax;
     * - a single asterisk followed by a number, \*i: nlo = nmin; nhi = i;
     * - two numbers with an asterisk in between. i\*j: nlo = i; nhi = j;
     *
     * \param file     name of source file for error message
     * \param line     line number in source file for error message
     * \param str      string to be processed
     * \param nmin     smallest possible lower bound
     * \param nmax     largest allowed upper bound
     * \param nlo      lower bound
     * \param nhi      upper bound
     * \param error    pointer to Error class for out-of-bounds messages */

    void boundsbig(const char *file, int line, char *str,
                   bigint nmin, bigint nmax, bigint &nlo, bigint &nhi,
                   Error *error);
                bigint nmin, bigint nmax, TYPE &nlo, TYPE &nhi, Error *error);

    /** Expand list of arguments when containing fix/compute wildcards
     *