ProteoWizard
equispaceinterpolationtest.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//
22
26
27
28namespace{
29using namespace pwiz::util;
30
31 void testApproxLinearSequence()
32 {
33 std::vector<double> x, y, ys, xout, yout;
34 ralab::base::base::seq(-20.,20.,1., x);
35 y.assign(x.begin(),x.end());
36 //double (*p)(double, double) = pow;
37
38 //ralab::base::stats::runif(x.size(), y ,-2.,2. );
39 ralab::base::cumsum(y.begin(),y.end(),ys);
40
41 ralab::base::base::seq(-30.,30.,.1, xout);
42
43 yout.resize(xout.size());
45 ys.begin(),
46 ys.end(),
47 xout.begin(),
48 xout.end(),
49 yout.begin()
50 ,-20
51 );
52 yout.resize(xout.size());
53 ralab::base::base::interpolate_cosine(ys.begin(),ys.end(),
54 xout.begin(),xout.end(),yout.begin(),-20);
55
56 yout.resize(xout.size());
57 ralab::base::base::interpolate_cubic(ys.begin(),ys.end(),
58 xout.begin(),xout.end(),yout.begin(),-20);
59
60
61 ////// constant approximation //////
62 yout.resize(xout.size());
63 ralab::base::base::interpolate_Hermite(ys.begin(),ys.end() ,
64 xout.begin(),xout.end(),yout.begin(),1.,0.,-20);
65 }
66
67}//end namespace
68
69int main(int argc, char **argv) {
70testApproxLinearSequence();
71}
KernelTraitsBase< Kernel >::space_type::abscissa_type x
KernelTraitsBase< Kernel >::space_type::ordinate_type y
int main(int argc, char **argv)
void interpolate_Hermite(YInputIterator begY, YInputIterator endY, XInputIterator begX, XInputIterator endX, OutputIterator out, double tension=0, double bias=0, int start_index=0, typename std::iterator_traits< OutputIterator >::value_type epsilon=std::numeric_limits< typename std::iterator_traits< OutputIterator >::value_type >::epsilon())
Hermite interpolation on equidistantly spaced y's.
void interpolate_cubic(YInputIterator begY, YInputIterator endY, XInputIterator begX, XInputIterator endX, OutputIterator out, int start_index=0, typename std::iterator_traits< OutputIterator >::value_type epsilon=std::numeric_limits< typename std::iterator_traits< OutputIterator >::value_type >::epsilon())
cubic interpolation on equidistantly spaced y's.
void seq(TReal from, TReal to, std::vector< TReal > &result)
generates the sequence from, from+/-1, ..., to (identical to from:to).
Definition base.hpp:49
void interpolate_linear(YInputIterator begY, YInputIterator endY, XInputIterator begX, XInputIterator endX, OutputIterator out, int start_index=0, typename std::iterator_traits< OutputIterator >::value_type epsilon=std::numeric_limits< typename std::iterator_traits< OutputIterator >::value_type >::epsilon())
affine interpolation on equidistantly spaced y.
void interpolate_cosine(YInputIterator begY, YInputIterator endY, XInputIterator begX, XInputIterator endX, OutputIterator out, int start_index=0)
cosine interpolation on equidistantly spaced y.
void cumsum(TIterator beg, TIterator end, std::vector< T > &res)
Definition cumsum.hpp:40