/*! \file shapetest.cc * \brief test shape classes (implementation) * * ---------------------------------------------------------------------------- * * $Id: shapetest.cc,v 1.1 2002-12-06 19:21:08 forbrig Exp $ * \author Thomas Forbriger * \date 25/05/2002 * * test shape classes (implementation) * * Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt) * * REVISIONS and CHANGES * - 25/05/2002 V1.0 Thomas Forbriger * - 25/11/2002 V1.1 testing stepper * * ============================================================================ */ #define TF_SHAPETEST_CC_VERSION \ "TF_SHAPETEST_CC V1.1 " #define TF_SHAPETEST_CC_CVSID \ "$Id: shapetest.cc,v 1.1 2002-12-06 19:21:08 forbrig Exp $" #include #include #include #include #include #include using std::cout; using std::endl; using std::string; using namespace contxx::shape; using namespace contxx::util; /* * function to print index relation of shape */ template class Shape> void indexer(const char* name, const Shape& shape) { cout << "shape " << name << ":" << endl; typename Shape::Tlimits index; for (Tdim i=0; ishape.last(i)) { index[i]=shape.first(i); i++; } else { i=N; } } } cout << endl; } #define INDEXER( shape ) indexer( #shape , shape ); /* * function to print values of simple array */ template void saprint(const char* name, const S& s) { cout << "simple array: " << name << ":" << endl; for (Tsize i=0; i void position(const S& s) { cout << "cur: " << s.current() << " "; cout << "idx: "; for (int i=0; i A(tuple(3,3,3)); INDEXER( A ) } { cout << endl; cout << "Test SimpleRigidArray" << endl; cout << "=====================" << endl; cout << endl; SAPRINTER( tuple(5,8,2,5,4) ) SAPRINTER( tuple(6,300,12,-18,2) ) SAPRINTER( tuple(3.31e64,300.,12.,-18.,2.) ) SAPRINTER( tuple(string("Hallo"), string("das"), string("klappt"), string("auch"), string("so")) ) } { cout << endl; cout << "Test Stepper" << endl; cout << "============" << endl; cout << endl; Strided<3>::Tlimits first(tuple(2,1,5)); Strided<3>::Tlimits last(tuple(4,4,6)); Strided<3> S1(first,last); DenseStrided<3> S2(first,last); Strided<3>::Tstepper ST1(S1.stepper()); DenseStrided<3>::Tstepper ST2(S2.stepper()); POSITION(ST1); POSITION(ST2); cout << endl; cout << "to last:" << endl; ST1.tolast(); ST2.tolast(); POSITION(ST1); POSITION(ST2); cout << endl; cout << "to first:" << endl; ST1.tofirst(); ST2.tofirst(); POSITION(ST1); POSITION(ST2); cout << endl; cout << "increment:" << endl; for (int i=0; i<30; i++) { POSITION(ST1.incr()); POSITION(ST2.incr()); cout << endl; } cout << "while less:" << endl; do { POSITION(ST1.decr()); POSITION(ST2.decr()); cout << endl; BOOLIS(ST1.less()); BOOLIS(ST2.less()); cout << endl; } while (ST1.less() && ST2.less()); cout << "to first:" << endl; ST1.tofirst(); ST2.tofirst(); POSITION(ST1); POSITION(ST2); cout << endl; cout << "to last:" << endl; ST1.tolast(); ST2.tolast(); POSITION(ST1); POSITION(ST2); cout << endl; cout << "decrement:" << endl; for (int i=0; i<30; i++) { POSITION(ST1.decr()); POSITION(ST2.decr()); cout << endl; } cout << "while more:" << endl; do { POSITION(ST1.incr()); POSITION(ST2.incr()); cout << endl; } while (ST1.more() && ST2.more()); } } /* ----- END OF shapetest.cc ----- */