Lines Matching defs:eqn

1053      * Solves the cubic whose coefficients are in the <code>eqn</code>
1058 * eqn = {c, b, a, d}
1064 * @param eqn an array containing coefficients for a cubic
1068 public static int solveCubic(double eqn[]) {
1069 return solveCubic(eqn, eqn);
1073 * Solve the cubic whose coefficients are in the <code>eqn</code>
1077 * eqn = {c, b, a, d}
1082 * @param eqn the specified array of coefficients to use to solve
1089 public static int solveCubic(double eqn[], double res[]) {
1092 final double d = eqn[3];
1094 return QuadCurve2D.solveQuadratic(eqn, res);
1098 final double A = eqn[2] / d;
1099 final double B = eqn[1] / d;
1100 final double C = eqn[0] / d;
1128 if (res == eqn) {
1129 eqn = Arrays.copyOf(eqn, 4);
1153 if (res == eqn) {
1154 eqn = Arrays.copyOf(eqn, 4);
1164 num = fixRoots(eqn, res, num);
1175 // preconditions: eqn != res && eqn[3] != 0 && num > 1
1176 // This method tries to improve the accuracy of the roots of eqn (which
1182 private static int fixRoots(double[] eqn, double[] res, int num) {
1183 double[] intervals = {eqn[1], 2*eqn[2], 3*eqn[3]};
1195 // have been computed. We require that eqn[3] != 0, so eqn is a proper
1205 double xe = getRootUpperBound(eqn);
1212 res[0] = refineRootWithHint(eqn, x0, intervals[0], res[0]);
1213 res[1] = refineRootWithHint(eqn, intervals[0], intervals[1], res[1]);
1214 res[2] = refineRootWithHint(eqn, intervals[1], xe, res[2]);
1219 // fx0 = solveEqn(eqn, 3, x0); fxe = solveEqn(eqn, 3, xe)
1220 double fxe = eqn[3];
1224 double fx1 = solveEqn(eqn, 3, x1);
1237 res[0] = bisectRootWithHint(eqn, x0, x1, res[0]);
1239 res[0] = bisectRootWithHint(eqn, x1, xe, res[2]);
1245 res[0] = bisectRootWithHint(eqn, x0, xe, res[1]);
1255 // goodRoot = (abs(eqn'(res[0])) > abs(eqn'(res[1]))) ? res[0] : res[1]
1256 // where eqn' is the derivative of eqn.
1264 // roots, x must be the second one, so we evaluate eqn at x, and if
1266 // |solveEqn(eqn, 3, badRoot)| < |solveEqn(eqn, 3, x)| but this
1269 double fx = solveEqn(eqn, 3, x);
1272 double badRootVal = solveEqn(eqn, 3, badRoot);
1282 private static double refineRootWithHint(double[] eqn, double min, double max, double t) {
1286 double[] deriv = {eqn[1], 2*eqn[2], 3*eqn[3]};
1290 double y = solveEqn(eqn, 3, t);
1306 private static double bisectRootWithHint(double[] eqn, double x0, double xe, double hint) {
1311 double fx02 = solveEqn(eqn, 3, x02);
1312 double fxe2 = solveEqn(eqn, 3, xe2);
1323 fx02 = solveEqn(eqn, 3, x02);
1324 fxe2 = solveEqn(eqn, 3, xe2);
1333 return bisectRoot(eqn, x0, xe);
1336 private static double bisectRoot(double[] eqn, double x0, double xe) {
1337 double fx0 = solveEqn(eqn, 3, x0);
1340 double fm = solveEqn(eqn, 3, m);
1372 private static double solveEqn(double eqn[], int order, double t) {
1373 double v = eqn[order];
1375 v = v * t + eqn[order];
1381 * Computes M+1 where M is an upper bound for all the roots in of eqn.
1386 * Precondition: eqn must represent a cubic polynomial
1388 private static double getRootUpperBound(double[] eqn) {
1389 double d = eqn[3];
1390 double a = eqn[2];
1391 double b = eqn[1];
1392 double c = eqn[0];