DGtal-team / DGtal

Digital Geometry Tools and Algorithm Library
https://dgtal.org
GNU Lesser General Public License v3.0
370 stars 115 forks source link

testLinearStructure (dec) fails with recent Boost versions. #1268

Open rolanddenis opened 7 years ago

rolanddenis commented 7 years ago

When compiling testLinearStructure using Boost version 1.63.0 or 1.64.0, it fails with the following message:

New Block [testing 3d operators]
  [dec | primal 0-cells <-> dual 3-cells (2) | primal 1-cells <-> dual 2-cells (5) | primal 2-cells <-> dual 1-cells (4) | primal 3-cells <-> dual 0-cells (1)]
  New Block [base operators]
    d0
[primal 0-form => primal 1-form (2 => 5)]
-1  1
 0  1
 0  1
-1  0
-1  0
    d2p
[dual 2-form => dual 3-form (5 => 2)]
-1  0  0 -1 -1
 1  1  1  0  0
    [ERR] Fatal Error - assertion (Eigen::MatrixXd(d0.myContainer) == d0_th) failed in void test_manual_operators_3d(): /scratch/denis/DGtal/tests/dec/testLinearStructure.cpp(391)
Abandon (core dumped)

The related code https://github.com/DGtal-team/DGtal/blob/master/tests/dec/testLinearStructure.cpp#L391 suggests that the primal 0-form should instead be:

d0_th <<
    -1, 0,
    -1, 0,
    -1, 1,
     0, 1,
     0, 1;

It is indeed the case when using Boost 1.58.0.

Tested with GNU 5.4.1, 6.2.0 and 7.1.1, with Eigen 3.3.3 and 3.3.4.

dcoeurjo commented 3 years ago

Looks ok with the last boost 1.75. Should we keep this issue open?

rolanddenis commented 3 years ago

Still fails on my side with GCC 10.2.0, Eigen 3.3.9 and Boost 1.75.0 ... Does it work on your side ?

dcoeurjo commented 3 years ago

Ok so the problem does not come from boost 1.75 itself, maybe a combo GCC10+boost1.75. (clang+boost1.75 is fine).

rolanddenis commented 3 years ago

Fails also with LLVM 10.0.0, Boost 1.75.0 and Eigen 3.3.9 (Ubuntu), strange...

rolanddenis commented 3 years ago

I cannot test on Boost 1.58.0 anymore but looking at code of DiscreteExteriorCalcul shows that it depends on Boost for boost::array and boost::unordered_map. Naively replacing boost::unordered_map by std::map to define myProperties leads to another, but still invalid, result. Using std::unordered_map leads to a correct result for this specific comparison but another one fails just after.

It behaves like something is implementation dependent...

rolanddenis commented 3 years ago

In DiscreteExteriorCalculus::updateIndexes, index associated to each cell depends on the read order of myCellProperties. In DiscreteExteriorCalculus::derivative, this index is used as column index to fill the resulting sparse array, thus invalidating comparison in testLinearStructure with hard coded expected result.