Re: [eigen] again a unit test precision question

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


On Sat, 3 Jul 2010, Hauke Heibel wrote:

Anyways, the redux_8 test is failing every now and then in redux.cpp
line 105 (e.g. seed 1278148098).


and it is failing with values

6.1214e-005 and 6.10948e-005

The difference between these two values is 2e-7. The test adds 33 floats between -1 and 1. The error analysis for addition uses absolute error, not relative error, so the correct test is whether

abs(sum computed by one method - sum computed by another method) < tolerance.

For tolerance, you can use length of vector * epsilon for floats, which is bigger than 2e-7, so the error committed is fine.

and those values are probably occurring because v's values are uniform
random values from [-1,1]. I am quite bad in numerics but I assume we
are seeing such differences because of cancellation errors?

Yes.

Or is it simply addition arithmetic?

Whatever it is, I think a trivial fix would be to compute the absolute
sum. It is not the same test but in order to succeed it requires both,
the sum and the absolute value to be working.

I think we should simply change the test along the above lines.
Something like

  VERIFY_IS_MUCH_SMALLER_THAN(m1.sum() - s, Scalar(1));


Jitse



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/