ProteoWizard
preparedata.hpp
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
22#ifndef PREPAREDATA_H
23#define PREPAREDATA_H
24
25namespace ralab{
26 namespace base{
27 namespace filter{
28 namespace utilities{
29 /*!\brief
30
31 Example Sequence : 1 2 3 4 5;
32 width 5 and mirror false:
33 4 5 1 2 3 4 5 1 2,
34 if mirror true than:
35 2 1 1 2 3 4 5 5 4
36
37 */
38 template <typename TContainer ,typename TIterator>
39 typename TContainer::iterator prepareData
40 (
41 TIterator dataBeg ,
42 TIterator dataEnd ,
43 size_t fsize,
44 TContainer &res , //!< [out]
45 bool mirror = false //!< should it be circular or mirrored.
46 )
47 {
48 if(mirror)
49 {
50 typename TContainer::iterator it;
51 size_t fsize2 = (fsize-1)/2;
52 res.resize(std::distance(dataBeg,dataEnd)+fsize);
53 boost::reverse_iterator<TIterator> reverse_begin(dataEnd);
54 boost::reverse_iterator<TIterator> reverse_end(dataBeg);
55
56 it = std::copy(reverse_end - fsize2,reverse_end, res.begin() );
57 it = std::copy(dataBeg,dataEnd, it );
58 it = std::copy( reverse_begin, reverse_begin + fsize2, it);
59 return it;
60 }
61 else
62 {
63 typename TContainer::iterator it;
64 size_t fsize2 = (fsize-1)/2;
65 res.resize(std::distance(dataBeg,dataEnd)+fsize);
66 it = std::copy(dataEnd - fsize2,dataEnd, res.begin() );
67 it = std::copy(dataBeg,dataEnd, it );
68 it = std::copy( dataBeg, dataBeg + fsize2, it);
69 return it;
70 }
71 }
72 }//end utilities
73
74 }//filter
75 }//base
76}//ralab
77
78#endif // PREPAREDATA_H
TContainer::iterator prepareData(TIterator dataBeg, TIterator dataEnd, size_t fsize, TContainer &res, bool mirror=false)
Example Sequence : 1 2 3 4 5; width 5 and mirror false: 4 5 1 2 3 4 5 1 2, if mirror true than: 2 1 1...
void filter(const TContainer &data, const TContainer &filter, TContainer &result, bool circular=false, uint32_t sides=2)
Applies linear convolution (filtering) to a univariate time series.
Definition filter.hpp:112
EQUISPACEINTERPOL Interpolation on a equidistantly spaced grid.
Definition base.hpp:40