#include "ProcessCorrelations.h"

const double SliceProcessCorrelations::zero_cutoff = 1e-15;

void SliceProcessCorrelationsTimeZero::initialise(const std::vector<double>& prev_covariances, const std::vector<double>& covariances, const std::array<size_t, 3>& ordering)
{}

SliceProcessCorrelationsTimeZero::SliceProcessCorrelationsTimeZero(size_t size)
	:SliceProcessCorrelations(size)
{}

double SliceProcessCorrelations::get_zero_cutoff()
{
	return zero_cutoff;
}

void SliceProcessCorrelations::clean_matrix(gelib::d_matrix& mat)
{
	std::transform(mat.begin(), mat.end(), mat.begin(),
		[](double val) -> double {return  (fabs(val) > get_zero_cutoff()) ? val : 0.0; });
}

SliceProcessCorrelations::SliceProcessCorrelations(size_t size)
	:
	m_prev_slice_covariance(size, size),
	m_slice_covariance(size, size),
	m_increment_covariance(size, size),
	m_M(size, size),
	m_Mt(size, size),
	m_Chat(size, size)
{
	size_t index;
	for (size_t i = 0; i < size; ++i)
	{
		index = m_M.index(i, i);
		m_M[index] = 1.0;
		m_Mt[index] = 1.0;
	}
}

gelib::d_matrix const& SliceProcessCorrelations::get_prev_slice_covariance() const
{
	return m_prev_slice_covariance;
}

gelib::d_matrix const& SliceProcessCorrelations::get_slice_covariance() const
{
	return m_slice_covariance;
}

gelib::d_matrix const& SliceProcessCorrelations::get_increment_covariance() const
{
	return m_increment_covariance;
}

gelib::d_matrix const& SliceProcessCorrelations::get_M() const
{
	return m_M;
}

gelib::d_matrix const& SliceProcessCorrelations::get_Mt() const
{
	return m_Mt;
}

gelib::d_matrix const& SliceProcessCorrelations::get_Chat() const
{
	return m_Chat;
}
