aboutsummaryrefslogtreecommitdiff
path: root/src/jtutil/linear_map.cc
diff options
context:
space:
mode:
authorjthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5>2002-03-27 20:37:34 +0000
committerjthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5>2002-03-27 20:37:34 +0000
commit08555ac2f37b48d03dee307a8356a5c709b31efb (patch)
tree8654b81418c6a377387061be8ea6ad8e7c272c9c /src/jtutil/linear_map.cc
parent9aa4aeea088defb0049d20d49cb25838c9ee5a8a (diff)
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
Diffstat (limited to 'src/jtutil/linear_map.cc')
-rw-r--r--src/jtutil/linear_map.cc52
1 files changed, 36 insertions, 16 deletions
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<fp> object.
//
+namespace jtutil
+ {
template <typename fp>
linear_map<fp>::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<fp>::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<fp> object with a subrange
// of an existing one.
//
+namespace jtutil
+ {
template <typename fp>
linear_map<fp>::linear_map(const linear_map<fp> &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<fp>:: .
//
+namespace jtutil
+ {
template <typename fp>
void linear_map<fp>::constructor_common(fp min_fp_in, fp max_fp_in)
// assumes
@@ -92,6 +100,7 @@ if (fuzzy<fp>::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<fp>::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>
fp linear_map<fp>::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<fp>::
+// Having to explicitly specify the namespace for jtutil::round<fp>::
// is ++ugly. :(
//
+namespace jtutil
+ {
template <typename fp>
int linear_map<fp>::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<fp>::is_integer(fp_int))
then {
// x is (fuzzily) a grid point ==> return that
- return ::round<fp>::to_integer(fp_int); // *** EARLY RETURN ***
+ return jtutil::round<fp>::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<fp>::to_integer(fp_int); // *** EARLY RETURN ***
+ return jtutil::round<fp>::to_integer(fp_int); // *** EARLY RETURN ***
case floor:
- return ::round<fp>::floor(fp_int); // *** EARLY RETURN ***
+ return jtutil::round<fp>::floor(fp_int); // *** EARLY RETURN ***
case ceiling:
- return ::round<fp>::ceiling(fp_int); // *** EARLY RETURN ***
+ return jtutil::round<fp>::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<fp>::
+// Having to explicitly specify the namespace for jtutil::round<fp>::
// is ++ugly. :(
//
+namespace jtutil
+ {
template <typename fp>
int linear_map<fp>::delta_int_of_delta_fp(fp delta_x,
noninteger_action nia = error)
@@ -205,7 +222,8 @@ if (fuzzy<fp>::is_integer(fp_delta_int))
then {
// delta_x is (fuzzily) an integer number of grid spacings
// ==> return that
- return ::round<fp>::to_integer(fp_delta_int); // *** EARLY RETURN ***
+ return jtutil::round<fp>::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<fp>::to_integer(fp_delta_int); // *** EARLY RETURN ***
+ return jtutil::round<fp>::to_integer(fp_delta_int);
+ // *** EARLY RETURN ***
case floor:
- return ::round<fp>::floor(fp_delta_int); // *** EARLY RETURN ***
+ return jtutil::round<fp>::floor(fp_delta_int); // *** EARLY RETURN ***
case ceiling:
- return ::round<fp>::ceiling(fp_delta_int); // *** EARLY RETURN ***
+ return jtutil::round<fp>::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<double>;
+template class jtutil::linear_map<double>;