diff options
author | jthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5> | 2005-02-01 14:58:53 +0000 |
---|---|---|
committer | jthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5> | 2005-02-01 14:58:53 +0000 |
commit | cb95431b072f5519a083a59e878255c5bcab64d1 (patch) | |
tree | d36d7e7ee32fc44b5d288f244ae16ad086071fb5 /src/jtutil | |
parent | 0026d529a6a0ccd030d9510858726bcd3e1e0d24 (diff) |
fix a C++ namespaces bug found by Erik:
error_exit() was declared extern "C"
--> it wasn't namespace-mangled
--> it could conflict with a similar error_exit() in another thorn
although this fix touches a *lot* of files, it's conceptually simple:
* error_exit() is not extern "C" any more
* everything in src/jtutil/ (which used to be in the jtutil:: namespace)
is now in the AHFinderDirect::jtutil:: namespace
--> all C++ code in this thorn is now inside the AHFinderDirect:: namespace
git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinAnalysis/AHFinderDirect/trunk@1395 f88db872-0e4f-0410-b76b-b9085cfa78c5
Diffstat (limited to 'src/jtutil')
-rw-r--r-- | src/jtutil/README | 6 | ||||
-rw-r--r-- | src/jtutil/array.cc | 67 | ||||
-rw-r--r-- | src/jtutil/array.hh | 21 | ||||
-rw-r--r-- | src/jtutil/cpm_map.cc | 27 | ||||
-rw-r--r-- | src/jtutil/cpm_map.hh | 12 | ||||
-rw-r--r-- | src/jtutil/error_exit.cc | 15 | ||||
-rw-r--r-- | src/jtutil/fuzzy.cc | 33 | ||||
-rw-r--r-- | src/jtutil/linear_map.cc | 36 | ||||
-rw-r--r-- | src/jtutil/linear_map.hh | 12 | ||||
-rw-r--r-- | src/jtutil/miscfp.cc | 39 | ||||
-rw-r--r-- | src/jtutil/norm.cc | 25 | ||||
-rw-r--r-- | src/jtutil/round.cc | 26 | ||||
-rw-r--r-- | src/jtutil/test_array.cc | 2 | ||||
-rw-r--r-- | src/jtutil/test_array2.cc | 2 | ||||
-rw-r--r-- | src/jtutil/test_cpm_map.cc | 3 | ||||
-rw-r--r-- | src/jtutil/test_error_exit.cc | 2 | ||||
-rw-r--r-- | src/jtutil/test_fuzzy.cc | 3 | ||||
-rw-r--r-- | src/jtutil/test_linear_map.cc | 3 | ||||
-rw-r--r-- | src/jtutil/test_modulo.cc | 3 | ||||
-rw-r--r-- | src/jtutil/test_norm.cc | 3 | ||||
-rw-r--r-- | src/jtutil/test_round.cc | 2 | ||||
-rw-r--r-- | src/jtutil/util.hh | 6 |
22 files changed, 189 insertions, 159 deletions
diff --git a/src/jtutil/README b/src/jtutil/README index 1b6ea5e..31ac7aa 100644 --- a/src/jtutil/README +++ b/src/jtutil/README @@ -1,6 +1,8 @@ This directory holds low-level utility code in the C++ namespace jtutil::. -This code is not specific to this project -- it's things like min/max -templates, multidimensional array classes, fuzzy arithmetic routines, etc. +Apart from this namespace being inside this thorn's global AHFinderDirect:: +namespace, this code isn't specific to this project -- it's things like +min/max templates, multidimensional array classes, fuzzy arithmetic +routines, etc. array<fp> is a template class (templated on the integer or floating-point diff --git a/src/jtutil/array.cc b/src/jtutil/array.cc index b6fbc99..c8e5c47 100644 --- a/src/jtutil/array.cc +++ b/src/jtutil/array.cc @@ -33,6 +33,12 @@ #include "util.hh" #include "array.hh" +// everything in this file is inside these namespaces +namespace AHFinderDirect + { +namespace jtutil + { + //****************************************************************************** //****************************************************************************** //****************************************************************************** @@ -40,8 +46,6 @@ // // This function constructs an array1d object. // -namespace jtutil - { template <typename T> array1d<T>::array1d(int min_i_in, int max_i_in, T *array_in /* = NULL */, @@ -73,22 +77,18 @@ if (we_own_array_) operator()(i) = T(0); } } - } // namespace jtutil:: //****************************************************************************** // // This function destroys an array1d object. // -namespace jtutil - { template <typename T> array1d<T>::~array1d() { if (we_own_array_) then delete[] array_; } - } // namespace jtutil:: //****************************************************************************** //****************************************************************************** @@ -97,8 +97,6 @@ if (we_own_array_) // // This function constructs an array2d object. // -namespace jtutil - { template <typename T> array2d<T>::array2d(int min_i_in, int max_i_in, int min_j_in, int max_j_in, @@ -137,22 +135,18 @@ if (we_own_array_) } } } - } // namespace jtutil:: //****************************************************************************** // // This function destroys an array2d object. // -namespace jtutil - { template <typename T> array2d<T>::~array2d() { if (we_own_array_) then delete[] array_; } - } // namespace jtutil:: //****************************************************************************** //****************************************************************************** @@ -161,8 +155,6 @@ if (we_own_array_) // // This function constructs an array3d object. // -namespace jtutil - { template <typename T> array3d<T>::array3d(int min_i_in, int max_i_in, int min_j_in, int max_j_in, @@ -210,22 +202,18 @@ if (we_own_array_) } } } - } // namespace jtutil:: //****************************************************************************** // // This function destroys an array3d object. // -namespace jtutil - { template <typename T> array3d<T>::~array3d() { if (we_own_array_) then delete[] array_; } - } // namespace jtutil:: //****************************************************************************** //****************************************************************************** @@ -235,8 +223,6 @@ if (we_own_array_) // // This function constructs an array4d object. // -namespace jtutil - { template <typename T> array4d<T>::array4d(int min_i_in, int max_i_in, int min_j_in, int max_j_in, @@ -292,7 +278,6 @@ if (we_own_array_) } } } - } // namespace jtutil:: #endif /* NOT_USED */ //****************************************************************************** @@ -301,15 +286,12 @@ if (we_own_array_) // // This function destroys an array4d object. // -namespace jtutil - { template <typename T> array4d<T>::~array4d() { if (we_own_array_) then delete[] array_; } - } // namespace jtutil:: #endif /* NOT_USED */ //****************************************************************************** @@ -320,33 +302,40 @@ if (we_own_array_) // ***** template instantiations ***** // -template class jtutil::array1d<int>; +template class array1d<int>; // FIXME: we shouldn't have to instantiate these both, the const one // is actually trivially derivable from the non-const one. :( -template class jtutil::array1d< void *>; -template class jtutil::array1d<const void *>; +template class array1d< void *>; +template class array1d<const void *>; #ifdef STANDALONE_TEST - template class jtutil::array1d<float>; - template class jtutil::array2d<float>; - template class jtutil::array3d<float>; + template class array1d<float>; + template class array2d<float>; + template class array3d<float>; #ifdef NOT_USED - template class jtutil::array4d<float>; + template class array4d<float>; #endif - template class jtutil::array1d<double>; - template class jtutil::array2d<double>; - template class jtutil::array3d<double>; + template class array1d<double>; + template class array2d<double>; + template class array3d<double>; #ifdef NOT_USED - template class jtutil::array4d<double>; + template class array4d<double>; #endif #else // full-fledged Cactus thorn - template class jtutil::array1d<CCTK_REAL>; + template class array1d<CCTK_REAL>; - template class jtutil::array2d<CCTK_INT>; - template class jtutil::array2d<CCTK_REAL>; + template class array2d<CCTK_INT>; + template class array2d<CCTK_REAL>; - template class jtutil::array3d<CCTK_REAL>; + template class array3d<CCTK_REAL>; #endif + +//****************************************************************************** +//****************************************************************************** +//****************************************************************************** + + } // namespace jtutil + } // namespace AHFinderDirect diff --git a/src/jtutil/array.hh b/src/jtutil/array.hh index bf70628..96bb87a 100644 --- a/src/jtutil/array.hh +++ b/src/jtutil/array.hh @@ -62,10 +62,14 @@ // #endif -//****************************************************************************** - +// everything in this file is inside these namespaces +namespace AHFinderDirect + { namespace jtutil { + +//****************************************************************************** + template <typename T> class array1d { @@ -146,12 +150,9 @@ private: bool we_own_array_; // true ==> array_ --> new[] array which we own // false ==> array_ --> client-owned storage }; - } // namespace jtutil:: //****************************************************************************** -namespace jtutil - { template <typename T> class array2d { @@ -243,12 +244,9 @@ private: bool we_own_array_; // true ==> array_ --> new[] array which we own // false ==> array_ --> client-owned storage }; - } // namespace jtutil:: //****************************************************************************** -namespace jtutil - { template <typename T> class array3d { @@ -348,13 +346,10 @@ private: bool we_own_array_; // true ==> array_ --> new[] array which we own // false ==> array_ --> client-owned storage }; - } // namespace jtutil:: //****************************************************************************** #ifdef NOT_USED -namespace jtutil - { template <typename T> class array4d { @@ -469,9 +464,11 @@ private: bool we_own_array_; // true ==> array_ --> new[] array which we own // false ==> array_ --> client-owned storage }; - } // namespace jtutil:: #endif /* NOT_USED */ //****************************************************************************** + }; // namespace jtutil + }; // namespace AHFinderDirect + #endif /* AHFINDERDIRECT__ARRAY_HH */ diff --git a/src/jtutil/cpm_map.cc b/src/jtutil/cpm_map.cc index 09ab35a..1a44b20 100644 --- a/src/jtutil/cpm_map.cc +++ b/src/jtutil/cpm_map.cc @@ -14,7 +14,12 @@ #include "stdc.h" #include "util.hh" #include "cpm_map.hh" -using jtutil::error_exit; + +// everything in this file is inside these namespaces +namespace AHFinderDirect + { +namespace jtutil + { //****************************************************************************** //****************************************************************************** @@ -25,8 +30,6 @@ using jtutil::error_exit; // specified fixed point (must be integer or half-integer) and domain. // The sample point need not be in the map's domain/range. // -namespace jtutil - { template <typename fp_t> cpm_map<fp_t>::cpm_map(int min_i_in, int max_i_in, fp_t fixed_point) @@ -50,7 +53,6 @@ assert( fuzzy<fp_t>::ceiling(fixed_point) ); } - } // namespace jtutil:: //****************************************************************************** @@ -59,8 +61,6 @@ assert( // specified by a sample point sample_i --> sample_j and by sign. // The sample point need not be in the map's domain/range. // -namespace jtutil - { template <typename fp_t> cpm_map<fp_t>::cpm_map(int min_i_in, int max_i_in, int sample_i, int sample_j, @@ -73,7 +73,6 @@ cpm_map<fp_t>::cpm_map(int min_i_in, int max_i_in, // verify that we have setup correct assert( map_unchecked(sample_i) == sample_j ); } - } // namespace jtutil:: //****************************************************************************** @@ -85,8 +84,6 @@ assert( map_unchecked(sample_i) == sample_j ); // is never ok) and by sign. The sample point need not be in the map's // domain/range. // -namespace jtutil - { template <typename fp_t> cpm_map<fp_t>::cpm_map(int min_i_in, int max_i_in, fp_t sample_i, fp_t sample_j, @@ -115,7 +112,6 @@ assert( (map_is_plus_in ? fuzzy<fp_t>::floor (sample_j) : fuzzy<fp_t>::ceiling(sample_j)) ); } - } // namespace jtutil:: //****************************************************************************** //****************************************************************************** @@ -125,5 +121,12 @@ assert( // ***** template instantiations ***** // -template class jtutil::cpm_map<float>; -template class jtutil::cpm_map<double>; +template class cpm_map<float>; +template class cpm_map<double>; + +//****************************************************************************** +//****************************************************************************** +//****************************************************************************** + + } // namespace jtutil + } // namespace AHFinderDirect diff --git a/src/jtutil/cpm_map.hh b/src/jtutil/cpm_map.hh index 6b14ab3..4672b4e 100644 --- a/src/jtutil/cpm_map.hh +++ b/src/jtutil/cpm_map.hh @@ -25,10 +25,14 @@ // #endif -//****************************************************************************** - +// everything in this file is inside these namespaces +namespace AHFinderDirect + { namespace jtutil { + +//****************************************************************************** + template <typename fp_t> class cpm_map { @@ -132,8 +136,10 @@ private: int offset_; bool map_is_plus_; }; - } // namespace jtutil:: //****************************************************************************** + }; // namespace jtutil + }; // namespace AHFinderDirect + #endif /* AHFINDERDIRECT__CPM_MAP_HH */ diff --git a/src/jtutil/error_exit.cc b/src/jtutil/error_exit.cc index 956ae08..ffffa1e 100644 --- a/src/jtutil/error_exit.cc +++ b/src/jtutil/error_exit.cc @@ -18,6 +18,12 @@ #include "config.h" #include "stdc.h" +// everything in this file is inside these namespaces +namespace AHFinderDirect + { +namespace jtutil + { + //****************************************************************************** // @@ -48,9 +54,6 @@ // args... = (in) Any additional arguments are (presumably) used in formatting // the error message string. // -namespace jtutil - { -extern "C" /*VARARGS*/ int error_exit(int msg_level, const char *format, ...) { @@ -81,4 +84,8 @@ if ((len > 0) && (buffer[len-1] == '\n')) // if we got here, evidently msg_level wasn't drastic enough abort(); /*NOTREACHED*/ } - } // namespace jtutil:: + +//****************************************************************************** + + } // namespace jtutil + } // namespace AHFinderDirect diff --git a/src/jtutil/fuzzy.cc b/src/jtutil/fuzzy.cc index d3e4314..e444c30 100644 --- a/src/jtutil/fuzzy.cc +++ b/src/jtutil/fuzzy.cc @@ -11,40 +11,39 @@ // #include <stdlib.h> +#include <stdio.h> #include "stdc.h" #include "util.hh" -//****************************************************************************** - +// everything in this file is inside these namespaces +namespace AHFinderDirect + { namespace jtutil { + +//****************************************************************************** + template <typename fp_t> bool fuzzy<fp_t>::EQ(fp_t x, fp_t y) { -fp_t max_abs = jtutil::max(jtutil::abs(x), jtutil::abs(y)); -fp_t epsilon = jtutil::max(tolerance_, tolerance_*max_abs); +fp_t max_abs = max(jtutil::abs(x), jtutil::abs(y)); +fp_t epsilon = max(tolerance_, tolerance_*max_abs); return jtutil::abs(x-y) <= epsilon; } - } // namespace jtutil:: //****************************************************************************** -namespace jtutil - { template <typename fp_t> bool fuzzy<fp_t>::is_integer(fp_t x) { int i = round<fp_t>::to_integer(x); return EQ(x, fp_t(i)); } - } // namespace jtutil:: //****************************************************************************** -namespace jtutil - { template <typename fp_t> int fuzzy<fp_t>::floor(fp_t x) { @@ -52,12 +51,9 @@ return fuzzy<fp_t>::is_integer(x) ? round<fp_t>::to_integer(x) : round<fp_t>::floor(x); } - } // namespace jtutil:: //****************************************************************************** -namespace jtutil - { template <typename fp_t> int fuzzy<fp_t>::ceiling(fp_t x) { @@ -65,7 +61,6 @@ return fuzzy<fp_t>::is_integer(x) ? round<fp_t>::to_integer(x) : round<fp_t>::ceiling(x); } - } // namespace jtutil:: //****************************************************************************** //****************************************************************************** @@ -80,8 +75,6 @@ return fuzzy<fp_t>::is_integer(x) // me figure out the correct syntax here! // -namespace jtutil - { // initializations of fuzzy::tolerance for each instantation we're going to make template <> float fuzzy<float>::tolerance_ = 1.0e-5; // about 100 * FLT_EPSILON @@ -92,4 +85,10 @@ template <> // template instantiations template class fuzzy<float>; template class fuzzy<double>; - } // namespace jtutil:: + +//****************************************************************************** +//****************************************************************************** +//****************************************************************************** + + } // namespace jtutil + } // namespace AHFinderDirect diff --git a/src/jtutil/linear_map.cc b/src/jtutil/linear_map.cc index 636675e..b44b466 100644 --- a/src/jtutil/linear_map.cc +++ b/src/jtutil/linear_map.cc @@ -16,7 +16,12 @@ #include "stdc.h" #include "util.hh" #include "linear_map.hh" -using jtutil::error_exit; + +// everything in this file is inside these namespaces +namespace AHFinderDirect + { +namespace jtutil + { //****************************************************************************** //****************************************************************************** @@ -27,8 +32,6 @@ using jtutil::error_exit; // // This function constructs a linear_map<fp_t> object. // -namespace jtutil - { template <typename fp_t> linear_map<fp_t>::linear_map(int min_int_in, int max_int_in, fp_t min_fp_in, fp_t delta_fp_in, fp_t max_fp_in) @@ -37,7 +40,6 @@ linear_map<fp_t>::linear_map(int min_int_in, int max_int_in, { constructor_common(min_fp_in, max_fp_in); } - } // namespace jtutil:: //****************************************************************************** @@ -45,8 +47,6 @@ constructor_common(min_fp_in, max_fp_in); // This function constructs a linear_map<fp_t> object with a subrange // of an existing one. // -namespace jtutil - { template <typename fp_t> linear_map<fp_t>::linear_map(const linear_map<fp_t> &lm_in, int min_int_in, int max_int_in) // subrange @@ -65,7 +65,6 @@ if (! (is_in_range(min_int_in) && is_in_range(max_int_in)) ) constructor_common(lm_in.fp_of_int_unchecked(min_int_in), lm_in.fp_of_int_unchecked(max_int_in)); } - } // namespace jtutil:: //****************************************************************************** @@ -73,8 +72,6 @@ constructor_common(lm_in.fp_of_int_unchecked(min_int_in), // This function does the common argument validation and setup for // all the constructors of class linear_map<fp_t>:: . // -namespace jtutil - { template <typename fp_t> void linear_map<fp_t>::constructor_common(fp_t min_fp_in, fp_t max_fp_in) // assumes @@ -101,7 +98,6 @@ if (fuzzy<fp_t>::NE(fp_of_int_unchecked(max_int()), max_fp_in)) double(min_fp_in), double(delta_fp()), double(max_fp_in)); /*NOTREACHED*/ } - } // namespace jtutil:: //****************************************************************************** @@ -109,8 +105,6 @@ if (fuzzy<fp_t>::NE(fp_of_int_unchecked(max_int()), max_fp_in)) // This function converts fp --> int coordinate, returning the result // as an fp (which need not be fuzzily integral). // -namespace jtutil - { template <typename fp_t> fp_t linear_map<fp_t>::fp_int_of_fp(fp_t x) const @@ -127,7 +121,6 @@ if (! is_in_range(x)) return inverse_delta_ * (x - origin_); } - } // namespace jtutil:: //****************************************************************************** @@ -140,8 +133,6 @@ return inverse_delta_ * (x - origin_); // Having to explicitly specify the namespace for jtutil::round<fp_t>:: // is ++ugly. :( // -namespace jtutil - { template <typename fp_t> int linear_map<fp_t>::int_of_fp(fp_t x, noninteger_action nia /* = nia_error */) const @@ -196,7 +187,6 @@ default: return 0; // dummy return to quiet gcc // (which doesn't grok that error_exit() never returns) } - } // namespace jtutil:: //****************************************************************************** @@ -210,8 +200,6 @@ return 0; // dummy return to quiet gcc // Having to explicitly specify the namespace for jtutil::round<fp_t>:: // is ++ugly. :( // -namespace jtutil - { template <typename fp_t> int linear_map<fp_t>::delta_int_of_delta_fp (fp_t delta_x, noninteger_action nia /* = nia_error */) @@ -271,7 +259,6 @@ default: return 0; // dummy return to quiet gcc // (which doesn't grok that error_exit() never returns) } - } // namespace jtutil:: //****************************************************************************** //****************************************************************************** @@ -281,5 +268,12 @@ return 0; // dummy return to quiet gcc // ***** template instantiation ***** // -template class jtutil::linear_map<float>; -template class jtutil::linear_map<double>; +template class linear_map<float>; +template class linear_map<double>; + +//****************************************************************************** +//****************************************************************************** +//****************************************************************************** + + } // namespace jtutil + } // namespace AHFinderDirect diff --git a/src/jtutil/linear_map.hh b/src/jtutil/linear_map.hh index 48c0f2d..2417176 100644 --- a/src/jtutil/linear_map.hh +++ b/src/jtutil/linear_map.hh @@ -26,10 +26,14 @@ // #endif -//***************************************************************************** - +// everything in this file is inside these namespaces +namespace AHFinderDirect + { namespace jtutil { + +//***************************************************************************** + template <typename fp_t> class linear_map { @@ -139,8 +143,10 @@ private: // bounds (inclusive) const int min_int_, max_int_; }; - } // namespace jtutil:: //****************************************************************************** + }; // namespace jtutil + }; // namespace AHFinderDirect + #endif /* AHFINDERDIRECT__LINEAR_MAP_HH */ diff --git a/src/jtutil/miscfp.cc b/src/jtutil/miscfp.cc index 87a0272..519f7e0 100644 --- a/src/jtutil/miscfp.cc +++ b/src/jtutil/miscfp.cc @@ -23,6 +23,12 @@ #include "stdc.h" #include "util.hh" +// everything in this file is inside these namespaces +namespace AHFinderDirect + { +namespace jtutil + { + //****************************************************************************** //****************************************************************************** //****************************************************************************** @@ -31,15 +37,12 @@ // This function computes the floating point "signum" function (as in APL), // signum(x) = -1.0, 0.0, or +1.0, according to the sign of x. // -namespace jtutil - { double signum(double x) { if (x == 0.0) then return 0.0; else return (x > 0.0) ? 1.0 : -1.0; } - } // namespace jtutil:: //****************************************************************************** @@ -58,13 +61,10 @@ if (x == 0.0) // unwarranted IEEE exceptions if any of |x|, |y|, or |z| is close to // the overflow and/or underflow threshold. // -namespace jtutil - { double hypot3(double x, double y, double z) { return sqrt(x*x + y*y + z*z); } - } // namespace jtutil:: //****************************************************************************** @@ -81,14 +81,11 @@ return sqrt(x*x + y*y + z*z); // some real $R$, i.e. it returns the angle between the positive $x$ axis and // the line joining the origin and the point $(x,y)$. // -namespace jtutil - { double arctan_xy(double x, double y) { // note reversed argument order (y,x) in std::atan2() function return ((x == 0.0) && (y == 0.0)) ? 0.0 : atan2(y,x); } - } // namespace jtutil:: //****************************************************************************** @@ -96,8 +93,6 @@ return ((x == 0.0) && (y == 0.0)) ? 0.0 : atan2(y,x); // This function reduces x modulo xmod to be (fuzzily) in the range // [xmin, xmax] , or does an error_exit() if no such value exists. // -namespace jtutil - { double modulo_reduce(double x, double xmod, double xmin, double xmax) { double xx = x; @@ -113,27 +108,24 @@ double xx = x; } if (! (fuzzy<double>::GE(xx, xmin) && fuzzy<double>::LE(xx, xmax)) ) - then jtutil::error_exit(ERROR_EXIT, + then error_exit(ERROR_EXIT, "***** modulo_reduce(): no modulo value is fuzzily within specified range!\n" " x = %g xmod = %g\n" " [xmin,xmax] = [%g,%g]\n" " ==> xx = %g\n" , - x, xmod, - xmin, xmax, - xx); /*NOTREACHED*/ + x, xmod, + xmin, xmax, + xx); /*NOTREACHED*/ return xx; } - } // namespace jtutil:: //****************************************************************************** // // This function sets a C-style array to all zeros. // -namespace jtutil - { template <typename fp_t> void zero_C_array(int N, fp_t array[]) { @@ -142,7 +134,6 @@ template <typename fp_t> array[i] = 0; } } - } // namespace jtutil:: //****************************************************************************** //****************************************************************************** @@ -152,7 +143,11 @@ template <typename fp_t> // ***** template instantiations ***** // -namespace jtutil - { template void zero_C_array<CCTK_REAL>(int, CCTK_REAL[]); - } // namespace jtutil:: + +//****************************************************************************** +//****************************************************************************** +//****************************************************************************** + + } // namespace jtutil + } // namespace AHFinderDirect diff --git a/src/jtutil/norm.cc b/src/jtutil/norm.cc index 283beb3..5c9b699 100644 --- a/src/jtutil/norm.cc +++ b/src/jtutil/norm.cc @@ -16,6 +16,12 @@ #include "util.hh" +// everything in this file is inside these namespaces +namespace AHFinderDirect + { +namespace jtutil + { + //***************************************************************************** //***************************************************************************** //***************************************************************************** @@ -23,8 +29,6 @@ // // This function constructs a norm object. // -namespace jtutil - { template <typename fp_t> norm<fp_t>::norm() : N_(0L), @@ -32,15 +36,12 @@ template <typename fp_t> max_abs_value_(0.0), min_abs_value_(0.0), max_value_(0.0), min_value_(0.0) { } - } //***************************************************************************** // // This function resets a norm object to its initial state // -namespace jtutil - { template <typename fp_t> void norm<fp_t>::reset() { @@ -52,15 +53,12 @@ min_abs_value_ = 0.0; max_value_ = 0.0; min_value_ = 0.0; } - } //***************************************************************************** // // This function updates the norms with a new data point x . // -namespace jtutil - { template <typename fp_t> void norm<fp_t>::data(fp_t x) { @@ -76,15 +74,12 @@ max_value_ = (N_ == 0) ? x : jtutil::max(max_value_, x); ++N_; } - } // namespace jtutil:: //****************************************************************************** // // these functions compute the corresponding norms // -namespace jtutil - { template<typename fp_t> fp_t norm<fp_t>::mean() const { return sum_/fp_t(N_); } template<typename fp_t> @@ -92,7 +87,6 @@ template<typename fp_t> template<typename fp_t> fp_t norm<fp_t>::rms_norm() const { assert(is_nonempty()); return sqrt(sum2_/fp_t(N_)); } - } // namespace jtutil:: //****************************************************************************** //****************************************************************************** @@ -104,3 +98,10 @@ template<typename fp_t> template class jtutil::norm<float>; template class jtutil::norm<double>; + +//****************************************************************************** +//****************************************************************************** +//****************************************************************************** + + } // namespace jtutil + } // namespace AHFinderDirect diff --git a/src/jtutil/round.cc b/src/jtutil/round.cc index 6559944..3c2d7e6 100644 --- a/src/jtutil/round.cc +++ b/src/jtutil/round.cc @@ -14,6 +14,12 @@ #include "stdc.h" #include "util.hh" +// everything in this file is inside these namespaces +namespace AHFinderDirect + { +namespace jtutil + { + //****************************************************************************** //****************************************************************************** //****************************************************************************** @@ -29,8 +35,6 @@ //****************************************************************************** // round to nearest integer, up for exact tie -namespace jtutil - { template <typename fp_t> int round<fp_t>::to_integer(fp_t x) { @@ -38,12 +42,9 @@ return (x >= 0.0) ? int(x + 0.5) // eg 3.6 --> int(4.1) = 4 : - int( (-x) + 0.5 ); // eg -3.6 --> - int(4.1) = -4 } - } // namespace jtutil:: //****************************************************************************** -namespace jtutil - { template <typename fp_t> int round<fp_t>::floor(fp_t x) { @@ -51,12 +52,9 @@ return (x >= 0.0) ? int(x) : - ceiling(-x); } - } // namespace jtutil:: //****************************************************************************** -namespace jtutil - { template <typename fp_t> int round<fp_t>::ceiling(fp_t x) { @@ -64,7 +62,6 @@ return (x >= 0.0) ? int(x) + (x != fp_t(int(x))) : - floor(-x); } - } // namespace jtutil:: //****************************************************************************** //****************************************************************************** @@ -74,5 +71,12 @@ return (x >= 0.0) // ***** template instantiations ***** // -template class jtutil::round<float>; -template class jtutil::round<double>; +template class round<float>; +template class round<double>; + +//****************************************************************************** +//****************************************************************************** +//****************************************************************************** + + } // namespace jtutil + } // namespace AHFinderDirect diff --git a/src/jtutil/test_array.cc b/src/jtutil/test_array.cc index 56c2a0c..2b413c4 100644 --- a/src/jtutil/test_array.cc +++ b/src/jtutil/test_array.cc @@ -9,6 +9,8 @@ #include "util.hh" #include "array.hh" +using namespace AHFinderDirect; + using jtutil::fuzzy; using jtutil::array1d; using jtutil::array2d; diff --git a/src/jtutil/test_array2.cc b/src/jtutil/test_array2.cc index 9015cbd..c89e209 100644 --- a/src/jtutil/test_array2.cc +++ b/src/jtutil/test_array2.cc @@ -9,6 +9,8 @@ #include "util.hh" #include "array.hh" +using namespace AHFinderDirect; + void print( jtutil::array2d<double>& Aref); void cprint(const jtutil::array2d<double>& Aref); diff --git a/src/jtutil/test_cpm_map.cc b/src/jtutil/test_cpm_map.cc index 070321a..cdb5c7c 100644 --- a/src/jtutil/test_cpm_map.cc +++ b/src/jtutil/test_cpm_map.cc @@ -7,6 +7,9 @@ #include "stdc.h" #include "util.hh" #include "cpm_map.hh" + +using namespace AHFinderDirect; + using jtutil::cpm_map; //****************************************************************************** diff --git a/src/jtutil/test_error_exit.cc b/src/jtutil/test_error_exit.cc index a1b568e..fd4e170 100644 --- a/src/jtutil/test_error_exit.cc +++ b/src/jtutil/test_error_exit.cc @@ -4,6 +4,8 @@ #include <stdio.h> #include "stdc.h" + +using namespace AHFinderDirect; using jtutil::error_exit; int main() diff --git a/src/jtutil/test_fuzzy.cc b/src/jtutil/test_fuzzy.cc index 437df36..3566f61 100644 --- a/src/jtutil/test_fuzzy.cc +++ b/src/jtutil/test_fuzzy.cc @@ -12,6 +12,9 @@ #include "stdc.h" #include "util.hh" + +using namespace AHFinderDirect; + using jtutil::error_exit; using jtutil::fuzzy; diff --git a/src/jtutil/test_linear_map.cc b/src/jtutil/test_linear_map.cc index f38d362..29b8974 100644 --- a/src/jtutil/test_linear_map.cc +++ b/src/jtutil/test_linear_map.cc @@ -7,6 +7,9 @@ #include "stdc.h" #include "util.hh" #include "linear_map.hh" + +using namespace AHFinderDirect; + using jtutil::fuzzy; using jtutil::linear_map; diff --git a/src/jtutil/test_modulo.cc b/src/jtutil/test_modulo.cc index c587ea6..a32ba2b 100644 --- a/src/jtutil/test_modulo.cc +++ b/src/jtutil/test_modulo.cc @@ -6,6 +6,9 @@ #include "stdc.h" #include "util.hh" + +using namespace AHFinderDirect; + using jtutil::error_exit; using jtutil::fuzzy; diff --git a/src/jtutil/test_norm.cc b/src/jtutil/test_norm.cc index f9c8d47..6eec312 100644 --- a/src/jtutil/test_norm.cc +++ b/src/jtutil/test_norm.cc @@ -7,6 +7,9 @@ #include "stdc.h" #include "util.hh" + +using namespace AHFinderDirect; + using jtutil::norm; using jtutil::fuzzy; diff --git a/src/jtutil/test_round.cc b/src/jtutil/test_round.cc index 5e3354a..dc90584 100644 --- a/src/jtutil/test_round.cc +++ b/src/jtutil/test_round.cc @@ -6,6 +6,8 @@ #include "stdc.h" #include "util.hh" + +using namespace AHFinderDirect; using jtutil::round; // diff --git a/src/jtutil/util.hh b/src/jtutil/util.hh index 35f1fcc..14b0ce5 100644 --- a/src/jtutil/util.hh +++ b/src/jtutil/util.hh @@ -9,6 +9,9 @@ // "stdc.h" // +// everything in this file is inside these namespaces +namespace AHFinderDirect + { namespace jtutil { @@ -207,6 +210,7 @@ public: //****************************************************************************** - } // namespace jtutil + }; // namespace jtutil + }; // namespace AHFinderDirect #endif /* AHFINDERDIRECT__UTIL_HH */ |