| 132 | } |
| 133 | } |
| 134 | void solve_quartic(double a, double b, double c, double d, double e, int& N, double& x0, double& x1, double& x2, double& x3) { |
| 135 | |
| 136 | // 0 = ax^4 + b*x^3 + c*x^2 + d*x + e |
| 137 | |
| 138 | Eigen::PolynomialSolver<double, Eigen::Dynamic> solver; |
| 139 | Eigen::VectorXd coeff(5); |
| 140 | coeff << e, d, c, b, a; |
| 141 | solver.compute(coeff); |
| 142 | |
| 143 | std::vector<double> realRoots; |
| 144 | solver.realRoots(realRoots); |
| 145 | N = static_cast<int>(realRoots.size()); |
| 146 | |
| 147 | if (N > 0) { |
| 148 | x0 = realRoots[0]; |
| 149 | } |
| 150 | if (N > 1) { |
| 151 | x1 = realRoots[1]; |
| 152 | } |
| 153 | if (N > 2) { |
| 154 | x2 = realRoots[2]; |
| 155 | } |
| 156 | if (N > 3) { |
| 157 | x3 = realRoots[3]; |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | bool SplineClass::build() { |
| 162 | if (Nconstraints == 4) { |
no test coverage detected