我正在尝试boost::qvm
与boost::multiprecision
. 我构建了一个用户定义的四元数,但我无法缩放四元数。我想按多种类型对其进行缩放boost::multiprecision::cpp_dec_float_100
。贝娄是我的代码。我还用注释掉的代码尝试了它。
#include <bits/stdc++.h>
#include <boost/numeric/odeint.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/qvm.hpp>
using namespace std;
typedef boost::multiprecision::cpp_dec_float_100 fl;
struct fquat { fl a[4]; };
namespace boost { namespace qvm {
template <>
struct quat_traits<fquat>: quat_traits_defaults<fquat,fl> {
template <int I>
static inline scalar_type & write_element( fquat & q ) {
return q.a[I];
}
};
template <> struct is_scalar<fl> { static bool const value=true; };
template <> struct scalar_traits<fl>
{ BOOST_QVM_INLINE_CRITICAL static fl value( int v ) { return fl(v); }};
/*
template <>
struct deduce_quat<fquat, fl> {
typedef fquat type;
};
template <>
struct deduce_quat2<fquat, fquat, fl> {
typedef fquat type;
};
*/
} }
int main()
{
fquat q = {fl(1),fl(1),fl(1),fl(1)};
fl x = fl(3);
q *= x;
return 0;
}
我得到的错误是:
test2.cpp: In function ‘int main()’:
test2.cpp:48:7: error: no match for ‘operator*=’ (operand types are ‘fquat’ and ‘fl’ {aka ‘boost::multiprecision::number<boost::multiprecision::backends::cpp_dec_float<100> >’})
48 | q *= x;
| ~~^~~~