Polynomial solver. More...
Macros | |
#define | SWAPD(a, b) do { double tmp = b ; b = a ; a = tmp ; } while(0) |
Functions | |
double | MAXD (double a, double b) |
uint32_t | solve_quadratic (double a, double b, double c, double *x0, double *x1) |
Solve quadric equation a*x^2 + b*x + c = 0. More... | |
uint32_t | solve_cubic (double a, double b, double c, double d, double *x0, double *x1, double *x2) |
Solve cubic equation a*x^3 + b*x^2 + c*x + d = 0. More... | |
uint32_t | solve_quartic (double a, double b, double c, double d, double *x0, double *x1, double *x2, double *x3) |
Solve quartic equation x^4 + a*x^3 + b*x^2 + c*x + d = 0. More... | |
Detailed Description
Polynomial solver.
Polynomial solvers.
Copyright (C) 2003 CERN, K. S. K"{o}lbig and T. Kalvas
Quadratic and quartic solvers converted to C and implemented into the GSL-extras library by Andrew W. Steiner and Andy Buckley
Cubic solver taken from gsl-1.12 by T. Kalvas
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Function Documentation
◆ solve_cubic()
uint32_t solve_cubic | ( | double | a, |
double | b, | ||
double | c, | ||
double | d, | ||
double * | x0, | ||
double * | x1, | ||
double * | x2 | ||
) |
Solve cubic equation a*x^3 + b*x^2 + c*x + d = 0.
Solves the cubic equation. Can also handle lower order polynomials if coefficients are zero. Returns the number of roots found. Roots are filled in ascending order.
◆ solve_quadratic()
uint32_t solve_quadratic | ( | double | a, |
double | b, | ||
double | c, | ||
double * | x0, | ||
double * | x1 | ||
) |
Solve quadric equation a*x^2 + b*x + c = 0.
Solves the quadric equation. Can also handle linear case if a is zero. Returns the number of roots found. Roots are filled in ascending order.
◆ solve_quartic()
uint32_t solve_quartic | ( | double | a, |
double | b, | ||
double | c, | ||
double | d, | ||
double * | x0, | ||
double * | x1, | ||
double * | x2, | ||
double * | x3 | ||
) |
Solve quartic equation x^4 + a*x^3 + b*x^2 + c*x + d = 0.
Solves the quartic equation. Returns the number of roots found. Roots are filled in ascending order.