aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5>2002-04-10 14:03:04 +0000
committerjthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5>2002-04-10 14:03:04 +0000
commit33321b57b889dee2c308474e87b8f6cd384782dd (patch)
treebda89798c5ed976bd3a7f331139b031624881830 /src
parentca8170fae34fbc42f75075f6060718e0432dfd98 (diff)
change from jtutil::min/max --> std::, also add missing std:: in some files
git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinAnalysis/AHFinderDirect/trunk@481 f88db872-0e4f-0410-b76b-b9085cfa78c5
Diffstat (limited to 'src')
-rw-r--r--src/jtutil/fuzzy.cc7
-rw-r--r--src/jtutil/makefile18
-rw-r--r--src/jtutil/norm.cc10
-rw-r--r--src/jtutil/util.hh15
4 files changed, 23 insertions, 27 deletions
diff --git a/src/jtutil/fuzzy.cc b/src/jtutil/fuzzy.cc
index 80f9adb..d71a873 100644
--- a/src/jtutil/fuzzy.cc
+++ b/src/jtutil/fuzzy.cc
@@ -10,6 +10,7 @@
// ***** template instantiations *****
//
+#include <algorithm>
#include "jt/stdc.h"
#include "jt/util.hh"
@@ -20,10 +21,10 @@ namespace jtutil
template <typename fp>
bool fuzzy<fp>::EQ(fp x, fp y)
{
-fp max_abs = jtutil::max(jtutil::abs(x), jtutil::abs(y));
-fp epsilon = jtutil::max(tolerance, tolerance*max_abs);
+fp max_abs = std::max(jtutil::abs(x), jtutil::abs(y));
+fp epsilon = std::max(tolerance, tolerance*max_abs);
-return jtutil::abs<fp>(x-y) <= epsilon;
+return jtutil::abs(x-y) <= epsilon;
}
} // namespace jtutil::
diff --git a/src/jtutil/makefile b/src/jtutil/makefile
index 6d62512..0669ac4 100644
--- a/src/jtutil/makefile
+++ b/src/jtutil/makefile
@@ -1,5 +1,5 @@
# Makefile for standalone test drivers in this directory
-# $Id: makefile,v 1.2 2002-04-07 14:17:33 jthorn Exp $
+# $Id: makefile,v 1.3 2002-04-10 14:03:04 jthorn Exp $
#
# CC, CXX = C and C++ compilers. Defaults are gcc and g++ if
# variables aren't set from command line or environment.
@@ -13,7 +13,6 @@
# Targets:
# test ==> build test programs
# clean ==> delete object files, test drivers
-# superclean ==> delete object files, test drivers
#
# Bugs:
# - Dependencies on *.hh are omitted.
@@ -23,12 +22,14 @@ CXX := g++
CFLAGS := $(STD_GCC_FLAGS) -I.. -g
CXXFLAGS := $(STD_GXX_FLAGS) -I.. -g
+ALL_TESTS := test_array test_array2 \
+ test_cpm_map test_linear_map \
+ test_fuzzy test_round \
+ test_modulo test_norm
+
################################################################################
-test : test_array test_array2 \
- test_cpm_map test_linear_map \
- test_fuzzy test_round \
- test_modulo test_norm
+test : $(ALL_TESTS)
test_array : test_array.o array.o \
fuzzy.o round.o -lm
@@ -44,3 +45,8 @@ test_modulo : test_modulo.o miscfp.o \
fuzzy.o round.o error_exit.o -lm
test_norm : test_norm.o norm.o \
fuzzy.o round.o -lm
+
+.PHONY : clean
+clean :
+ -rm -f *.o
+ -rm -f $(ALL_TESTS)
diff --git a/src/jtutil/norm.cc b/src/jtutil/norm.cc
index 1878e74..d6f0baf 100644
--- a/src/jtutil/norm.cc
+++ b/src/jtutil/norm.cc
@@ -5,8 +5,8 @@
// *** class jtutil::norm::
//
-#include <float.h>
-#include <math.h>
+#include <cmath>
+#include <algorithm>
#include <assert.h>
#include "jt/util.hh"
@@ -21,7 +21,7 @@ template <typename fp>
{
++N_;
sum2_ += x*x;
-infinity_norm_ = jtutil::max(infinity_norm_, jtutil::abs(x));
+infinity_norm_ = std::max(infinity_norm_, jtutil::abs<fp>(x));
}
} // namespace jtutil::
@@ -31,10 +31,10 @@ infinity_norm_ = jtutil::max(infinity_norm_, jtutil::abs(x));
namespace jtutil
{
template<typename fp>
- fp norm<fp>::two_norm() const { return sqrt(sum2_); }
+ fp norm<fp>::two_norm() const { return std::sqrt(sum2_); }
template<typename fp>
fp norm<fp>::rms_norm() const
- { assert(is_nonempty()); return sqrt(sum2_/fp(N_)); }
+ { assert(is_nonempty()); return std::sqrt(sum2_/fp(N_)); }
template<typename fp>
fp norm<fp>::infinity_norm() const { return infinity_norm_; }
} // namespace jtutil::
diff --git a/src/jtutil/util.hh b/src/jtutil/util.hh
index b1051a4..e3a8f75 100644
--- a/src/jtutil/util.hh
+++ b/src/jtutil/util.hh
@@ -2,7 +2,6 @@
// $Id$
//
// jtutil::{how_many_in_range,is_even,is_odd} - misc integer manipulation
-// jtutil::{min,max} - min/max templates
// jtutil::abs - absolute value template
// jtutil::pow* - raise floating point value to small-integer power
// jtutil::norm<fp> - compute 2-, rms-, and infinity-norms
@@ -24,19 +23,9 @@ inline int is_even(int i) { return !(i & 0x1); }
inline int is_odd (int i) { return (i & 0x1); }
//
-// minimum/maximum templates (valid for both integer and floating-point types)
-// FIXME: these are supposed to be in the STL, in <algorithm>
-// but in practice they often aren't (yet) :(
-// eg the gcc 2.95.2 library doesn't have them :(
-//
-template <typename num>
- inline num min(num x, num y) { return x < y ? x : y; };
-template <typename num>
- inline num max(num x, num y) { return x > y ? x : y; };
-
-//
// absolute value template
-// FIXME: this ought to be somewhere in the STL?
+// FIXME: <cmath> puts this in std::, but then things sometimes get
+// confused with the C function int abs(int) :( :( :(
//
template <typename fp>
inline fp abs(fp x) { return (x > 0.0) ? x : -x; }