SourceForge.net Logo timeSeries: timeSeries Class Library

timeSeries< T > Class Template Reference
[timeSeries objects]

a scalar sequence of data samples spaced evenly in time More...

#include <timeSeries.h>

Inherits tsBase< T >.

Collaboration diagram for timeSeries< T >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 timeSeries (std::string varnam, dataFile &df)
 timeSeries (dataDef &dd, dataFile &df)
 timeSeries (const char *vn, const char *sn, double t)
tsVal< T > operator[] (int k) const
const T operator() (double t)
timeSeries< T > range (int j, int k)
timeSeries< T > range (double t0, double tf)
timeSeries< T > range (state &s)
timeSeries< T > duplicate () const
timeSeries< T > integrate ()
timeSeries< T > differentiate ()
timeSeries< T > sqrt () const
 element-by-element square root
int min () const
 returns index of the minimum value
int max () const
 returns index of the maximum value
tsResult stddev ()
 returns standard deviation
template<class U >
timeSeries< T > & operator+= (const timeSeries< U > &ts)
timeSeries< T > & operator+= (const T &v)
template<class U >
timeSeries< T > & operator-= (const timeSeries< U > &ts)
timeSeries< T > & operator-= (const T &v)
template<class U >
timeSeries< T > & operator*= (const timeSeries< U > &ts)
timeSeries< T > & operator*= (const T &v)
template<class U >
timeSeries< T > & operator/= (const timeSeries< U > &ts)
timeSeries< T > & operator/= (const T &v)
template<class U >
boolResult operator> (const timeSeries< U > &ts) const
boolResult operator> (const T &v) const
template<class U >
boolResult operator< (const timeSeries< U > &ts) const
boolResult operator< (const T &v) const
template<class U >
boolResult operator== (const timeSeries< U > &ts) const
boolResult operator== (const T &v) const
template<class U >
boolResult operator!= (const timeSeries< U > &ts) const
boolResult operator!= (const T &v) const
template<class U >
boolResult operator>= (const timeSeries< U > &ts) const
boolResult operator>= (const T &v) const
template<class U >
boolResult operator<= (const timeSeries< U > &ts) const
boolResult operator<= (const T &v) const
timeSeries< T > operator>> (const unsigned int n) const
timeSeries< T > operator<< (const unsigned int n) const
template<class U >
 operator timeSeries< U > () const

Friends

class timeSeriesArray
class timeSeries

Related Functions

(Note that these are not member functions.)



template<class T , class U >
const timeSeries< T > operator+ (const timeSeries< T > &lhs, const U &rhs)
template<class T , class U >
const timeSeries< T > operator- (const timeSeries< T > &lhs, const U &rhs)
template<class T , class U >
const timeSeries< T > operator* (const timeSeries< T > &lhs, const U &rhs)
template<class T , class U >
const timeSeries< T > operator/ (const timeSeries< T > &lhs, const U &rhs)
template<class T >
std::ostream & operator<< (std::ostream &os, timeSeries< T > ts)

Detailed Description

template<class T>
class timeSeries< T >

a scalar sequence of data samples spaced evenly in time

T is the base type of the timeSeries object. T must be one of char, short, int, float or double.

Overview
The timeSeries class encapsulates data recorded at uniform time intervals. A timeSeries object is typically constructed from a previously instantiated dataFile object. Once constructed, a timeSeries object can be indexed like a normal C++ array (in the examples below, tsvar is a timeSeries<float> object):
    tsvar[i] >> cout;
where i is an integer index that denotes the particular data sample to be retrieved.
You can also reference a timeSeries object by time instead of sample number:
    tsvar(39.4) >> cout;
Assigning a value to a timeSeries object is also permitted:
    tsvar[53] = 43.59;
However, such an assignment modifies only the timeSeries. The dataFile object retains the original data.
Note that an expression like tsvar[53] does not return an ordinay float. It returns a tsVal object, which is also defined here. When used as a r-value, a tsVal object is silently converted to the appropriate type. When used as an l-value, the tsVal class implements an automatic copy-on-write scheme. However, for all purposes, a tsVal object can and should be treated as an ordinary data type.
timeSeries objects may be assigned using = as in:
    timeSeries<float> tsvar2 = tsvar1;
Assignment operations are both space and time efficient -- no data is copied.
Performance
The timeSeries class is designed to operate efficiently on very large datasets. To minimize memory usage a timeSeries object constructed from a dataFile does not automatically make a new copy of the underlying data. Instead, the timeSeries object references the data already contained in the dataFile object.
When a timeSeries is modified, the timeSeries class implements a copy-on-write mechanism that makes a duplicate of the underlying data the first time it is modified. No user intervention is required and the copy-on-write operation is transparent to the user. However, depending on the size of the data set, there may be a substantial performance penalty for the first write access to a timeSeries object.
Examples:

camp_utilities.h, campAnalysis.cpp, campVIRTTEXAnalysis.cpp, hmi04.cpp, hmi04.h, hmi04_utilities.cpp, and hmi04_utilities.h.


Constructor & Destructor Documentation

template<class T>
timeSeries< T >::timeSeries ( std::string  varnam,
dataFile df 
) [inline]

timeSeries constructor

Parameters:
df a dataFile object that contains the data on which the timeSeries will be based
varnam a string that selects the field contained in the dataFile that will be used to construct the timeSeries object
Exceptions:
BadDimension 
template<class T>
timeSeries< T >::timeSeries ( dataDef dd,
dataFile df 
) [inline]

timeSeries constructor

Parameters:
df a dataFile object that contains the data on which the timeSeries will be based
dd a dataDef object that selects the field contained in the dataFile that will be used to construct the timeSeries object
Exceptions:
BadDimension 
template<class T>
timeSeries< T >::timeSeries ( const char *  vn,
const char *  sn,
double  t 
) [inline]

timeSeries constructor

Parameters:
vn a variable name to be associated with the timeSeries
sn a "short" variable name associated with the timeSeries. This field is not currently used by any of the timeSeries member functions
t the sample time associated with the timeSeries object

Member Function Documentation

template<class T >
template timeSeries< double > timeSeries< T >::differentiate (  )  [inline]

numerical differntiation

Returns:
a timeSeries object

performs differentiation by central differences and returns a new timeSeries containing the result. The original timeSeries object is not modified.

template<class T >
template timeSeries< char > timeSeries< T >::duplicate (  )  const [inline]
Returns:
a new timeSeries object containing a copy of the original data
template<class T >
template timeSeries< double > timeSeries< T >::integrate (  )  [inline]

numerical integration

Returns:
a timeSeries object

performs trapezoidal integration and returns a new timeSeries containing the result. The original timeSeries object is not modified.

template<class T>
template<class U >
timeSeries< T >::operator timeSeries< U > (  )  const [inline]

timeSeries conversion

Convert a timeSeries object from one base type to another

template<class T>
boolResult timeSeries< T >::operator!= ( const T &  v  )  const [inline]

not equals

Parameters:
v is a scalar
Returns:
returns a boolResult object with each element in the boolResult calculated from an element-by-element comparsion of the timeSeries with the scalar
template<class T>
template<class U >
boolResult timeSeries< T >::operator!= ( const timeSeries< U > &  ts  )  const [inline]

not equals

Parameters:
ts a timeSeries
Exceptions:
Length_error 
Returns:
returns a boolResult object with each element in the boolResult calculated from an element-by-element comparsion
template<class T >
template const double timeSeries< T >::operator() ( double  t  )  [inline]

index by time

Parameters:
t time
Returns:
returns a tsVal< T > data object representing the value of the timeSeries at time t. The tsVal object will be silenty converted to type T when used in an expression.

() performs automatic range-checking but unlike [] it returns a value at the end of the range if t is out of bounds. No exception is thrown. If the t does not correspond to a data sample, a linear interpolation between samples is returned.

template<class T>
timeSeries<T>& timeSeries< T >::operator*= ( const T &  v  )  [inline]

assign-product operator

Parameters:
v a scalar
Returns:
returns an element-by-element product of the object and the scalar v
template<class T>
template<class U >
timeSeries<T>& timeSeries< T >::operator*= ( const timeSeries< U > &  ts  )  [inline]

assign-product operator

Parameters:
ts a timeSeries
Returns:
returns an element-by-element product of the object and ts
Exceptions:
Length_error 
template<class T>
timeSeries<T>& timeSeries< T >::operator+= ( const T &  v  )  [inline]

assign-sum operator

Parameters:
v a scalar
Returns:
returns an element-by-element sum of the object and the scalar v
template<class T>
template<class U >
timeSeries<T>& timeSeries< T >::operator+= ( const timeSeries< U > &  ts  )  [inline]

assign-sum operator

Parameters:
ts a timeSeries
Returns:
returns an element-by-element sum of the object and ts
Exceptions:
Length_error 
template<class T>
timeSeries<T>& timeSeries< T >::operator-= ( const T &  v  )  [inline]

assign-difference operator

Parameters:
v a scalar
Returns:
returns an element-by-element difference of the object and the scalar v
template<class T>
template<class U >
timeSeries<T>& timeSeries< T >::operator-= ( const timeSeries< U > &  ts  )  [inline]

assign-difference operator

Parameters:
ts a timeSeries
Returns:
returns an element-by-element difference of the object and ts
Exceptions:
Length_error 
template<class T>
timeSeries<T>& timeSeries< T >::operator/= ( const T &  v  )  [inline]

assign-quotient operator

Parameters:
v a scalar
Returns:
returns an element-by-element quotient of the object and the scalar v
template<class T>
template<class U >
timeSeries<T>& timeSeries< T >::operator/= ( const timeSeries< U > &  ts  )  [inline]

assign-quotient operator

Parameters:
ts a timeSeries
Returns:
returns an element-by-element quotient of the object and ts
Exceptions:
Length_error 
template<class T>
boolResult timeSeries< T >::operator< ( const T &  v  )  const [inline]

less than

Parameters:
v a scalar
Returns:
returns a boolResult
template<class T>
template<class U >
boolResult timeSeries< T >::operator< ( const timeSeries< U > &  ts  )  const [inline]

less than

Parameters:
ts a timeSeries
Returns:
returns a boolResult
Exceptions:
Length_error 
template<class T>
timeSeries<T> timeSeries< T >::operator<< ( const unsigned int  n  )  const [inline]

shift

Shift a timeSeries left by n samples. When new values are shifted in, they are set to zero.

Currently, the entire timeSeries shifted, even if a subrange is the target.

Parameters:
n the number of samples to shift the time series
Returns:
a timeSeries shifted by n samples
template<class T>
boolResult timeSeries< T >::operator<= ( const T &  v  )  const [inline]

less than or equal

Parameters:
v a scalar
Returns:
returns a boolResult
template<class T>
template<class U >
boolResult timeSeries< T >::operator<= ( const timeSeries< U > &  ts  )  const [inline]

less than or equal

Parameters:
ts a timeSeries
Returns:
returns a boolResult
Exceptions:
Length_error 
template<class T>
boolResult timeSeries< T >::operator== ( const T &  v  )  const [inline]

equals

Parameters:
v is a scalar
Returns:
returns a boolResult object with each element in the boolResult calculated from an element-by-element comparsion of the timeSeries with the scalar
template<class T>
template<class U >
boolResult timeSeries< T >::operator== ( const timeSeries< U > &  ts  )  const [inline]

equals

Parameters:
ts a timeSeries
Exceptions:
Length_error 
Returns:
returns a boolResult object with each element in the boolResult calculated from an element-by-element comparsion
template<class T>
boolResult timeSeries< T >::operator> ( const T &  v  )  const [inline]

greater than

Parameters:
v a scalar
Returns:
returns a boolResult
template<class T>
template<class U >
boolResult timeSeries< T >::operator> ( const timeSeries< U > &  ts  )  const [inline]

greater than

Parameters:
ts a timeSeries
Returns:
returns a boolResult
Exceptions:
Length_error 
template<class T>
boolResult timeSeries< T >::operator>= ( const T &  v  )  const [inline]

greater than or equal

Parameters:
v a scalar
Returns:
returns a boolResult
template<class T>
template<class U >
boolResult timeSeries< T >::operator>= ( const timeSeries< U > &  ts  )  const [inline]

greater than or equal

Parameters:
ts a timeSeries
Returns:
returns a boolResult
Exceptions:
Length_error 
template<class T>
timeSeries<T> timeSeries< T >::operator>> ( const unsigned int  n  )  const [inline]

shift

Shift a timeSeries right by n samples. When new values are shifted in, they are set to zero.

Currently, the entire timeSeries shifted, even if a subrange is the target.

Parameters:
n the number of samples to shift the time series
Returns:
a timeSeries shifted by n samples
template<class T>
tsVal<T> timeSeries< T >::operator[] ( int  k  )  const [inline]

index operator

Parameters:
k sample number
Returns:
returns a tsVal< T > data object representing the value of the timeSeries at sample k. The tsVal object will be silenty converted to type T when used in an expression.
Exceptions:
OutOfRange [] performs automatic range-checking and will throw an exception if the index value is out of range.
template<class T>
timeSeries<T> timeSeries< T >::range ( state s  )  [inline]
Parameters:
s state
Returns:
a timeSeries object formed from the subrange defined by the state s

States are simply pairs of indices that define a region. They usually arise from searches on stateFlag objects. Subranges are created by reference. No data is copied or moved.

Reimplemented in stateFlag.

template<class T>
timeSeries<T> timeSeries< T >::range ( double  t0,
double  tf 
) [inline]
Parameters:
t0 begining time
tf ending time
Returns:
a timeSeries object corresponding approximately to the range [t0,tf]. If t0 or tf do not correspond exactly to a sample time, the nearest sample is used.

Subranges are created by reference. No data is copied or moved.

Reimplemented in stateFlag.

template<class T >
template timeSeries< char > timeSeries< T >::range ( int  j,
int  k 
) [inline]
Parameters:
j begining sample
k ending sample
Returns:
a timeSeries object corresponding to the range [j,k]

Subranges are created by reference. No data is copied or moved.

Reimplemented in stateFlag.

Generated on Tue Mar 16 15:10:52 2010 for timeSeries by  doxygen 1.6.3