MCPcopy Create free account
hub / github.com/CoolProp/CoolProp / solve_quartic

Function solve_quartic

src/CPnumerics.cpp:134–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132 }
133}
134void 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
161bool SplineClass::build() {
162 if (Nconstraints == 4) {

Callers 1

spinodal_densitiesMethod · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected