X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=flower%2Fpolynomial.cc;h=5dc1f01db19359257b900364883449472e0bc6fd;hb=af3aa113a3f88c48b6449946a18501e2d333285d;hp=5f719147674860a3cca8d4035b4282e80660625e;hpb=ff90d34b47b91a7321ff9b21fe20133911376364;p=lilypond.git diff --git a/flower/polynomial.cc b/flower/polynomial.cc index 5f71914767..5dc1f01db1 100644 --- a/flower/polynomial.cc +++ b/flower/polynomial.cc @@ -1,12 +1,29 @@ /* - poly.cc -- routines for manipulation of polynomials in one var + This file is part of LilyPond, the GNU music typesetter. - (c) 1993--2006 Han-Wen Nienhuys + Copyright (C) 1993--2010 Han-Wen Nienhuys + + LilyPond 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 3 of the License, or + (at your option) any later version. + + LilyPond 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 LilyPond. If not, see . */ #include "polynomial.hh" +#include "warn.hh" + #include + + using namespace std; /* @@ -167,14 +184,11 @@ Polynomial::check_sol (Real x) const Real d = p.eval (x); if (abs (f) > abs (d) * FUDGE) - ; - /* - warning ("x=%f is not a root of polynomial\n" - "f (x)=%f, f' (x)=%f \n", x, f, d); */ + programming_error ("not a root of polynomial\n"); } void -Polynomial::check_sols (std::vector roots) const +Polynomial::check_sols (vector roots) const { for (vsize i = 0; i < roots.size (); i++) check_sol (roots[i]); @@ -203,10 +217,10 @@ iszero (Real r) return !r; } -std::vector +vector Polynomial::solve_cubic ()const { - std::vector sol; + vector sol; /* normal form: x^3 + Ax^2 + Bx + C = 0 */ Real A = coefs_[2] / coefs_[3]; @@ -295,10 +309,10 @@ Polynomial::degree ()const /* all roots of quadratic eqn. */ -std::vector +vector Polynomial::solve_quadric ()const { - std::vector sol; + vector sol; /* normal form: x^2 + px + q = 0 */ Real p = coefs_[1] / (2 * coefs_[2]); Real q = coefs_[0] / coefs_[2]; @@ -316,16 +330,16 @@ Polynomial::solve_quadric ()const } /* solve linear equation */ -std::vector +vector Polynomial::solve_linear ()const { - std::vector s; + vector s; if (coefs_[1]) s.push_back (-coefs_[0] / coefs_[1]); return s; } -std::vector +vector Polynomial::solve () const { Polynomial *me = (Polynomial *) this; @@ -340,7 +354,7 @@ Polynomial::solve () const case 3: return solve_cubic (); } - std::vector s; + vector s; return s; }