equal<strict>() for Blaze types is not actually strict

Issue #259 resolved
Mikhail Katliar created an issue

Example:

#include <blaze/Math.h>
#include <iostream>

int main(int, char **)
{
    blaze::DynamicMatrix<double> A {
        {1.0000000001e-02}
    };

    blaze::DynamicMatrix<double> B {
        {1.0000000002e-02}
    };

    std::cout << "equal<strict>(A, B) == " << blaze::equal<blaze::strict>(A, B) << std::endl;
    std::cout << "A - B == " << A - B << std::endl;

    return 0;
}

Output:

equal<strict>(A, B) == 1
A - B == ( -9.99999e-13 )

This behavior is unexpected. The documentation says that “Based on the setting of the relaxation flag RF, the function either performs a comparison via the equality operator (blaze::strict) or or a special comparison is selected that takes the limited machine accuracy into account (blaze::relaxed).” As per #258, operator== for Blaze types does not perform strict comparison, hence equal<strict>() doesn’t either. On the other hand, equal<strict>(A, B) does look like the syntax for _strict _comparison, which is super counter-intuitive. What would be the way to do strict comparison then?

Comments (4)

  1. Klaus Iglberger

    Hi Mikhail!

    Thanks a lot for pointing out this defect. This is indeed an oversight, but luckily does not affect all Blaze types, but is restricted to the comparison of dense matrices via the equal() function. We will fix the problem as quickly as possible.

    Best regards,

    Klaus!

  2. Klaus Iglberger

    Commit 48460a0 fixes the overloads of the equal() function for the comparison of two dense matrices. The fix is immediately available via cloning the Blaze repository and will be officially released in Blaze 3.6.

  3. Log in to comment