48 : _v{ {a - b * s + c * s * s - d * s * s * s,
49 b - 2 * c * s + 3 * d * s * s,
94 _v = { a - b * s + c * s * s - d * s * s * s,
95 b - 2 * c * s + 3 * d * s * s,
120 return _v[0] + x * (_v[1] + x * (_v[2] + x * _v[3]));
125 return _v[1] + x * (2 * _v[2] + x * 3 * _v[3]);
134 for (
auto i = 0u; i < _v.size(); ++i) {
148 for (
auto i = 0u; i < _v.size(); ++i) {
176 std::array<value_type, 4> _v = {0.0, 0.0, 0.0, 0.0};
定义一个三次多项式CubicPolynomial类,用于描述和计算三次多项式 f(x) = a + b * x + c * x^2 + d * x^3
CubicPolynomial & operator*=(const value_type &rhs)
CubicPolynomial & operator+=(const CubicPolynomial &rhs)
CubicPolynomial(const value_type &a, const value_type &b, const value_type &c, const value_type &d, const value_type &s)
void Set(const value_type &a, const value_type &b, const value_type &c, const value_type &d)
CubicPolynomial()=default
friend CubicPolynomial operator*(const value_type &lhs, CubicPolynomial rhs)
value_type Evaluate(const value_type &x) const
评估 f(x) = a + bx + cx^2 + dx^3
value_type Tangent(const value_type &x) const
使用 df/dx = b + 2cx + 3dx^2 计算正切值
void Set(const value_type &a, const value_type &b, const value_type &c, const value_type &d, const value_type &s)
friend CubicPolynomial operator+(CubicPolynomial lhs, const CubicPolynomial &rhs)
friend CubicPolynomial operator*(CubicPolynomial lhs, const value_type &rhs)
CubicPolynomial(const value_type &a, const value_type &b, const value_type &c, const value_type &d)
CubicPolynomial(const CubicPolynomial &)=default
std::array< value_type, 4 > _v