TS++ library: time series library

◆ trim_to_nsamples()

template<typename T >
void ts::TimeSeriesCollection< T >::trim_to_nsamples ( )

Trim to same number of samples.

Set length of all time series to smallest found in collection.

Definition at line 223 of file tscollection.h.

224  {
225  this->synchronize_nsamples();
226  if (this->size() > 1)
227  {
228  // find smallest number of samples in collection
229  typename Tbase::iterator i_series=this->begin();
230  Theader header=i_series->header;
231  unsigned int nsamples=header.nsamples;
232  ++i_series;
233  while (i_series != this->end())
234  {
235  header=i_series->header;
236  unsigned int thisnsamples=header.nsamples;
237  nsamples = thisnsamples < nsamples ? thisnsamples : nsamples;
238  ++i_series;
239  }
240 
241  // adjust number of samples
242  i_series=this->begin();
243  while (i_series != this->end())
244  {
245  i_series->header.nsamples = nsamples;
246  i_series->setlastindex(i_series->f()+nsamples-1);
247  ++i_series;
248  }
249  }
250  } // void TimeSeriesCollection<T>::trim_to_nsamples()
void synchronize_nsamples()
Synchronize header with series.
Definition: tscollection.h:158