diff options
author | jthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5> | 2002-07-08 13:48:47 +0000 |
---|---|---|
committer | jthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5> | 2002-07-08 13:48:47 +0000 |
commit | f8152abfe46754f261e012ab96b70168b346c0b3 (patch) | |
tree | a9850b9ac162d3c8f92b247a7e29861128a0a5ac /src/jtutil | |
parent | f205f775e69ad6f4b772963a6d826ad627b3199f (diff) |
array.{cc,hh}
* rename is_valid_subscript() functions to
is_valid_i() , is_valid_ij() , is_valid_ijk(), is_valid_ijkl()
* also switch subscript() over to separate asserts on each axis
so assert violation msg will tell us which axis is out of range
array.cc
* add #ifdef STANDALONE_TEST code to get "fake_cctk.h" in this case
cpm_map.cc
* tweak some comments
makefile
* define STANDALONE_TEST for standalone test compilations
git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinAnalysis/AHFinderDirect/trunk@609 f88db872-0e4f-0410-b76b-b9085cfa78c5
Diffstat (limited to 'src/jtutil')
-rw-r--r-- | src/jtutil/array.cc | 7 | ||||
-rw-r--r-- | src/jtutil/array.hh | 39 | ||||
-rw-r--r-- | src/jtutil/cpm_map.cc | 6 | ||||
-rw-r--r-- | src/jtutil/makefile | 6 |
4 files changed, 34 insertions, 24 deletions
diff --git a/src/jtutil/array.cc b/src/jtutil/array.cc index 4e394ff..e48ae27 100644 --- a/src/jtutil/array.cc +++ b/src/jtutil/array.cc @@ -19,7 +19,12 @@ #include <assert.h> #include <stddef.h> // for NULL -#include "cctk.h" // so we can instantiate templates with CCTK_* types +// we want to instantiate templates with CCTK_* types +#ifdef STANDALONE_TEST + #include "fake_cctk.h" +#else + #include "cctk.h" +#endif #include "stdc.h" #include "util.hh" diff --git a/src/jtutil/array.hh b/src/jtutil/array.hh index dbe997f..9f4715f 100644 --- a/src/jtutil/array.hh +++ b/src/jtutil/array.hh @@ -69,8 +69,6 @@ public: int max_i() const { return max_i_; } int N_i() const { return jtutil::how_many_in_range(min_i_, max_i_); } bool is_valid_i(int i) const { return (i >= min_i_) && (i <= max_i_); } - bool is_valid_subscript(int i) const - { return is_valid_i(i); } // subscripting functions // (low-level, dangerous, use with caution!) @@ -80,17 +78,18 @@ public: { return offset_ + stride_i_*i; } int subscript(int i) const { - assert( is_valid_subscript(i) ); - const int posn = subscript_unchecked(i); // n.b. we want each assert() here to be on a separate // source line, so an assert() failure message can // pinpoint *which* index is bad + assert( is_valid_i(i) ); + const int posn = subscript_unchecked(i); assert(posn >= 0); assert(posn <= max_subscript_); return posn; } int subscript_offset() const { return offset_; } int subscript_stride_i() const { return stride_i_; } + // normal-use access functions // ... rvalue @@ -139,7 +138,7 @@ private: // n.b. put this at end of class since performance doesn't matter bool we_own_array_; // true ==> array_ --> new[] array which we own - // false ==> array --> caller owns array_ + // false ==> array_ --> client-owned storage }; }; // namespace jtutil:: @@ -160,7 +159,7 @@ public: int N_j() const { return jtutil::how_many_in_range(min_j_, max_j_); } bool is_valid_i(int i) const { return (i >= min_i_) && (i <= max_i_); } bool is_valid_j(int j) const { return (j >= min_j_) && (j <= max_j_); } - bool is_valid_subscript(int i, int j) const + bool is_valid_ij(int i, int j) const { return is_valid_i(i) && is_valid_j(j); } // subscripting functions @@ -171,11 +170,12 @@ public: { return offset_ + stride_i_*i + stride_j_*j; } int subscript(int i, int j) const { - assert( is_valid_subscript(i,j) ); - const int posn = subscript_unchecked(i,j); // n.b. we want each assert() here to be on a separate // source line, so an assert() failure message can // pinpoint *which* index is bad + assert( is_valid_i(i) ); + assert( is_valid_j(j) ); + const int posn = subscript_unchecked(i,j); assert(posn >= 0); assert(posn <= max_subscript_); return posn; @@ -235,7 +235,7 @@ private: // n.b. put this at end of class since performance doesn't matter bool we_own_array_; // true ==> array_ --> new[] array which we own - // false ==> array --> caller owns array_ + // false ==> array_ --> client-owned storage }; }; // namespace jtutil:: @@ -260,7 +260,7 @@ public: bool is_valid_i(int i) const { return (i >= min_i_) && (i <= max_i_); } bool is_valid_j(int j) const { return (j >= min_j_) && (j <= max_j_); } bool is_valid_k(int k) const { return (k >= min_k_) && (k <= max_k_); } - bool is_valid_subscript(int i, int j, int k) const + bool is_valid_ijk(int i, int j, int k) const { return is_valid_i(i) && is_valid_j(j) && is_valid_k(k); } // subscripting functions @@ -271,11 +271,13 @@ public: { return offset_ + stride_i_*i + stride_j_*j + stride_k_*k; } int subscript(int i, int j, int k) const { - assert( is_valid_subscript(i,j,k) ); - const int posn = subscript_unchecked(i,j,k); // n.b. we want each assert() here to be on a separate // source line, so an assert() failure message can // pinpoint *which* index is bad + assert( is_valid_i(i) ); + assert( is_valid_j(j) ); + assert( is_valid_k(k) ); + const int posn = subscript_unchecked(i,j,k); assert(posn >= 0); assert(posn <= max_subscript_); return posn; @@ -338,7 +340,7 @@ private: // n.b. put this at end of class since performance doesn't matter bool we_own_array_; // true ==> array_ --> new[] array which we own - // false ==> array --> caller owns array_ + // false ==> array_ --> client-owned storage }; }; // namespace jtutil:: @@ -367,7 +369,7 @@ public: bool is_valid_j(int j) const { return (j >= min_j_) && (j <= max_j_); } bool is_valid_k(int k) const { return (k >= min_k_) && (k <= max_k_); } bool is_valid_l(int l) const { return (l >= min_l_) && (l <= max_l_); } - bool is_valid_subscript(int i, int j, int k, int l) const + bool is_valid_ijkl(int i, int j, int k, int l) const { return is_valid_i(i) && is_valid_j(j) && is_valid_k(k) && is_valid_l(l); @@ -384,11 +386,14 @@ public: } int subscript(int i, int j, int k, int l) const { - assert( is_valid_subscript(i,j,k,l) ); - const int posn = subscript_unchecked(i,j,k,l); // n.b. we want each assert() here to be on a separate // source line, so an assert() failure message can // pinpoint *which* index is bad + assert( is_valid_i(i) ); + assert( is_valid_j(j) ); + assert( is_valid_k(k) ); + assert( is_valid_l(l) ); + const int posn = subscript_unchecked(i,j,k,l); assert(posn >= 0); assert(posn <= max_subscript_); return posn; @@ -455,6 +460,6 @@ private: // n.b. put this at end of class since performance doesn't matter bool we_own_array_; // true ==> array_ --> new[] array which we own - // false ==> array --> caller owns array_ + // false ==> array_ --> client-owned storage }; }; // namespace jtutil:: diff --git a/src/jtutil/cpm_map.cc b/src/jtutil/cpm_map.cc index 6f84307..7b1a897 100644 --- a/src/jtutil/cpm_map.cc +++ b/src/jtutil/cpm_map.cc @@ -1,9 +1,9 @@ // cpm_map.cc -- "integer +/-" mapping i --> j = const +/- i // $Id$ // -// jtutil::cpm_map::cpm_map // mirror map, specified by fixed point -// jtutil::cpm_map::cpm_map // generic map specified by sample point & sign -// jtutil::cpm_map::cpm_map // generic map specified by *fp* sample point & sign +// jtutil::cpm_map::cpm_map # mirror map, specified by fixed point +// jtutil::cpm_map::cpm_map # generic map specified by sample point & sign +// jtutil::cpm_map::cpm_map # generic map specified by *fp* sample point & sign // // ***** template instantiations ***** // diff --git a/src/jtutil/makefile b/src/jtutil/makefile index b9541c0..40a7675 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.4 2002-06-24 16:15:42 jthorn Exp $ +# $Id: makefile,v 1.5 2002-07-08 13:48:47 jthorn Exp $ # # CC, CXX = C and C++ compilers. Defaults are gcc and g++ if # variables aren't set from command line or environment. @@ -19,8 +19,8 @@ # CXX := g++ -CFLAGS := $(STD_GCC_FLAGS) -I../include -g -CXXFLAGS := $(STD_GXX_FLAGS) -I../include -g +CFLAGS := $(STD_GCC_FLAGS) -I../include -DSTANDALONE_TEST -g +CXXFLAGS := $(STD_GXX_FLAGS) -I../include -DSTANDALONE_TEST -g ALL_TESTS := test_array test_array2 \ test_cpm_map test_linear_map \ |