Multiprecison Support

Issue #174 resolved
Zhen Zhong created an issue

support boost multiprecison lib https://github.com/boostorg/multiprecision

Comments (5)

  1. Klaus Iglberger

    Hi Dysis!

    Thanks to the completely generic backend of Blaze, the Boost multiprecision library is already supported by Blaze. For instance, the following addition of two int128_t matrices works out of the box:

    DynamicMatrix<mp::int128_t> A{ { 1, 2 }, { 3, 4 } };
    DynamicMatrix<mp::int128_t> B{ { 1, 2 }, { 3, 4 } };
    
    DynamicMatrix<mp::int128_t> C( A + B );
    
    std::cout << "\n C =\n" << C << "\n\n";
    

    Output:

     C =
    (            2            4 )
    (            6            8 )
    

    Best regards,

    Klaus!

  2. Zhen Zhong reporter

    Indeed it not always work well. I need to add many many traits by myself.

    using complex_t = number<mpc_complex_backend<113>, et_off>;
    using scalar_t = complex_t::value_type;
     template<>
        struct UnderlyingNumeric<scalar_t>
        {
            using Type = scalar_t;
        };
    
        template<>
        struct UnderlyingNumeric<complex_t>
        {
            using Type = complex_t;
        };
    
        template<>
        struct UnderlyingBuiltin<scalar_t>
        {
            using Type = scalar_t;
        };
    
        template<>
        struct UnderlyingBuiltin<complex_t>
        {
            using Type = complex_t;
        };
    
        template<>
        struct UnderlyingElement<scalar_t>
        {
            using Type = scalar_t;
        };
    
        template<>
        struct UnderlyingElement<complex_t>
        {
            using Type = scalar_t;
        };
    
    
        template<>
        struct IsNumeric<scalar_t>
        {
            static constexpr bool value = true;
        };
    
        template<>
        struct IsNumeric<complex_t>
        {
            static constexpr bool value = true;
        };
    

    I need to add_definitions(-DBLAZE_USE_VECTORIZATION=0) or it will compile error in pow(A, 2) and so on. Maybe you need to add some tests for custom numeric type.

  3. Klaus Iglberger

    Hi Dysis!

    You are correct. In order to provide support for the Boost Multiprecision Library (MPL) for all possible operations requires you to add several specializations for Blaze type traits. This is our idea of enabling users of Blaze to use any kind of custom data type. Apparently your idea of supporting the MPL is that we should provide all necessary specializations ourselves. We apologize for the misunderstanding.

    We have created issue #176 as a follow-up, which specifies the requirements in detail. Since we feel that this would be an interesting, but non-essential addition we have given the issue a minor priority, though. Thanks for the clarification,

    Best regards,

    Klaus!

  4. Log in to comment