1 // Created on: 1991-05-13
2 // Created by: Laurent PAINNOT
3 // Copyright (c) 1991-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _math_DirectPolynomialRoots_HeaderFile
18 #define _math_DirectPolynomialRoots_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <Standard_Boolean.hxx>
25 #include <Standard_Integer.hxx>
26 #include <Standard_Real.hxx>
27 #include <Standard_OStream.hxx>
28 class Standard_RangeError;
29 class StdFail_InfiniteSolutions;
33 //! This class implements the calculation of all the real roots of a real
34 //! polynomial of degree <= 4 using a direct method. Once found,
35 //! the roots are polished using the Newton method.
36 class math_DirectPolynomialRoots
44 //! computes all the real roots of the polynomial
45 //! Ax4 + Bx3 + Cx2 + Dx + E using a direct method.
46 Standard_EXPORT math_DirectPolynomialRoots(const Standard_Real A, const Standard_Real B, const Standard_Real C, const Standard_Real D, const Standard_Real E);
49 //! computes all the real roots of the polynomial
50 //! Ax3 + Bx2 + Cx + D using a direct method.
51 Standard_EXPORT math_DirectPolynomialRoots(const Standard_Real A, const Standard_Real B, const Standard_Real C, const Standard_Real D);
54 //! computes all the real roots of the polynomial
55 //! Ax2 + Bx + C using a direct method.
56 Standard_EXPORT math_DirectPolynomialRoots(const Standard_Real A, const Standard_Real B, const Standard_Real C);
59 //! computes the real root of the polynomial Ax + B.
60 Standard_EXPORT math_DirectPolynomialRoots(const Standard_Real A, const Standard_Real B);
62 //! Returns true if the computations are successful, otherwise returns false.
63 Standard_Boolean IsDone() const;
65 //! Returns true if there is an infinity of roots, otherwise returns false.
66 Standard_Boolean InfiniteRoots() const;
68 //! returns the number of solutions.
69 //! An exception is raised if there are an infinity of roots.
70 Standard_Integer NbSolutions() const;
72 //! returns the value of the Nieme root.
73 //! An exception is raised if there are an infinity of roots.
74 //! Exception RangeError is raised if Nieme is < 1
75 //! or Nieme > NbSolutions.
76 Standard_Real Value (const Standard_Integer Nieme) const;
78 //! Prints on the stream o information on the current state
80 //! Is used to redefine the operator <<.
81 Standard_EXPORT void Dump (Standard_OStream& o) const;
89 Standard_EXPORT void Solve (const Standard_Real A, const Standard_Real B, const Standard_Real C, const Standard_Real D, const Standard_Real E);
91 Standard_EXPORT void Solve (const Standard_Real A, const Standard_Real B, const Standard_Real C, const Standard_Real D);
93 Standard_EXPORT void Solve (const Standard_Real A, const Standard_Real B, const Standard_Real C);
95 Standard_EXPORT void Solve (const Standard_Real A, const Standard_Real B);
104 Standard_Boolean Done;
105 Standard_Boolean InfiniteStatus;
106 Standard_Integer NbSol;
107 Standard_Real TheRoots[4];
113 #include <math_DirectPolynomialRoots.lxx>
119 #endif // _math_DirectPolynomialRoots_HeaderFile