1

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.

1201ProgramAlarm
  • 32,384
  • 7
  • 42
  • 56
Marko Bencik
  • 368
  • 2
  • 13
  • When compiling using Visual Studio 2019, the `prod` function requires 3 arguments, not 2. – PaulMcKenzie Oct 21 '20 at 22:14
  • Looks like UBlas simply doesn't support QVM. Did you have reason to expect otherwise? Also, I'd be stumped if ublas::prod was magically faster than just the product there – sehe Oct 21 '20 at 22:28
  • @PaulMcKenzie can you give me a example (code) how the how the prob function has 3 params? I work with gcc 7.4 and ubuntu 18.04, so a lot more advanced than visual studio – Marko Bencik Oct 22 '20 at 10:57
  • So Visual Studio C++ 2019 is less advanced than gcc?? Take the code posted, compile it as-is using boost 1.72 (that's the version I have). – PaulMcKenzie Oct 22 '20 at 11:09
  • [See the results here](https://godbolt.org/z/vfsf7j) – PaulMcKenzie Oct 22 '20 at 11:14
  • @PaulMcKenzie niether clang and gcc canot compile it tried multiple versions, so this is my guideline, VS 2019 is not catching the problem. – Marko Bencik Oct 22 '20 at 11:20
  • The point is that VS is giving you a different, less cryptic error message. What looks simpler to tackle, all that mess that g++ gives you as an error, or the Visual Studio errors? If you can go to that site, fix the VS error, then that same code will more than likely fix the g++ error. One tool that programmers use is that they use different compilers, with the secondary compiler used to verify or generate error messages that may be more understandable than their main compiler. – PaulMcKenzie Oct 22 '20 at 11:23
  • Also note that the issue is spelled out very easily -- the `prod` function requires 3 arguments. Nowhere in any of g++ messages did it mention this. So now you know *why* the error occurs. How to fix the error is a different story. – PaulMcKenzie Oct 22 '20 at 11:27
  • @PaulMcKenzie after a deep insight into the issue the idea with VS helped, but also showed the likning strategy of VS. So thnx – Marko Bencik Oct 22 '20 at 12:59

1 Answers1

0

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.

Marko Bencik
  • 368
  • 2
  • 13