AFF --- A container for numbers (array) by Friederich and Forbriger.

◆ main()

int main ( )

test shape class

Definition at line 133 of file shapetest.cc.

References AFF_SHAPETEST_CC_VERSION, CODE, DUMP, aff::dump_map(), section(), and steppers().

134 {
135  cout << AFF_SHAPETEST_CC_VERSION << endl;
136 
137  section("Test shape class Strided", '=');
138 
139  section("Test shaper class Shaper");
140 
141  cout << endl << "Basic usage:" << endl;
142  DUMP( Shaper(10)(12) );
143 
144 #ifdef ILLEGAL1
145 #warning intentionally compiling illegal code
146  cout << endl << "Illegal with limited dimensionality:" << endl;
147  DUMP( Shaper(2,10)(-12,12)(9)(2,7)(3,4) );
148 #endif
149 
150  cout << endl << "Usage for an external Fortran shape:" << endl;
151  DUMP( Shaper(1,6,10)(1,12,30)(1,10) );
152 
153  section("Test subarrays and slicing");
154 
155  DUMP( Shaper(10)(10)(10) );
156 
157  cout << endl;
158  DUMP( Strided(Shaper(10)(10)(10)).shrink(0,2,5) );
159 
160  cout << endl;
161  DUMP( Strided(Shaper(10)(10)(10)).shrink(2,5) );
162 
163  cout << endl;
164  DUMP( Strided(Shaper(10)(15)(20)).collapse(1,5) );
165 
166  cout << endl;
167  DUMP( Strided(Shaper(11,20)(11,20)(11,20)).shift(1,5) );
168 
169  cout << endl;
170  DUMP( Strided(Shaper(11,20)(11,20)(11,20)).setfirst(1,5) );
171 
172  section("Test stepper");
173 
174  {
175  cout << endl << "Basic functionality" << endl;
176  CODE( Strided shape(Shaper(3)(4)(2)(3)); )
177  DUMP( shape );
178  CODE( steppers(shape, shape.size()+10); )
179  }
180 
181  {
182  cout << endl << "Shape with gaps" << endl;
183  CODE( Strided shape(Shaper(0,9)(0,9)(0,9)(0,9)); )
184  DUMP( shape.shrink(0,3,5).shrink(1,4,6).shrink(2,5,7).shrink(3,6,8) );
185  CODE( steppers(shape, shape.size()+10); )
186  }
187 
188  {
189  cout << endl << "Small array" << endl;
190  CODE( Strided shape(Shaper(3,5,10)(3)); )
191  DUMP( shape );
192  CODE( steppers(shape, shape.size()+10); )
193  }
194 
195  section("Test offset functions");
196  {
197  CODE( Strided shape(Shaper(5)(10)(10)(10)); )
198  CODE( shape.shrink(0,2,4).shrink(1,3,7).shrink(2,5,6).shrink(3,2,3); )
199  CODE( dump_map(shape, 3); )
200  CODE( dump_map(shape, 2); )
201  CODE( dump_map(shape, 1); )
202  CODE( dump_map(shape, 0); )
203  CODE( steppers(shape, shape.size()); )
204  CODE( Strided copy(shape); )
205  CODE( copy.collapse(2,6).collapse(2,3).shift(0,1000).setfirst(1,50); )
206  CODE( dump_map(copy); )
207  CODE( copy=shape; )
208  CODE( copy.collapse(1,7).collapse(2,3).shift(0,1000).setfirst(1,50); )
209  CODE( dump_map(copy); )
210  }
211 }
Shape for a rectangular array layout.
Definition: strided.h:117
#define AFF_SHAPETEST_CC_VERSION
Definition: shapetest.cc:42
void section(const char *s, const char l='-')
print headline
Definition: shapetest.cc:75
#define DUMP(A)
Dump any object through its dump function.
Definition: dump_macros.h:62
void dump_map(const Strided &shape, const Tdim &i, std::ostream &os)
dump index mapping of shape
Definition: dump.cc:145
#define CODE(C)
Dump code and execute (works like echo)
Definition: dump_macros.h:82
void steppers(const Strided &shape, const int &nmax=30)
cycle steppers
Definition: shapetest.cc:97
Shaper class for Fortran layout.
Definition: shaper.h:66
Here is the call graph for this function: