|
Ublas : |
Subject: Re: [ublas] Product of scalar and diagonal matrix of integers compile error
From: Oswin Krause (Oswin.Krause_at_[hidden])
Date: 2012-10-22 12:17:22
Hi,
add the following to the compiler flags or before you include ublas:
#define BOOST_UBLAS_TYPE_CHECK=0
This will turn off the (overly restrictive) debug checks. YOu will also
notive a speedup of at least factor 2 in debug.
On 2012-10-22 17:53, George Slavov wrote:
> I have stumbled into something of a bug. I am using MSVC 2010 and
> boost 1.51.0. When compiling my code I get an error because
> internally
> a call is made to square root with an integer argument which has no
> appropriate overload. Here's a minimal example
>
> #include <iostream>
> #include <boost/numeric/ublas/matrix.hpp>
> #include <boost/numeric/ublas/banded.hpp>
> #include <boost/numeric/ublas/matrix_expression.hpp>
> #include <boost/numeric/ublas/io.hpp>
>
> int main()
> {
> Â Â namespace ublas = boost::numeric::ublas;
>
> Â Â ublas::scalar_matrix<int> A(5,5,1);
> Â Â ublas::vector<int> v(5, 0);
> Â Â v(0) = 0;
> Â Â v(1) = 1;
> Â Â v(2) = 2;
> Â Â v(3) = 3;
> Â Â v(4) = 4;
> Â Â ublas::diagonal_matrix<int> D(v.size(), v.data());
> Â Â std::cout << A << std::endl;
> Â Â std::cout << D << std::endl;
>
> Â Â ublas::matrix<int> result = ublas::prod(A,D);
> Â Â std::cout << result << std::endl;
> }
>
> It's worth noting that this only fails in a debug build. Defining
> NDEBUG causes this problem to go away. I'm guessing some sort of
> dimension checking is done internally and the square root function is
> templated according to the matrices' value types, but in my case
> that's an int. What's an appropriate workaround?
>
> Regards,
> George