| OLD | NEW |
| 1 // from http://tog.acm.org/resources/GraphicsGems/gems/Roots3And4.c | 1 // from http://tog.acm.org/resources/GraphicsGems/gems/Roots3And4.c |
| 2 /* | 2 /* |
| 3 * Roots3And4.c | 3 * Roots3And4.c |
| 4 * | 4 * |
| 5 * Utility functions to find cubic and quartic roots, | 5 * Utility functions to find cubic and quartic roots, |
| 6 * coefficients are passed like this: | 6 * coefficients are passed like this: |
| 7 * | 7 * |
| 8 * c[0] + c[1]*x + c[2]*x^2 + c[3]*x^3 + c[4]*x^4 = 0 | 8 * c[0] + c[1]*x + c[2]*x^2 + c[3]*x^3 + c[4]*x^4 = 0 |
| 9 * | 9 * |
| 10 * The functions return the number of non-complex roots and | 10 * The functions return the number of non-complex roots and |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 * than once. | 25 * than once. |
| 26 */ | 26 */ |
| 27 | 27 |
| 28 #include <math.h> | 28 #include <math.h> |
| 29 #include "CubicUtilities.h" | 29 #include "CubicUtilities.h" |
| 30 #include "QuadraticUtilities.h" | 30 #include "QuadraticUtilities.h" |
| 31 #include "QuarticRoot.h" | 31 #include "QuarticRoot.h" |
| 32 | 32 |
| 33 int reducedQuarticRoots(const double t4, const double t3, const double t2, const
double t1, | 33 int reducedQuarticRoots(const double t4, const double t3, const double t2, const
double t1, |
| 34 const double t0, const bool oneHint, double roots[4]) { | 34 const double t0, const bool oneHint, double roots[4]) { |
| 35 #if SK_DEBUG | 35 #ifdef SK_DEBUG |
| 36 // create a string mathematica understands | 36 // create a string mathematica understands |
| 37 // GDB set print repe 15 # if repeated digits is a bother | 37 // GDB set print repe 15 # if repeated digits is a bother |
| 38 // set print elements 400 # if line doesn't fit | 38 // set print elements 400 # if line doesn't fit |
| 39 char str[1024]; | 39 char str[1024]; |
| 40 bzero(str, sizeof(str)); | 40 bzero(str, sizeof(str)); |
| 41 sprintf(str, "Solve[%1.19g x^4 + %1.19g x^3 + %1.19g x^2 + %1.19g x + %1.19g
== 0, x]", | 41 sprintf(str, "Solve[%1.19g x^4 + %1.19g x^3 + %1.19g x^2 + %1.19g x + %1.19g
== 0, x]", |
| 42 t4, t3, t2, t1, t0); | 42 t4, t3, t2, t1, t0); |
| 43 mathematica_ize(str, sizeof(str)); | 43 mathematica_ize(str, sizeof(str)); |
| 44 #if ONE_OFF_DEBUG && ONE_OFF_DEBUG_MATHEMATICA | 44 #if ONE_OFF_DEBUG && ONE_OFF_DEBUG_MATHEMATICA |
| 45 SkDebugf("%s\n", str); | 45 SkDebugf("%s\n", str); |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 if (j < --num) { | 227 if (j < --num) { |
| 228 s[j] = s[num]; | 228 s[j] = s[num]; |
| 229 } | 229 } |
| 230 } else { | 230 } else { |
| 231 ++j; | 231 ++j; |
| 232 } | 232 } |
| 233 } | 233 } |
| 234 } | 234 } |
| 235 return num; | 235 return num; |
| 236 } | 236 } |
| OLD | NEW |