From 08555ac2f37b48d03dee307a8356a5c709b31efb Mon Sep 17 00:00:00 2001 From: jthorn Date: Wed, 27 Mar 2002 20:37:34 +0000 Subject: put *everything* into namespace jtutil:: start changing arrays to allow user-specified strides (only array2d so far) git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinAnalysis/AHFinderDirect/trunk@378 f88db872-0e4f-0410-b76b-b9085cfa78c5 --- src/jtutil/linear_map.cc | 52 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 16 deletions(-) (limited to 'src/jtutil/linear_map.cc') diff --git a/src/jtutil/linear_map.cc b/src/jtutil/linear_map.cc index 09928ce..5106949 100644 --- a/src/jtutil/linear_map.cc +++ b/src/jtutil/linear_map.cc @@ -1,11 +1,11 @@ // linear_map.cc -- linear mapping from integers <--> floating point values // $Id$ // -// linear_map::linear_map - basic constructor -// linear_map::linear_map - constructor for subrange of existing linear_map -// linear_map::fp_int_of_fp - convert fp --> int coord, return as fp -// linear_map::int_of_fp - convert fp --> int, check for being fuzzily integral -// linear_map::delta_int_of_delta_fp - ... same for spacings (delta_* values) +// jtutil::linear_map::linear_map - basic ctor +// jtutil::linear_map::linear_map - ctor for subrange of existing linear_map +// jtutil::linear_map::fp_int_of_fp - convert fp --> int coord, return as fp +// jtutil::linear_map::int_of_fp - convert fp --> int, check for ==fuzzy int +// jtutil::linear_map::delta_int_of_delta_fp - ... same for spacings // // ***** template instantiation ***** // @@ -26,6 +26,8 @@ using jtutil::error_exit; // // This function constructs a linear_map object. // +namespace jtutil + { template linear_map::linear_map(int min_int_in, int max_int_in, fp min_fp_in, fp delta_fp_in, fp max_fp_in) @@ -34,6 +36,7 @@ linear_map::linear_map(int min_int_in, int max_int_in, { constructor_common(min_fp_in, max_fp_in); } + } // namespace jtutil:: //****************************************************************************** @@ -41,6 +44,8 @@ constructor_common(min_fp_in, max_fp_in); // This function constructs a linear_map object with a subrange // of an existing one. // +namespace jtutil + { template linear_map::linear_map(const linear_map &lm_in, int min_int_in, int max_int_in) // subrange @@ -59,6 +64,7 @@ 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:: //****************************************************************************** @@ -66,6 +72,8 @@ 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:: . // +namespace jtutil + { template void linear_map::constructor_common(fp min_fp_in, fp max_fp_in) // assumes @@ -92,6 +100,7 @@ if (fuzzy::NE(fp_of_int_unchecked(max_int()), max_fp_in)) double(min_fp_in), double(delta_fp()), double(max_fp_in)); /*NOTREACHED*/ } + } // namespace jtutil:: //****************************************************************************** @@ -99,6 +108,8 @@ if (fuzzy::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 fp linear_map::fp_int_of_fp(fp x) const @@ -115,6 +126,7 @@ if (! is_in_range(x)) return inverse_delta_ * (x - offset_); } + } // namespace jtutil:: //****************************************************************************** @@ -124,9 +136,11 @@ return inverse_delta_ * (x - offset_); // result *isn't* fuzzily integral.) // // FIXME: -// Having to explicitly specify the global namespace for ::round:: +// Having to explicitly specify the namespace for jtutil::round:: // is ++ugly. :( // +namespace jtutil + { template int linear_map::int_of_fp(fp x, noninteger_action nia = error) const @@ -136,7 +150,7 @@ const fp fp_int = fp_int_of_fp(x); if (fuzzy::is_integer(fp_int)) then { // x is (fuzzily) a grid point ==> return that - return ::round::to_integer(fp_int); // *** EARLY RETURN *** + return jtutil::round::to_integer(fp_int); // *** EARLY RETURN *** } // get to here ==> x isn't (fuzzily) a grid point @@ -163,13 +177,13 @@ case warning: // fall through case round: - return ::round::to_integer(fp_int); // *** EARLY RETURN *** + return jtutil::round::to_integer(fp_int); // *** EARLY RETURN *** case floor: - return ::round::floor(fp_int); // *** EARLY RETURN *** + return jtutil::round::floor(fp_int); // *** EARLY RETURN *** case ceiling: - return ::round::ceiling(fp_int); // *** EARLY RETURN *** + return jtutil::round::ceiling(fp_int); // *** EARLY RETURN *** default: error_exit(PANIC_EXIT, @@ -181,6 +195,7 @@ default: return 0; // dummy return to quiet gcc // (which doesn't grok that error_exit() never returns) } + } // namespace jtutil:: //****************************************************************************** @@ -191,9 +206,11 @@ return 0; // dummy return to quiet gcc // do if the result *isn't* fuzzily integral.) // // FIXME: -// Having to explicitly specify the global namespace for ::round:: +// Having to explicitly specify the namespace for jtutil::round:: // is ++ugly. :( // +namespace jtutil + { template int linear_map::delta_int_of_delta_fp(fp delta_x, noninteger_action nia = error) @@ -205,7 +222,8 @@ if (fuzzy::is_integer(fp_delta_int)) then { // delta_x is (fuzzily) an integer number of grid spacings // ==> return that - return ::round::to_integer(fp_delta_int); // *** EARLY RETURN *** + return jtutil::round::to_integer(fp_delta_int); + // *** EARLY RETURN *** } // get to here ==> delta_x isn't (fuzzily) an integer number of grid spacings @@ -232,13 +250,14 @@ case warning: // fall through case round: - return ::round::to_integer(fp_delta_int); // *** EARLY RETURN *** + return jtutil::round::to_integer(fp_delta_int); + // *** EARLY RETURN *** case floor: - return ::round::floor(fp_delta_int); // *** EARLY RETURN *** + return jtutil::round::floor(fp_delta_int); // *** EARLY RETURN *** case ceiling: - return ::round::ceiling(fp_delta_int); // *** EARLY RETURN *** + return jtutil::round::ceiling(fp_delta_int);// *** EARLY RETURN *** default: error_exit(PANIC_EXIT, @@ -250,6 +269,7 @@ default: return 0; // dummy return to quiet gcc // (which doesn't grok that error_exit() never returns) } + } // namespace jtutil:: //****************************************************************************** //****************************************************************************** @@ -259,4 +279,4 @@ return 0; // dummy return to quiet gcc // ***** template instantiation ***** // -template class linear_map; +template class jtutil::linear_map; -- cgit v1.2.3