ProteoWizard
Namespaces | Functions
ralab::base Namespace Reference

Namespaces

 base
 
 filter
 
 ms
 
 resample
 
 stats
 
 utils
 

Functions

template<typename TIterator , typename T >
void cumsum (TIterator beg, TIterator end, std::vector< T > &res)
 
template<typename TIterator >
TIterator cumsum (TIterator beg, TIterator end)
 
template<typename T >
void cumprod (std::vector< T > &x, std::vector< T > &res)
 Returns a vector whose elements are the cumulative products of the elements of the argument. More...
 
template<typename T >
void cummax (std::vector< T > &x, std::vector< T > &res)
 Returns a vector whose elements are the cumulative maximum of the elements of the argument. More...
 
template<typename T >
void cummin (std::vector< T > &x, std::vector< T > &res)
 Returns a vector whose elements are the cumulative sums, products, minima or maxima of the elements of the argument. More...
 

Function Documentation

§ cumsum() [1/2]

template<typename TIterator , typename T >
void ralab::base::cumsum ( TIterator  beg,
TIterator  end,
std::vector< T > &  res 
)

CUMSUM Returns a vector whose elements are the cumulative sums, products, minima or maxima of the elements of the argument.

Parameters
[in]begvector of values of type T
[out]rescumulative sum

Definition at line 40 of file cumsum.hpp.

45  {
46  if(beg!=end){
47 
48  res.assign(beg,end);
49  typename std::vector<T>::iterator begRes = res.begin();
50  typename std::vector<T>::iterator begResDelayed = begRes;
51  ++begRes;
52 
53  typename std::vector<T>::iterator begEnd = res.end();
54  for( ;begRes != begEnd ; ++begRes, ++begResDelayed)
55  {
56  *begRes += *(begResDelayed) ;
57  }
58  }
59  }

§ cumsum() [2/2]

template<typename TIterator >
TIterator ralab::base::cumsum ( TIterator  beg,
TIterator  end 
)
Parameters
[in]begvector of values of type T

Definition at line 63 of file cumsum.hpp.

67  {
68  TIterator begRes = beg;
69  ++begRes;
70  for( ;begRes != end ; ++begRes, ++beg)
71  {
72  *begRes += *(beg) ;
73  }
74  return begRes;
75  }

§ cumprod()

template<typename T >
void ralab::base::cumprod ( std::vector< T > &  x,
std::vector< T > &  res 
)

Returns a vector whose elements are the cumulative products of the elements of the argument.

Parameters
[in]x
rescumulative product

Definition at line 80 of file cumsum.hpp.

83  {
84  res.resize(x.size());
85  for(size_t i = 0; i < x.size() ; ++i)
86  {
87  res[i] = x[i];
88  }
89  for(size_t i = 1; i < x.size(); ++i)
90  {
91  res[i] *= res[i-1] ;
92  }
93  }

§ cummax()

template<typename T >
void ralab::base::cummax ( std::vector< T > &  x,
std::vector< T > &  res 
)

Returns a vector whose elements are the cumulative maximum of the elements of the argument.

Parameters
[in]xvector of type T
[out]rescumulative maximum

Definition at line 97 of file cumsum.hpp.

101  {
102  res.resize(x.size());
103  for(size_t i = 0; i < x.size() ; ++i)
104  {
105  res[i] = x[i];
106  }
107  for(size_t i = 1; i < x.size(); ++i)
108  {
109  res[i] = std::max( res[i-1] , res[i]) ;
110  }
111  }

§ cummin()

template<typename T >
void ralab::base::cummin ( std::vector< T > &  x,
std::vector< T > &  res 
)

Returns a vector whose elements are the cumulative sums, products, minima or maxima of the elements of the argument.

Parameters
[in]xvector of type T
[in]rescumulative minimum

Definition at line 115 of file cumsum.hpp.

119  {
120  res.resize(x.size());
121  for(size_t i = 0; i < x.size() ; ++i)
122  {
123  res[i] = x[i];
124  }
125  for(size_t i = 1; i < x.size(); ++i)
126  {
127  res[i] = std::min( res[i-1] , res[i]) ;
128  }
129  }