这是我正在运行或更好地尝试运行的示例代码。长话短说,它没有按预期工作。
#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,但如果这不起作用,那就没有意义了。