1

这是我正在运行或更好地尝试运行的示例代码。长话短说,它没有按预期工作。

#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;
}

它给出了以下错误。

<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,

     ^~~~

基本上有很多这样的。为什么这不被接受?我需要将 qvm 转换为矩阵表达式吗?如果是怎么办?我想在将来使用 axpy_prod,但如果这不起作用,那就没有意义了。

4

1 回答 1

0

在对问题进行了深入修改后,我得出的结论是,我的问题没有想要的答案。我所做的一切都是一种交易。

问题是translate_transformerandrotate_transformer来自 boost QVM,而prod函数来自 uBlas 库。随着 boost 1.64 的开始,如何使用 boost QVM 和 uBlas 的想法发生了变化,它们被分开了。基本上,在 uBlas 中使用 QVM 矩阵的支持已经消失。

我必须在这里批评。我对提升的了解并不好,所以可能有一些方法可以以我不知道的正确方式使用它。

于 2020-10-24T12:29:41.483 回答