Boost matrix product for multiprecision numbers

506 Views Asked by At

I am trying to implement some high precision calculations in C++ using Boost.Multiprecision and Boost.uBLAS, in VS 2010 Express. However even in the simplest case my code fails to compile, giving the following error:

error C2677: binary '+=' : no global operator found which takes type 'boost::multiprecision::detail::expression' (or there is no acceptable conversion) c:\program files (x86)\boost_1_53_0\boost\numeric\ublas\functional.hpp 1176

#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/numeric/ublas/matrix.hpp>

using namespace boost::multiprecision;   
using namespace boost::numeric::ublas;

int main(int, char**)
{
  matrix<number<cpp_dec_float<50> > > m (3, 3);
  matrix<number<cpp_dec_float<50> > > E (3, 3);

  E=prod(E,m);

  return 0;

}

The line that the compiler complains about is in ublas's functional.hpp:

 template<class E1, class E2>
 static BOOST_UBLAS_INLINE
 result_type apply (const matrix_expression<E1> &e1,
                    const matrix_expression<E2> &e2,
                    size_type i, size_type j) {
   size_type size = BOOST_UBLAS_SAME (e1 ().size2 (), e2 ().size1 ());
   result_type t = result_type (0);
   for (size_type k = 0; k < size; ++ k)
      t += e1 () (i, k) * e2 () (k, j); //here the error arises
   return t;
 }

I am using a number<cpp_dec_float<50> > as a type for high precision floating point number, instantiate two matrices E and m - this works just fine. However if I try to multiply them using prod, the code fails to compile. Multiprecision FAQ available here suggests explicitly casting all arguments of prod to the high-precision type, but prod(static_cast<matrix<number<cpp_dec_float<50> > > >(E),static_cast<matrix<number<cpp_dec_float<50> > > >(m) ) doesn't help.

Any idea of what could I still be missing? Thanks in advance.

0

There are 0 best solutions below