/* * The Spar Library - modular math parser * Copyright (C) 2000,2001 Davide Angelocola * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * */ #ifndef _sl_poly_ #define _sl_poly_ #include struct poly_s { sl_vector *c; sl_vector *g; double grade; }; typedef struct poly_s sl_poly; __BEGIN_DECLS /* * Evaluate polynomial * c[0] + c[1] x + c[2] x^2 + ... + c[len-1] x^(len-1) */ double sl_poly_eval (const double c[], const int len, const double x); /* Solve for real or complex roots of the standard quadratic equation, * returning the number of real roots. */ int sl_poly_solve_quadratic (double a, double b, double c, double *x1, double *x2); /* * Solve for real roots of the cubic equation * x^3 + a x^2 + b x + c = 0, returning the number of real roots. */ int sl_poly_solve_cubic (double a, double b, double c, double *x0, double *x1, double *x2); #include int sl_poly_zsolve_quadratic (double a, double b, double c, sl_complex * z0, sl_complex * z1); int sl_poly_zsolve_cubic (double a, double b, double c, sl_complex *z0, sl_complex *z1, sl_complex *z2); __END_DECLS #endif /* _sl_poly_ */