ProteoWizard
simplepickertest.cpp
Go to the documentation of this file.
1//
2// $Id$
3//
4//
5// Original author: Witold Wolski <wewolski@gmail.com>
6//
7// Copyright : ETH Zurich
8//
9// Licensed under the Apache License, Version 2.0 (the "License");
10// you may not use this file except in compliance with the License.
11// You may obtain a copy of the License at
12//
13// http://www.apache.org/licenses/LICENSE-2.0
14//
15// Unless required by applicable law or agreed to in writing, software
16// distributed under the License is distributed on an "AS IS" BASIS,
17// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18// See the License for the specific language governing permissions and
19// limitations under the License.
20//
21
24
25namespace {
26
27 using namespace pwiz::util;
28
29 // Tests that the Foo::Bar() method does Abc.
30 void testpicker() {
32
33 std::vector<double> zerocross(10,0.);
34 //lag2 at 5
35 //lag2 at
36 double data2[] = {1.,2.,3.,4.,5.,6.,5.,3.,2.,1.,0.};
37 size_t x = sp(data2,data2+sizeof(data2)/sizeof(double),zerocross.begin(),zerocross.size(),2);
38 unit_assert_equal(zerocross[0],5.,1e-10);
39 x = sp(data2,data2+sizeof(data2)/sizeof(double),zerocross.begin(),zerocross.size(),4);
40 unit_assert_equal(zerocross[0],4.6666,1e-4);
41 x = sp(data2,data2+sizeof(data2)/sizeof(double),zerocross.begin(),zerocross.size(),6);
42 unit_assert_equal(zerocross[0],4.5,1e-4);
43 std::cout << x << std::endl;
44
45
46 double data3[] = {0.,1.,2.,3.,5.,6.,5.,4.,3.,2.,1.};
47 x = sp(data3,data3+sizeof(data3)/sizeof(double),zerocross.begin(),zerocross.size(),2);
48 x = sp(data3,data3+sizeof(data3)/sizeof(double),zerocross.begin(),zerocross.size(),4);
49 unit_assert_equal(zerocross[0],5.3333,1e-4);
50 x = sp(data3,data3+sizeof(data3)/sizeof(double),zerocross.begin(),zerocross.size(),6);
51 unit_assert_equal(zerocross[0],5.5,1e-4);
52 std::cout << x << std::endl;
53
54 double data[] = {1.,2.,3.,4.,5.,6.,5.,4.,3.,2.,1.};
55
56 // for lag 2
57 // zero cross at 5
58
59 x = sp(data,data+sizeof(data)/sizeof(double),zerocross.begin(),2);
60 unit_assert_equal(zerocross[0],5.,1e-10);
61 x = sp(data,data+sizeof(data)/sizeof(double),zerocross.begin(),4);
62 unit_assert_equal(zerocross[0],5.,1e-10);
63 x = sp(data,data+sizeof(data)/sizeof(double),zerocross.begin(),6);
64 unit_assert_equal(zerocross[0],5.,1e-10);
65
66 std::cout << x << std::endl;
67 }
68}//end namespace
69
70
71int main(int argc, char **argv) {
72 testpicker();
73}
KernelTraitsBase< Kernel >::space_type::abscissa_type x
int main(int argc, char **argv)
#define unit_assert_equal(x, y, epsilon)
Definition unit.hpp:99