SourceForge.net Logo timeSeries: timeSeries Class Library

timeSeriesArray< T > Class Template Reference
[timeSeries objects]

vector sequence of data samples spaced evenly in time More...

#include <timeSeriesArray.h>

Inherits tsBase< T >.

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

List of all members.

Public Member Functions

 timeSeriesArray (std::string varnam, dataFile &df)
 timeSeriesArray (dataDef &dd, dataFile &df)
 timeSeriesArray constructor
 timeSeriesArray (char *vn, char *sn, double t, int n)
 timeSeriesArray constructor
 timeSeriesArray (char *vn, char *sn, int n...)
 construct a timeSeriesArray from one or more timeSeries objects
tsAPtr< T > operator[] (int k) const
 index operator
const std::vector< T > operator() (double t)
timeSeriesArray< T > range (int j, int k)
timeSeriesArray< T > range (double t0, double tf)
timeSeriesArray< T > integrate ()
timeSeriesArray< T > differentiate ()
timeSeries< T > element (int i) const
 extract an element from a timeSeriesArray
timeSeriesArray< T > sqrt () const
 element-by-element square root
tsResult stddev ()
 returns standard deviation
template<class U >
timeSeriesArray< T > & operator+= (const timeSeriesArray< U > &ts)
timeSeriesArray< T > & operator+= (const T &v)
template<class U >
timeSeriesArray< T > & operator-= (const timeSeriesArray< U > &ts)
timeSeriesArray< T > & operator-= (const T &v)
template<class U >
timeSeriesArray< T > & operator*= (const timeSeriesArray< U > &ts)
timeSeriesArray< T > & operator*= (const T &v)
template<class U >
timeSeriesArray< T > & operator/= (const timeSeriesArray< U > &ts)
timeSeriesArray< T > & operator/= (const T &v)

Friends

class timeSeriesArray
class timeSeries

Related Functions

(Note that these are not member functions.)



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

Detailed Description

template<class T>
class timeSeriesArray< T >

vector sequence of data samples spaced evenly in time

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

Overview
The timeSeriesArray class encapsulates array data recorded at uniform time intervals. A timeSeriesArray object is typically constructed from a previously instantiated dataFile object. Once constructed, a timeSeriesArray object can be indexed like a normal C++ array two-dimensional array where the first index corresponds to the array element and the second index corresponds to the data sample (in the examples below, omega is a timeSeriesArray<float> object with 3 elements):
omega[0][i] >> cout;
where i is an integer index that denotes the particular data sample to be retrieved.
You can also reference a timeSeriesArray object by time instead of sample number:
omega[0](39.4) >> cout;
Assigning a value to a timeSeriesArray object is also permitted:
omega[2][53] = 43.59;
However, such an assignment modifies only the timeSeriesArray. The dataFile object retains the original data.
The following construct is also legal:
omega(25.7)
This expression returns a n-element vector (3 elements in the case of omega) evaluated at 25.7 seconds.
Note that an expression like omega[2][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.
Performance
The timeSeriesArray class is designed to operate efficiently on very large datasets. To minimize memory usage a timeSeriesArray object constructed from a dataFile does not automatically make a new copy of the underlying data. Instead, the timeSeriesArray object references the data already contained in the dataFile object.
When a timeSeriesArray is modified, the timeSeriesArray 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 timeSeriesArray object.
Caution
The timeSeriesArray class does not support the full set of operations (specifically comparisons) allowed by the timeSeries class
Examples:

campAnalysis.cpp.


Constructor & Destructor Documentation

template<class T>
timeSeriesArray< T >::timeSeriesArray ( 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>
timeSeriesArray< T >::timeSeriesArray ( dataDef dd,
dataFile df 
) [inline]

timeSeriesArray constructor

Parameters:
df a dataFile object that contains the data on which the timeSeriesArray 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>
timeSeriesArray< T >::timeSeriesArray ( char *  vn,
char *  sn,
double  t,
int  n 
) [inline]

timeSeriesArray constructor

Parameters:
vn a variable name to be associated with the timeSeriesArray
sn a "short" variable name associated with the timeSeriesArray. This field is not currently used by any of the timeSeriesArray member functions
t the sample time associated with the timeSeriesArray object
n the number of elements in the timeSeriesArray
template<class T>
timeSeriesArray< T >::timeSeriesArray ( char *  vn,
char *  sn,
int  n... 
) [inline]

construct a timeSeriesArray from one or more timeSeries objects

Parameters:
vn a variable name to be associated with the timeSeriesArray
sn a "short" variable name associated with the timeSeriesArray. This field is not currently used by any of the timeSeriesArray member functions
n the number of elements in the timeSeriesArray. This must correspond exactly to the number of timeSeries objects that follow in the argument list

This constructor takes a variable number of arguments. After the parameter n, the call expects exactly n arguments, each of which must be a pointer to a timeSeries object. Each timeSeries object must have the same length.

Returns:
returns a timeSeriesArray where each dimension of the array is constructed from a timeSeries object.
Exceptions:
Length_Error 
performance
Unlike other timeSeriesArray constructors, this function does copy data. The contents of each listed timeSeries is copied to the new timeSeriesArray.
Example:
// construct a timeSeriesArray
timeSeries<float> brake1(vsimFrame.findName("BRAKE_TORQUE1"),data);
timeSeries<float> brake2(vsimFrame.findName("BRAKE_TORQUE2"),data);
timeSeries<float> brake3(vsimFrame.findName("BRAKE_TORQUE3"),data);
timeSeries<float> brake4(vsimFrame.findName("BRAKE_TORQUE4"),data);                              
timeSeriesArray<float> brake("Brake Torques", "ybrake", 4,
                             &brake1,
                             &brake2,
                             &brake3,
                             &brake4);      

Member Function Documentation

template<class T >
template timeSeriesArray< double > timeSeriesArray< 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< int > timeSeriesArray< T >::element ( int  i  )  const [inline]

extract an element from a timeSeriesArray

Parameters:
i the index of the vector element to extract
Returns:
returns a timeSeries object containing the ith element of the timeSeriesArray
template<class T >
template timeSeriesArray< double > timeSeriesArray< 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 const vector< double > timeSeriesArray< T >::operator() ( double  t  )  [inline]

time index a vector

Parameters:
t the time
Returns:
returns a n-element vector derived by evaluating the timeSeriesArray object at time t. If t does not correspond to an exact sample time, linear interpolation is used to find an approximate value
template<class T>
timeSeriesArray<T>& timeSeriesArray< 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 >
timeSeriesArray<T>& timeSeriesArray< T >::operator*= ( const timeSeriesArray< U > &  ts  )  [inline]

Exceptions:
Dimension_error 
template<class T>
timeSeriesArray<T>& timeSeriesArray< 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 >
timeSeriesArray<T>& timeSeriesArray< T >::operator+= ( const timeSeriesArray< U > &  ts  )  [inline]

Exceptions:
Dimension_error 
template<class T>
timeSeriesArray<T>& timeSeriesArray< 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 >
timeSeriesArray<T>& timeSeriesArray< T >::operator-= ( const timeSeriesArray< U > &  ts  )  [inline]

Exceptions:
Dimension_error 
template<class T>
timeSeriesArray<T>& timeSeriesArray< 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 >
timeSeriesArray<T>& timeSeriesArray< T >::operator/= ( const timeSeriesArray< U > &  ts  )  [inline]

Exceptions:
Dimension_error 
template<class T>
tsAPtr<T> timeSeriesArray< T >::operator[] ( int  k  )  const [inline]

index operator

Parameters:
k element number
Returns:
returns a tsAPtr< T > data object representing a timeSeries array element. The tsAPtr object must be indexed by the [] or () operators to result in an l-value or an r-value
template<class T>
timeSeriesArray<T> timeSeriesArray< 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.

template<class T >
template timeSeriesArray< int > timeSeriesArray< 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.


Friends And Related Function Documentation

template<class T >
std::ostream & operator<< ( std::ostream &  os,
timeSeriesArray< T >  tsa 
) [related]

output operator for a timeSeries

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