The timeseries class stores vectors of regularly repeated observations. The design is intended to accomodate various frequencies of observation, although only MONTHLY is currently implemented. Associated with the vector of observations is a start-date expressed as a year and a period withing that year (month, 1=January). The data vector can be internal, or external. In the latter case, the extent of the timeseries can not be modified.
Methods
Creation/Destruction
adco_TimeSeries( int NumObs, int SYear, int SPeriod, adco_cEnumElem freq, double* Values = NULL, int maxobs = 0 );
Create a timeseries with the specfied number of observations utilizing the supplied vector of Values. Pre-Allocate maxobs observations worth of storage (zero = use internal default).
adco_TimeSeries( const adco_TimeSeries& ts, int newlength = 0 );
Copy a timeseries, allocating newlength internal storage.
True if the observations are stored in an internally allocated vector.
Value Extraction
double* Values() const { return mValues; }
Retrieve a pointer to the values vector.
int GetIdx( int year, int period ) const;
Calculate the offset in the values vector of the specified date. Can throw an invalid index error.
int GetRawIdx( int year, int period ) const;
Calculate the offset in the values vector of the specified date. Can be outside the actual vector, including negative indices.
double GetVal( int year, int period ) const;
Get the value corresponding to the supplied date.
void GetVal( int year, int period, double* vec, int NumObs ) const;
Copy NumObs values into the supplied vector starting at the specified date. Can throw an invalid index error.
Value Modification
void SetVal( int year, int period, double value, int NumObs = 1 );
Replace the value(s) beginning at the specified date for NumObs periods. SetVal can extend the range of the timeseries, but cannot leave any "gaps" in the data.
void SetVal( int year, int period, double* vec, int NumObs );
Replace the value(s) beginning at the specifed date for the NumObs periods. SetVal can extend the range of the timeseries, but cannot leave any "gaps" in the data.
void SetVal( int year, int period, const adco_TimeSeries& TS, int NumObs = 0 );
Replace the values starting at the specified date, copying corresponding elements of the supplied.timeseries.
void SetValFromList( int year, int period, const double* vec );
Set values starting in the specified period. vec is a list of {count, value} pairs terminated by a zero count.
void Extend( int SYear, int SPeriod, int NumObs );
Repeat the last value of the timeseries making it NumObs long..
void Extend( int SYear, int SPeriod, int EYear, int EPeriod );
Repeat the first/last value of the timeseries as necessary to cover the specified range.
void Truncate( int NumObs );
Truncate the timeseries to the specified number of observations (must be less than the current value)..
void Truncate( int EYear, int EPeriod );
Truncate the timeseries to end in the current year. Supplied date must be less than current end date.
API INTEGRATION CODING FOR DEVELOPERS
TimeSeries Class: adco_TimeSeries
Description
The timeseries class stores vectors of regularly repeated observations. The design is intended to accomodate various frequencies of observation, although only MONTHLY is currently implemented. Associated with the vector of observations is a start-date expressed as a year and a period withing that year (month, 1=January). The data vector can be internal, or external. In the latter case, the extent of the timeseries can not be modified.
Methods
Creation/Destruction
Properties
Value Extraction
Value Modification