CDatedData::CDatedData(const CDatedData &right, const TIndex &selectedDim) : date(right.date) { if ( selectedDim.Size() <= 0 ) data.CopyContent(right.data); else { TIndex validDim; for (int i=0; i<selectedDim.Size(); i++) { if (selectedDim[i] >=0 && selectedDim[i] < right.DataDimension()) validDim += selectedDim[i]; } data = right.data.SubVector(validDim); } }
CDatedDataSeries::CDatedDataSeries(const TDenseMatrix &date_data_matrix, const TIndex &selectedTime, const TIndex &selectedDim) { if (selectedTime.Size() <= 0) { for (int i=0; i<date_data_matrix.rows; i++) this->push_back(CDatedData(date_data_matrix.RowVector(i),selectedDim)); } else { for (int i=0; i<selectedTime.Size(); i++) { if (selectedTime[i] >= 0 && selectedTime[i] < date_data_matrix.rows) this->push_back(CDatedData(date_data_matrix.RowVector(selectedTime[i]), selectedDim)); } } }
CDatedDataSeries::CDatedDataSeries(const CDatedDataSeries &right, const TIndex &selectedTime, const TIndex &selectedDim) { if (selectedTime.Size() <= 0) { for (int i=0; i<right.ObservationLength(); i++) this->push_back(CDatedData(right[i],selectedDim)); } else { for (int i=0; i<selectedTime.Size(); i++) { if (selectedTime[i] >=0 && selectedTime[i] < (int)(right.size()) ) this->push_back(CDatedData(right[selectedTime[i]],selectedDim)); } } }
CDatedData::CDatedData(const CDate &_date, const TDenseVector &_data, const TIndex &selectedDim) : date(_date) { if (selectedDim.Size() <= 0) data.CopyContent(_data); else { TIndex validDim; for (int i=0; i<selectedDim.Size(); i++) { if (selectedDim[i] >=0 && selectedDim[i] < _data.Dimension()) validDim += selectedDim[i]; } data = _data.SubVector(validDim); } }
CDatedDataSeries::CDatedDataSeries(const std::vector<CDate> &date_series, const TDenseMatrix &data_matrix, const TIndex &selectedTime, const TIndex &selectedDim) { int N = (int)date_series.size() <= data_matrix.rows ? (int)date_series.size() : data_matrix.rows; if (selectedTime.Size() <= 0) { for (int i=0; i<N; i++) this->push_back(CDatedData(date_series[i],data_matrix.RowVector(i,selectedDim))); } else { for (int i=0; i<selectedTime.Size(); i++) { if (selectedTime[i] >= 0 && selectedTime[i] < N) this->push_back(CDatedData(date_series[selectedTime[i]],data_matrix.RowVector(selectedTime[i],selectedDim) )); } } }
CDatedDataSeries::CDatedDataSeries(const std::vector<CDate> &date_series, const std::vector<TDenseVector> &data_series, const TIndex &selectedTime, const TIndex &selectedDim) { int N = (int)(date_series.size() <= data_series.size() ? date_series.size() : data_series.size()); if (selectedTime.Size() <= 0) { for (int i=0; i<N; i++) this->push_back(CDatedData(date_series[i],data_series[i],selectedDim)); } else { for (int i=0; i<selectedTime.Size(); i++) { if (selectedTime[i] >= 0 && selectedTime[i] < N) this->push_back(CDatedData(date_series[selectedTime[i]], data_series[selectedTime[i]], selectedDim)); } } }
std::vector<CDate> CDatedDataSeries::GetDateSeries(const TIndex &selectedTime) const { std::vector<CDate> date_series; if (selectedTime.Size() <= 0) { for (int i=0; i<ObservationLength(); i++) date_series.push_back(this->operator[](i).GetDate()); } else { for (int i=0; i<selectedTime.Size(); i++) { if (selectedTime[i] >= 0 || selectedTime[i] < ObservationLength()) date_series.push_back(this->operator[](selectedTime[i]).GetDate()); } } return date_series; }
std::vector<TDenseVector> CDatedDataSeries::GetDataSeries_Vector(const TIndex &selectedTime, const TIndex &selectedDim) const { std::vector<TDenseVector> data_series; if (selectedTime.Size() <= 0) { for (int i=0; i<ObservationLength(); i++) data_series.push_back(this->operator[](i).GetData(selectedDim)); } else { for (int i=0; i<selectedTime.Size(); i++) { if (selectedTime[i] >= 0 && selectedTime[i] < ObservationLength()) data_series.push_back(this->operator[](selectedTime[i]).GetData(selectedDim)); } } return data_series; }
CDatedData::CDatedData(const TDenseVector &date_data, const TIndex &selectedDim) : date(date_data) { if (date_data.Dimension() > 3) // there are data besides date { if (selectedDim.Size() <= 0) data = date_data.SubVector(3,date_data.Dimension()-1); else { TIndex validDim; for (int i=0; i<selectedDim.Size(); i++) { if (selectedDim[i] >= 3 && selectedDim[i] < date_data.Dimension()) validDim += selectedDim[i]; } data = date_data.SubVector(validDim); } } }