GSE++ library: reading and writing GSE waveforms

◆ test_diff()

void GSE2::tests::test_diff ( )

Test the template metaprograms that apply and remove differences.

See also
GSE2::waveform::apply1stdiffT
GSE2::waveform::apply2nddiffT
GSE2::waveform::remove1stdiffT
GSE2::waveform::remove1stdiffT

Definition at line 77 of file gsexx_tests.cc.

Referenced by main().

78 {
79  std::cout << std::endl;
80  std::cout
81  << "Test the template metaprograms that apply and remove differences."
82  << std::endl;
83 
84  // test values
85  int values[] = { 1,3,5,7,3,-2,-4,6 };
86  // number of test values
87  const int nval=8;
88  // declare differencers
91  // declare inverse operators
94  for (int i=0; i<nval; i++)
95  {
96  // apply 1st differences
97  int v1st=diff1st(values[i]);
98  // apply 2nd differences
99  int v2nd=diff2nd(values[i]);
100  // remove 1st differences
101  int v1strem=rem1st(v1st);
102  // remove 2nd differences
103  int v2ndrem=rem2nd(v2nd);
104  // print results
105  std::cout.width(3); std::cout << i << " " << "value=";
106  std::cout.width(3); std::cout << values[i] << " " << "1st diff=";
107  std::cout.width(3); std::cout << v1st << " " << "1st rem=";
108  std::cout.width(3); std::cout << v1strem << " " << "2nd diff=";
109  std::cout.width(3); std::cout << v2nd << " " << "2nd rem=";
110  std::cout.width(3); std::cout << v2ndrem << " ";
111  std::cout << std::endl;
112  }
113 } // function test_diff
differences::Tdiff_operator< 2, differences::Tremove_diff > remove2nddiffT
Operator to remove second differences.
Definition: gsexx.h:286
differences::Tdiff_operator< 2, differences::Tapply_diff > apply2nddiffT
Operator to apply second differences.
Definition: gsexx.h:280
differences::Tdiff_operator< 1, differences::Tapply_diff > apply1stdiffT
Operator to apply first differences.
Definition: gsexx.h:277
differences::Tdiff_operator< 1, differences::Tremove_diff > remove1stdiffT
Operator to remove first differences.
Definition: gsexx.h:283
Here is the caller graph for this function: