Class RootSolver
LICENSE
This code repository predates the concept of Open Source, and predates most licenses along such lines. As such, the official license truly is:
EULA:
The Graphics Gems code is copyright-protected. In other words, you cannot claim the text of the code as your own and resell it. Using the code is permitted in any program, product, or library, non-commercial or commercial. Giving credit is not required, though is a nice gesture. The code comes as-is, and if there are any flaws or problems with any Gems code, nobody involved with Gems - authors, editors, publishers, or webmasters - are to be held responsible. Basically, don't be a jerk, and remember that anything free comes with no guarantee.
Roots3And4.c
Utility functions to find cubic and quartic roots, coefficients are passed like this:
c[0] + c[1]*x + c[2]*x^2 + c[3]*x^3 + c[4]*x^4 = 0
The functions return the number of non-complex roots and put the values into the s array.
Author: Jochen Schwarze (schwarze@isa.de)
Jan 26, 1990 Version for Graphics Gems
Oct 11, 1990 Fixed sign problem for negative q's in SolveQuartic
(reported by Mark Podlipec),
Old-style function definitions,
IsZero() as a macro
Nov 23, 1990 Some systems do not declare acos() and cbrt() in
<math.h>, though the functions exist in the library.
If large coefficients are used, EQN_EPS should be
reduced considerably (e.g. to 1E-30), results will be
correct but multiple roots might be reported more
than once.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intsolveCubic(double c3, double c2, double c1, double c0, double[] results) static intsolveQuadric(double c2, double c1, double c0, double[] results, int resultIndex) static intsolveQuartic(double c4, double c3, double c2, double c1, double c0, double[] results)
-
Field Details
-
M_PI
public static final double M_PI- See Also:
-
EQN_EPS
public static final double EQN_EPS- See Also:
-
-
Constructor Details
-
RootSolver
public RootSolver()
-
-
Method Details
-
solveQuadric
public static int solveQuadric(double c2, double c1, double c0, double[] results, int resultIndex) -
solveCubic
public static int solveCubic(double c3, double c2, double c1, double c0, double[] results) -
solveQuartic
public static int solveQuartic(double c4, double c3, double c2, double c1, double c0, double[] results)
-