accuracy of floating point calculations: d vs cpp

drug drug2004 at bk.ru
Mon Jul 22 17:22:24 UTC 2019


22.07.2019 17:19, drug пишет:
> 22.07.2019 16:26, Guillaume Piolat пишет:
>>>
>>> Typical floating point operations in single-precision like a simple 
>>> (a * b) + c will provide a -140dB difference if order is changed. 
>>> It's likely the order of operations is not the same in your program, 
>>> so the least significant digit should be different.
>>
>> What I would recommend is compute the mean relative error, in double, 
>> and if it's below -200 dB, not bother. This is an incredibly low 
>> relative error of 0.00000001%.
>> You will have no difficulty making your D program deterministic, but 
>> knowing exactly where the C++ and D differ will be long and serve no 
>> purpose.
> Unfortunately error has been turned out to be much bigger than I guessed 
> before. So obviously there is a problem either on D side or on C++ side. 
> Error is too huge to ignore it.

There was a typo in C++ implementation. I did simple-n-dirt Python 
version and after the typo fixed all three implementations show the same 
result if one filter update occurs. But if several updates happen a 
subtle difference exists nevertheless, error accumulates somewhere else 
- time for numerical methods using.


More information about the Digitalmars-d-learn mailing list