shapetest.cc 2.23 KB
Newer Older
thomas.forbriger's avatar
thomas.forbriger committed
1
2
3
4
5
/*! \file shapetest.cc
 * \brief test shape classes (implementation)
 * 
 * ----------------------------------------------------------------------------
 * 
thomas.forbriger's avatar
thomas.forbriger committed
6
 * $Id: shapetest.cc,v 1.2 2002-12-18 09:58:52 forbrig Exp $
thomas.forbriger's avatar
thomas.forbriger committed
7
8
9
10
11
12
13
14
15
 * \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
thomas.forbriger's avatar
thomas.forbriger committed
16
 *  - 18/12/2002   V1.1   started test of Strided (aff)
thomas.forbriger's avatar
thomas.forbriger committed
17
18
19
 * 
 * ============================================================================
 */
thomas.forbriger's avatar
thomas.forbriger committed
20
21
22
23
#define AFF_SHAPETEST_CC_VERSION \
  "AFF_SHAPETEST_CC   V1.1"
#define AFF_SHAPETEST_CC_CVSID \
  "$Id: shapetest.cc,v 1.2 2002-12-18 09:58:52 forbrig Exp $"
thomas.forbriger's avatar
thomas.forbriger committed
24
25

#include<iostream>
thomas.forbriger's avatar
thomas.forbriger committed
26
27
#include<aff/dump.h>
#include<aff/shaper.h>
thomas.forbriger's avatar
thomas.forbriger committed
28
29
30

using std::cout;
using std::endl;
thomas.forbriger's avatar
thomas.forbriger committed
31
32
33
34
35
36
37
38
using namespace aff;

/*! \example tests/shapetest.cc
 *
 * Test shape aff::Strided, the shaper class aff::Shaper,
 * and the helper class aff::util::StridedStepper
 *
 * \sa tests/shapetest.cc
thomas.forbriger's avatar
thomas.forbriger committed
39
40
 */

thomas.forbriger's avatar
thomas.forbriger committed
41
42
//! echo
#define CODE( C ) cout << #C << endl; C
thomas.forbriger's avatar
thomas.forbriger committed
43

thomas.forbriger's avatar
thomas.forbriger committed
44
45
//! print headline
void section(const char* s, const char l='-')
thomas.forbriger's avatar
thomas.forbriger committed
46
{
thomas.forbriger's avatar
thomas.forbriger committed
47
48
49
  cout << endl << s << endl;
  const char* p=s;
  while (*p) { cout << l; ++p; }
thomas.forbriger's avatar
thomas.forbriger committed
50
51
52
  cout << endl;
}

thomas.forbriger's avatar
thomas.forbriger committed
53
//! print value of a bool
thomas.forbriger's avatar
thomas.forbriger committed
54
55
56
const char* bvalue(const bool& b)
{ if (b) return("true"); return("false"); }

thomas.forbriger's avatar
thomas.forbriger committed
57
//! print value of a bool
thomas.forbriger's avatar
thomas.forbriger committed
58
59
#define BOOLIS( S ) cout << " *** " << #S << ": " << bvalue(S);

thomas.forbriger's avatar
thomas.forbriger committed
60
//! test shape class
thomas.forbriger's avatar
thomas.forbriger committed
61
62
int main()
{
thomas.forbriger's avatar
thomas.forbriger committed
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
  cout << AFF_SHAPETEST_CC_VERSION << endl;
  cout << AFF_SHAPETEST_CC_CVSID << endl << endl;
  
  section("Test shape class Strided", '=');

  section("Test shaper class Shaper");

  cout << endl << "Basic usage:" << endl;
  DUMP( Shaper(10)(12) );

  cout << endl << "Fool proof with limited dimensionality:" << endl;
  DUMP( Shaper(2,10)(-12,12)(9)(2,7)(3,4) );

  cout << endl << "Usage for an external Fortran shape:" << endl;
  DUMP( Shaper(1,6,10)(1,12,30)(1,10) );

  section("Test subarrays and slicing");

  DUMP( Shaper(10)(10)(10) );

  cout << endl;
  DUMP( Strided(Shaper(10)(10)(10)).shrink(0,2,5) );

  cout << endl;
  DUMP( Strided(Shaper(10)(10)(10)).shrink(2,5) );

  cout << endl;
  DUMP( Strided(Shaper(10)(15)(20)).collapse(1,5) );
thomas.forbriger's avatar
thomas.forbriger committed
91
92
93
}

/* ----- END OF shapetest.cc ----- */