Product of scalar and diagonal matrix of integers compile error

George Slavov <[email protected]>
Newsgroups gmane.comp.lib.boost.ublas
Message-ID <CALNdZVKOzYNLDzAe1i==wp-f4Hu6ByT9BhxFfAKX+9hx3VbcaA@mail.gmail.com>
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.