Commit 1bceb8f6 authored by Ludovic Courtès's avatar Ludovic Courtès

core: vertical_segment: Consolidate 'Eigen::Map' creation as methods.

parent 40f0c97f
......@@ -130,13 +130,7 @@ void vertical_segment::get(int i, vec& yl, vec& yu) const
vec vertical_segment::get(int i) const
{
// Omit the confidence interval data.
auto relevant_rows = _parameters.dimX() + _parameters.dimY();
auto matrix =
Map<MatrixXd, 0, OuterStride<> >(_data.get(), relevant_rows, size(),
OuterStride<>(column_number()));
return matrix.col(i);
return data_view().col(i);
}
void vertical_segment::set(int i, const vec& x)
......@@ -146,8 +140,7 @@ void vertical_segment::set(int i, const vec& x)
if(x.size() == column_number()
|| x.size() == _parameters.dimX() + _parameters.dimY())
{
auto matrix = matrix_view();
auto row = matrix.row(i);
auto row = matrix_view().row(i);
row.head(x.size()) = x;
} else {
std::cerr << "<<ERROR>> Passing an incorrect element to vertical_segment::set" << std::endl;
......
......@@ -113,13 +113,24 @@ class vertical_segment : public data
return _parameters.dimX() + 3 * _parameters.dimY();
}
// Return a matrix view of this data.
// Return a matrix view of the data: all the Xi and Yi followed by
// confidence interval data (lower and upper bound of the Yi). Thus,
// it has (dimX + 3 * dimY) columns and SIZE rows.
Eigen::Map<Eigen::MatrixXd> matrix_view() const
{
return Eigen::Map<Eigen::MatrixXd>(_data.get(), size(),
column_number());
}
// Return a matrix view of DATA that excludes confidence interval data.
// It has (dimX + dimY) columns and SIZE rows.
Eigen::Map<Eigen::MatrixXd, 0, Eigen::OuterStride<> > data_view() const
{
return Eigen::Map<Eigen::MatrixXd, 0, Eigen::OuterStride<> >
(_data.get(), _parameters.dimX() + _parameters.dimY(), size(),
Eigen::OuterStride<>(column_number()));
}
protected: // method
//! \brief From a correct input configuration 'x' with size
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment