Re: Product of scalar and diagonal matrix of integers compile error

"Oswin Krause" <[email protected]>
Newsgroups gmane.comp.lib.boost.ublas
Message-ID <[email protected]>
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

_______________________________________________
ublas mailing list
[email protected]
http://lists.boost.org/mailman/listinfo.cgi/ublas
Sent to: [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.