ProteoWizard
pwiz
analysis
chromatogram_processing
SavitzkyGolaySmootherTest.cpp
Go to the documentation of this file.
1
//
2
// $Id$
3
//
4
//
5
// Original author: Matt Chambers <matt.chambers <a.t> vanderbilt.edu>
6
//
7
// Copyright 2008 Spielberg Family Center for Applied Proteomics
8
// Cedars-Sinai Medical Center, Los Angeles, California 90048
9
//
10
// Licensed under the Apache License, Version 2.0 (the "License");
11
// you may not use this file except in compliance with the License.
12
// You may obtain a copy of the License at
13
//
14
// http://www.apache.org/licenses/LICENSE-2.0
15
//
16
// Unless required by applicable law or agreed to in writing, software
17
// distributed under the License is distributed on an "AS IS" BASIS,
18
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
// See the License for the specific language governing permissions and
20
// limitations under the License.
21
//
22
23
24
#include "
SavitzkyGolaySmoother.hpp
"
25
#include "
pwiz/utility/misc/unit.hpp
"
26
#include "
pwiz/utility/misc/Std.hpp
"
27
28
using namespace
pwiz::util
;
29
using namespace
pwiz::analysis
;
30
31
32
ostream*
os_
= 0;
33
34
35
const
double
testArray
[] =
36
{
37
1, 15, 29, 20, 10, 40, 1, 50, 3, 40, 3, 25, 23, 90,
38
1, 15, 29, 20, 10, 40, 1, 50, 3, 40, 3, 25, 23, 90,
39
1, 15, 29, 20, 10, 40, 1, 50, 3, 40, 3, 25, 23, 90,
40
1, 15, 29, 20, 10, 40, 1, 50, 3, 40, 3, 25, 23, 90
41
};
42
43
44
void
test
()
45
{
46
vector<double>
testData
(
testArray
,
testArray
+(14*4));
47
if
(
os_
)
48
{
49
*
os_
<<
"Unsmoothed data ("
<<
testData
.size() <<
"):\t"
;
50
copy(
testData
.begin(),
testData
.end(), ostream_iterator<double>(*
os_
,
"\t"
));
51
*
os_
<< endl;
52
}
53
54
vector<double> smoothData =
SavitzkyGolaySmoother<double>::smooth_copy
(
testData
);
55
56
if
(
os_
)
57
{
58
*
os_
<<
"Smoothed data ("
<< smoothData.size() <<
"):\t"
;
59
copy(smoothData.begin(), smoothData.end(), ostream_iterator<double>(*
os_
,
"\t"
));
60
*
os_
<< endl;
61
}
62
63
unit_assert
(smoothData.size() ==
testData
.size());
64
}
65
66
67
int
main
(
int
argc,
char
* argv[])
68
{
69
TEST_PROLOG
(argc, argv)
70
71
try
72
{
73
if
(argc>1 && !strcmp(argv[1],
"-v"
))
os_
= &cout;
74
test
();
75
}
76
catch
(exception& e)
77
{
78
TEST_FAILED
(e.what())
79
}
80
catch
(...)
81
{
82
TEST_FAILED
(
"Caught unknown exception."
)
83
}
84
85
TEST_EPILOG
86
}
testData
const TestData testData[]
Definition
CwtPeakDetectorTest.cpp:43
Std.hpp
main
int main(int argc, char *argv[])
Definition
SavitzkyGolaySmootherTest.cpp:67
os_
ostream * os_
Definition
SavitzkyGolaySmootherTest.cpp:32
test
void test()
Definition
SavitzkyGolaySmootherTest.cpp:44
testArray
const double testArray[]
Definition
SavitzkyGolaySmootherTest.cpp:35
pwiz::analysis::SavitzkyGolaySmoother::smooth_copy
static std::vector< T > smooth_copy(const std::vector< T > &data)
Definition
SavitzkyGolaySmoother.hpp:40
SavitzkyGolaySmoother.hpp
pwiz::analysis
Definition
ChromatogramList_Filter.hpp:37
pwiz::util
Definition
almost_equal.hpp:33
unit.hpp
unit_assert
#define unit_assert(x)
Definition
unit.hpp:85
TEST_EPILOG
#define TEST_EPILOG
Definition
unit.hpp:183
TEST_FAILED
#define TEST_FAILED(x)
Definition
unit.hpp:177
TEST_PROLOG
#define TEST_PROLOG(argc, argv)
Definition
unit.hpp:175
Generated by
1.9.8