Commit e9e82494 authored by Ludovic Courtès's avatar Ludovic Courtès

core: vertical_segment: Fix the multiple-argument 'get' method.

Partly fixes a regression introduced in f8843e56.
Reported by Laurent BELCOUR <laurent.belcour@gmail.com>
at <http://lists.gforge.inria.fr/pipermail/alta-devel/2017-January/000746.html>.
parent 431aba86
......@@ -108,36 +108,28 @@ void vertical_segment::get(int i, vec& x, vec& yl, vec& yu) const
// Make sure we have the lower and upper bounds of Y.
assert(confidence_interval_kind() == ASYMMETRICAL_CONFIDENCE_INTERVAL);
auto matrix = matrix_view();
auto row = matrix_view().row(i);
#ifdef DEBUG
assert(i >= 0 && i < matrix.size());
#endif
x.resize(_parameters.dimX()); yl.resize(_parameters.dimY()) ; yu.resize(_parameters.dimY()) ;
for(int j=0; j<_parameters.dimX(); ++j)
{
x[j] = matrix(i, j);
}
for(int j=0; j<_parameters.dimY(); ++j)
{
yl[j] = matrix(i, _parameters.dimX() + 1*_parameters.dimY() + j);
yu[j] = matrix(i, _parameters.dimX() + 2*_parameters.dimY() + j);
}
x.resize(_parameters.dimX());
x = row.segment(0, _parameters.dimX()).transpose();
auto y = row.segment(_parameters.dimX(), _parameters.dimY()).transpose();
yl.resize(_parameters.dimY()); yu.resize(_parameters.dimY());
yl = row.segment(_parameters.dimX() + _parameters.dimY(),
_parameters.dimY()).transpose();
yl += y;
yu = row.segment(_parameters.dimX() + 2 * _parameters.dimY(),
_parameters.dimY()).transpose();
yu += y;
}
void vertical_segment::get(int i, vec& yl, vec& yu) const
{
// Make sure we have the lower and upper bounds of Y.
assert(confidence_interval_kind() == ASYMMETRICAL_CONFIDENCE_INTERVAL);
auto matrix = matrix_view();
yl.resize(_parameters.dimY()) ; yu.resize(_parameters.dimY()) ;
for(int j=0; j<_parameters.dimY(); ++j)
{
yl[j] = matrix(i, _parameters.dimX() + _parameters.dimY() + j);
yu[j] = matrix(i, _parameters.dimX() + 2*_parameters.dimY() + j);
}
vec x;
get(i, x, yl, yu);
}
vec vertical_segment::get(int i) const
......
......@@ -71,6 +71,16 @@ static void test_simple_load_from_text()
TEST_ASSERT(data->get(1) == Eigen::Vector4d(4., 5., 6., 7.));
TEST_ASSERT(data->get(2) == Eigen::Vector4d(8., 9., 10., 11.));
// Check the result of the other 'get' methods.
vec x, y_lower, y_upper;
data->get(1, x, y_lower, y_upper);
TEST_ASSERT(x == Eigen::VectorXd::Constant(1, 4.));
TEST_ASSERT(y_lower == Eigen::Vector3d(5., 6., 7.));
TEST_ASSERT(y_lower == y_upper);
data->get(1, y_lower, y_upper);
TEST_ASSERT(y_lower == Eigen::Vector3d(5., 6., 7.));
TEST_ASSERT(y_lower == y_upper);
// The "matrix view" includes confidence interval data.
auto view = data->matrix_view();
TEST_ASSERT(view.cols() == 1 + 3 + 2 * 3);
......
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