42 #define AFF_SHAPETEST_CC_VERSION \ 43 "AFF_SHAPETEST_CC V1.3" 75 void section(
const char* s,
const char l=
'-')
77 cout << endl << s << endl;
79 while (*p) { cout << l; ++p; }
87 {
if (b)
return(
"true");
return(
"false"); }
92 #define BOOLIS( S ) cout << " *** " << #S << ": " << bvalue(S); 101 for (
int i=0; i<nmax; i++)
103 cout.width(3); cout << i+1;
105 cout.width(5); cout << s1.
current() <<
"=[";
109 cout.width(2); cout << s1.index(j);
112 cout.width(5); cout <<
bvalue(s1.more());
113 cout.width(6); cout <<
bvalue(s1.valid());
115 cout.width(5); cout << s2.
current() <<
"=[";
119 cout.width(2); cout << s2.
index(j);
137 section(
"Test shape class Strided",
'=');
139 section(
"Test shaper class Shaper");
141 cout << endl <<
"Basic usage:" << endl;
145 #warning intentionally compiling illegal code 146 cout << endl <<
"Illegal with limited dimensionality:" << endl;
150 cout << endl <<
"Usage for an external Fortran shape:" << endl;
153 section(
"Test subarrays and slicing");
175 cout << endl <<
"Basic functionality" << endl;
182 cout << endl <<
"Shape with gaps" << endl;
184 DUMP( shape.shrink(0,3,5).shrink(1,4,6).shrink(2,5,7).shrink(3,6,8) );
189 cout << endl <<
"Small array" << endl;
195 section(
"Test offset functions");
198 CODE( shape.shrink(0,2,4).shrink(1,3,7).shrink(2,5,6).shrink(3,2,3); )
205 CODE( copy.collapse(2,6).collapse(2,3).shift(0,1000).setfirst(1,50); )
208 CODE( copy.collapse(1,7).collapse(2,3).shift(0,1000).setfirst(1,50); )
StridedStepper & decr()
decrement offset - return reference to itself
Root namespace of library.
Shape for a rectangular array layout.
#define AFF_SHAPETEST_CC_VERSION
int main()
test shape class
void section(const char *s, const char l='-')
print headline
#define DUMP(A)
Dump any object through its dump function.
const TIndexVec & index() const
return current index vector for array access
void dump_map(const Strided &shape, const Tdim &i, std::ostream &os)
dump index mapping of shape
Stepper class for strided shapes (prototypes)
#define CODE(C)
Dump code and execute (works like echo)
static const Tdim Mmax_dimen
instantiate static member (otherwise the linker won't find it)
StridedStepper & tolast()
set current element index to the last - return reference to itself
debug helpers (prototypes)
void steppers(const Strided &shape, const int &nmax=30)
cycle steppers
const Tsubscript & current() const
return current index value for Representation access
A stepper for all strided shapes.
const bool & valid() const
valid if not passed end or beginning
bool less() const
returns true if there are more elements in decr-direction
Shaper class for Fortran layout.
rectangular Fortran array layout (prototypes)
const char * bvalue(const bool &b)
print value of a bool