Wrong outcome from kron() with small numbers

Issue #335 resolved
kyung created an issue

After spending a day, I found a bug in kron() unless I miss something.

From the following code,

#include "blaze/Blaze.h"
#include <iostream>

using namespace blaze;

int main()
{
    DynamicVector<double> P1{0.073512780078877, 0.564448879998923, 0.350576679157777, 0.011448881656057, 0.000012778790294, 0.000000000316875, 0.000000000001194, 0.000000000000004, 0.000000000000000};

    DynamicVector<double> P2{1.0};

    std::cout << std::fixed << std::setprecision(15);
    std::cout << P1 << "\n";
    std::cout << P2 << "\n";
    std::cout << kron(P1, P2) << "\n";
};

I got the following outcome.

Please see that the last four numbers become zero.

( 0.073512780078877 )
( 0.564448879998923 )
( 0.350576679157777 )
( 0.011448881656057 )
( 0.000012778790294 )
( 0.000000000316875 )
( 0.000000000001194 )
( 0.000000000000004 )
( 0.000000000000000 )

( 1.000000000000000 )

( 0.073512780078877 )
( 0.564448879998923 )
( 0.350576679157777 )
( 0.011448881656057 )
( 0.000012778790294 )
( 0.000000000000000 )
( 0.000000000000000 )
( 0.000000000000000 )
( 0.000000000000000 )

Comments (5)

  1. Klaus Iglberger

    Hi Kyung!

    Thanks a lot for pointing out this defect. Indeed, the dense vector Kronecker product optimizes for values below a certain threshold and doesn’t perform the multiplications. This optimisation is unfortunately too aggressive. We apologize for the inconvenience and we will fix this problem as quickly as possible. Thanks again,

    Best regards,

    Klaus!

  2. Klaus Iglberger

    Commit e3318a4 resolves the runtime issues without the dense vector Kronecker product. The fix is immediately available via cloning the Blaze repository and will be officially released in Blaze 3.8.

  3. Log in to comment