Commit 2085e353 authored by Ludovic Courtès's avatar Ludovic Courtès

core: vertical_segment: Fix computation of 'yl' and 'yu' in 'get'.

parent ff854df1
/* ALTA --- Analysis of Bidirectional Reflectance Distribution Functions
Copyright (C) 2013, 2014, 2015, 2016 Inria
Copyright (C) 2013, 2014, 2015, 2016, 2017 Inria
This file is part of ALTA.
......@@ -110,20 +110,15 @@ void vertical_segment::get(int i, vec& x, vec& yl, vec& yu) const
auto row = matrix_view().row(i);
x.resize(_parameters.dimX());
x = row.segment(0, _parameters.dimX()).transpose();
x = row.segment(0, _parameters.dimX());
auto y = row.segment(_parameters.dimX(), _parameters.dimY()).transpose();
yl.resize(_parameters.dimY()); yu.resize(_parameters.dimY());
auto y = row.segment(_parameters.dimX(), _parameters.dimY());
yl = row.segment(_parameters.dimX() + _parameters.dimY(),
_parameters.dimY()).transpose();
yl += y;
_parameters.dimY());
yu = row.segment(_parameters.dimX() + 2 * _parameters.dimY(),
_parameters.dimY()).transpose();
yu += y;
_parameters.dimY());
}
void vertical_segment::get(int i, vec& yl, vec& yu) const
......
......@@ -229,6 +229,26 @@ int main(int argc, char** argv)
// confidence interval on Y.
TEST_ASSERT(vs_sample1->matrix_view() == vs_sample2->matrix_view());
TEST_ASSERT(vs_sample1->matrix_view() == vs_sample3->matrix_view());
auto dimX = sample1->parametrization().dimX();
auto dimY = sample1->parametrization().dimY();
for (auto i = 0; i < vs_sample1->size(); i++)
{
vec row = vs_sample1->matrix_view().row(i);
vec x = row.segment(0, dimX);
vec y = row.segment(dimX, dimY);
vec yl = row.segment(dimX + dimY, dimY);
vec yu = row.segment(dimX + 2 * dimY, dimY);
// Make sure the default confidence interval is used.
TEST_ASSERT(yl == y - Eigen::VectorXd::Constant(dimY, 0.1));
TEST_ASSERT(yu == y + Eigen::VectorXd::Constant(dimY, 0.1));
// Make sure this is consistent with the 'get' method.
vec x2, yl2, yu2;
vs_sample1->get(i, x2, yl2, yu2);
TEST_ASSERT(x2 == x && yl2 == yl && yu2 == yu);
}
}
CATCH_FILE_IO_ERROR(input_file);
......
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