cubicEqn.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::cubicEqn
26 
27 Description
28  Cubic equation of the form a*x^3 + b*x^2 + c*x + d = 0
29 
30 SourceFiles
31  cubicEqnI.H
32  cubicEqn.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef cubicEqn_H
37 #define cubicEqn_H
38 
39 #include "Roots.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 /*---------------------------------------------------------------------------*\
47  Class cubicEqn Declaration
48 \*---------------------------------------------------------------------------*/
49 
50 class cubicEqn
51 :
52  public VectorSpace<cubicEqn, scalar, 4>
53 {
54 public:
55 
56  //- Component labeling enumeration
57  enum components { A, B, C, D };
58 
59 
60  // Constructors
61 
62  //- Construct null
63  inline cubicEqn();
64 
65  //- Construct initialized to zero
66  inline cubicEqn(const Foam::zero);
67 
68  //- Construct from components
69  inline cubicEqn
70  (
71  const scalar a,
72  const scalar b,
73  const scalar c,
74  const scalar d
75  );
76 
77 
78  // Member Functions
79 
80  // Access
81 
82  inline scalar a() const;
83  inline scalar b() const;
84  inline scalar c() const;
85  inline scalar d() const;
86 
87  inline scalar& a();
88  inline scalar& b();
89  inline scalar& c();
90  inline scalar& d();
91 
92  //- Evaluate at x
93  inline scalar value(const scalar x) const;
94 
95  //- Evaluate the derivative at x
96  inline scalar derivative(const scalar x) const;
97 
98  //- Estimate the error of evaluation at x
99  inline scalar error(const scalar x) const;
100 
101  //- Get the roots
102  Roots<3> roots() const;
103 };
104 
105 
106 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
107 
108 } // End namespace Foam
109 
110 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
111 
112 #include "cubicEqnI.H"
113 
114 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
115 
116 #endif
117 
118 // ************************************************************************* //
scalar c() const
Definition: cubicEqnI.H:67
Templated vector space.
Definition: VectorSpace.H:53
scalar d() const
Definition: cubicEqnI.H:73
Templated storage for the roots of polynomial equations, plus flags to indicate the nature of the roo...
Definition: Roots.H:68
scalar error(const scalar x) const
Estimate the error of evaluation at x.
Definition: cubicEqnI.H:115
Cubic equation of the form a*x^3 + b*x^2 + c*x + d = 0.
Definition: cubicEqn.H:49
scalar b() const
Definition: cubicEqnI.H:61
scalar derivative(const scalar x) const
Evaluate the derivative at x.
Definition: cubicEqnI.H:109
components
Component labeling enumeration.
Definition: cubicEqn.H:56
Roots< 3 > roots() const
Get the roots.
Definition: cubicEqn.C:32
scalar a() const
Definition: cubicEqnI.H:55
A class representing the concept of 0 used to avoid unnecessary manipulations for objects that are kn...
Definition: zero.H:49
cubicEqn()
Construct null.
Definition: cubicEqnI.H:28
scalar value(const scalar x) const
Evaluate at x.
Definition: cubicEqnI.H:103
Namespace for OpenFOAM.