Boost matrix matrix prod definition

250 views Asked by At

This is a sample code that I'm running or better trying to run. Long story short it is not working as expected.

#include <iostream>

#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/strategies/transform/matrix_transformers.hpp>
#include <boost/numeric/ublas/matrix_expression.hpp>

namespace bg = boost::geometry;
namespace trans = bg::strategy::transform;

typedef bg::model::d2::point_xy<double> point;

int main()
{
    trans::translate_transformer<double, 2, 2> translate(0.0, 1.0);
    trans::rotate_transformer<bg::degree, double, 2, 2> rotate(90);

    trans::matrix_transformer<double, 2, 2> translateRotate(
         boost::numeric::ublas::prod(rotate.matrix(), translate.matrix())
         //rotate.matrix() * translate.matrix()
        );

    point p;
    translateRotate.apply(point(0, 0), p);
    std::cout << bg::get<0>(p) << " " << bg::get<1>(p) << std::endl;
}

It gives the following error.

<source>: In function 'int main()':

<source>:18:73: error: no matching function for call to 'prod(const matrix_type&, const matrix_type&)'

          boost::numeric::ublas::prod(rotate.matrix(), translate.matrix())

                                                                         ^

In file included from <source>:5:0:

/celibs/boost_1_65_0/boost/numeric/ublas/matrix_expression.hpp:4281:5: note: candidate: template<class E1, class E2> typename   
boost::numeric::ublas::matrix_vector_binary1_traits<typename E1::value_type, E1, typename E2::value_type, E2>::result_type 
boost::numeric::ublas::prod(const boost::numeric::ublas::matrix_expression<E>&, const boost::numeric::ublas::vector_expression<E2>&, boost::numeric::ublas::unknown_storage_tag, boost::numeric::ublas::row_major_tag)

     prod (const matrix_expression<E1> &e1,

     ^~~~

Basically there are many of those. Why is this not accepted? And do I need to convert a qvm to a matrix expression? If yes how? I would like to use the axpy_prod in the future but if this does not work it is pointless.

1

There are 1 answers

0
Marko Bencik On

After a in depth revision of the problem, I came to the conclusion that there is no desired answer to my question. What ever I do there is a trade of.

The issue is that the translate_transformer and rotate_transformer are from th boost QVM and the prod function is from the uBlas library. With the begin of boost 1.64 there was a change in thinking how to use boost QVM and uBlas and they were separated.Basically the support ofr using QVM matrices in uBlas is gone.

I have to be critical here. My knowledge of boost is not good, so there are probably ways to use this the right way which I'm not aware of.