Typedefs | Functions
test_CompactRealDftData.cxx File Reference
#include "dunecore/DuneCommon/Utility/CompactRealDftData.h"
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cassert>

Go to the source code of this file.

Typedefs

using Dft = CompactRealDftData< float >
 
using Index = Dft::Index
 
using FloatVector = Dft::FloatVector
 

Functions

int test_CompactRealDftData (bool useExistingFcl)
 
int main (int argc, char *argv[])
 

Typedef Documentation

using Dft = CompactRealDftData<float>

Definition at line 29 of file test_CompactRealDftData.cxx.

Definition at line 31 of file test_CompactRealDftData.cxx.

using Index = Dft::Index

Definition at line 30 of file test_CompactRealDftData.cxx.

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 117 of file test_CompactRealDftData.cxx.

117  {
118  bool useExistingFcl = false;
119  if ( argc > 1 ) {
120  string sarg(argv[1]);
121  if ( sarg == "-h" ) {
122  cout << "Usage: " << argv[0] << " [ARG]" << endl;
123  cout << " If ARG = true, existing FCL file is used." << endl;
124  return 0;
125  }
126  useExistingFcl = sarg == "true" || sarg == "1";
127  }
128  return test_CompactRealDftData(useExistingFcl);
129 }
int test_CompactRealDftData(bool useExistingFcl)
QTextStream & endl(QTextStream &s)
int test_CompactRealDftData ( bool  useExistingFcl)

Definition at line 35 of file test_CompactRealDftData.cxx.

35  {
36  const string myname = "test_RealDftData: ";
37 #ifdef NDEBUG
38  cout << myname << "NDEBUG must be off." << endl;
39  abort();
40 #endif
41  string line = "-----------------------------";
43 
44  cout << myname << line << endl;
45  cout << myname << "Create DFT." << endl;
46  FloatVector amps = { 5.0, 4.0, 3.0, 2.0, 1.0 };
47  FloatVector phas = { 0.0, 0.5, 1.0, 2.0, 4.0 };
48  Index namp = amps.size();
49  Index npha = phas.size();
50  Index nsam = namp + npha - 1;
51  assert( amps.size() == namp );
52  assert( phas.size() == npha );
53  cout << myname << "Sample length: " << nsam << endl;
54 
55  cout << myname << line << endl;
56  cout << myname << "Create invalid DFT objects." << endl;
57  FloatVector badvals = {11.1, 22.2};
58  Dft dftbad1(mynorm, amps, badvals);
59  assert ( ! dftbad1.size() );
60  Dft dftbad2(mynorm, badvals, phas);
61  assert ( ! dftbad2.size() );
62 
63  cout << myname << line << endl;
64  cout << myname << "Create DFT object with data." << endl;
65  Dft dft(mynorm, amps, phas);
66  cout << myname << " # samples: " << dft.size() << endl;
67  cout << myname << " Power: " << dft.power() << endl;
68  assert( dft.normalization().isValid() );
69  assert( dft.isValid() );
70  assert( dft.size() );
71  assert( dft.nCompact() == namp );
72  assert( dft.nAmplitude() == namp );
73  assert( dft.nPhase() == npha );
74  assert( dft.nSample() == nsam );
75  assert( dft.normalization().isStandard() );
76  assert( ! dft.normalization().isConsistent() );
77  assert( ! dft.normalization().isBin() );
78  assert( dft.normalization().isUnit() );
79  assert( ! dft.normalization().isPower() );
80 
81  // Copy data out.
82  cout << myname << line << endl;
83  cout << myname << "Copy data out." << endl;
84  FloatVector amps1, phas1;
85  dft.copyOut(amps1, phas1);
86  assert( dft.isValid() );
87  assert( dft.size() );
88  assert( dft.nCompact() == namp );
89  assert( dft.nAmplitude() == namp );
90  assert( dft.nPhase() == npha );
91  assert( dft.nSample() == nsam );
92  assert( amps1 == amps );
93  assert( phas1 == phas );
94 
95  // Move data out.
96  cout << myname << line << endl;
97  cout << myname << "Move data out." << endl;
98  FloatVector amps2, phas2;
99  dft.moveOut(amps2, phas2);
100  assert( ! dft.isValid() );
101  assert( dft.normalization().isValid() );
102  assert( dft.size() == 0 );
103  assert( dft.nCompact() == 0 );
104  assert( dft.nAmplitude() == 0 );
105  assert( dft.nPhase() == 0 );
106  assert( dft.nSample() == 0 );
107  assert( amps2 == amps );
108  assert( phas2 == phas );
109 
110  cout << myname << line << endl;
111  cout << myname << "Done." << endl;
112  return 0;
113 }
unsigned int Index
void line(double t, double *p, double &x, double &y, double &z)
Dft::FloatVector FloatVector
QTextStream & endl(QTextStream &s)