Example #1
0
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);
	}
}
Example #2
0
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)); 
		}
	}	
}
Example #3
0
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)); 
		}
	}
}
Example #4
0
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); 
	}
}
Example #5
0
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) )); 	
		}
	}
}
Example #6
0
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)); 
		}
	}
}
Example #7
0
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; 
}
Example #8
0
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; 
}
Example #9
0
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); 
		}
	}
}