All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
scalar.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) 2011-2019 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 Typedef
25  Foam::scalar
26 
27 Description
28  Single floating point number identical to float or double depending on
29  whether WM_SP, WM_DP or WM_LP is defined.
30 
31 SourceFiles
32  scalar.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef scalar_H
37 #define scalar_H
38 
39 #include "floatScalar.H"
40 #include "doubleScalar.H"
41 #include "longDoubleScalar.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 #if defined(WM_SP)
46 
47 // Define scalar as a float
48 
49 namespace Foam
50 {
51  typedef floatScalar scalar;
52 
53  static const scalar great = floatScalarGreat;
54  static const scalar rootGreat = floatScalarRootGreat;
55  static const scalar vGreat = floatScalarVGreat;
56  static const scalar rootVGreat = floatScalarRootVGreat;
57  static const scalar small = floatScalarSmall;
58  static const scalar rootSmall = floatScalarRootSmall;
59  static const scalar vSmall = floatScalarVSmall;
60  static const scalar rootVSmall = floatScalarRootVSmall;
61  static const scalar NaN = floatScalarNaN;
62 }
63 
64 #elif defined(WM_DP)
65 
66 // Define scalar as a double
67 
68 namespace Foam
69 {
70  typedef doubleScalar scalar;
71 
72  static const scalar great = doubleScalarGreat;
73  static const scalar rootGreat = doubleScalarRootGreat;
74  static const scalar vGreat = doubleScalarVGreat;
75  static const scalar rootVGreat = doubleScalarRootVGreat;
76  static const scalar small = doubleScalarSmall;
77  static const scalar rootSmall = doubleScalarRootSmall;
78  static const scalar vSmall = doubleScalarVSmall;
79  static const scalar rootVSmall = doubleScalarRootVSmall;
80  static const scalar NaN = doubleScalarNaN;
81 }
82 
83 #elif defined(WM_LP)
84 
85 // Define scalar as a long double
86 
87 namespace Foam
88 {
89  typedef longDoubleScalar scalar;
90 
91  static const scalar great = longDoubleScalarGreat;
92  static const scalar rootGreat = longDoubleScalarRootGreat;
93  static const scalar vGreat = longDoubleScalarVGreat;
94  static const scalar rootVGreat = longDoubleScalarRootVGreat;
95  static const scalar small = longDoubleScalarSmall;
96  static const scalar rootSmall = longDoubleScalarRootSmall;
97  static const scalar vSmall = longDoubleScalarVSmall;
98  static const scalar rootVSmall = longDoubleScalarRootVSmall;
99  static const scalar NaN = longDoubleScalarNaN;
100 }
101 
102 #else
103 
104  #error "Precision not set, please set either WM_SP, WM_DP or WM_LP"
105 
106 #endif
107 
108 //- Deprecated limit constant for backward-compatibility
109 namespace Foam
110 {
111  static const scalar GREAT = great;
112  static const scalar ROOTGREAT = rootGreat;
113  static const scalar VGREAT = vGreat;
114  static const scalar ROOTVGREAT = rootVGreat;
115  static const scalar SMALL = small;
116  static const scalar ROOTSMALL = rootSmall;
117  static const scalar VSMALL = vSmall;
118  static const scalar ROOTVSMALL = rootVSmall;
119 }
120 
121 
122 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
123 // Additional global and transcendental functions
124 
125 namespace Foam
126 {
127  scalar readScalar(Istream& is);
128 
129  //- Inverse normalized incomplete gamma function
130  scalar invIncGamma(const scalar a, const scalar P);
131 
132  //- Normalized upper incomplete gamma function
133  scalar incGammaRatio_Q(const scalar a, const scalar x);
134 
135  //- Normalized lower incomplete gamma function
136  scalar incGammaRatio_P(const scalar a, const scalar x);
137 
138  //- Upper incomplete gamma function
139  scalar incGamma_Q(const scalar a, const scalar x);
140 
141  //- Lower incomplete gamma function
142  scalar incGamma_P(const scalar a, const scalar x);
143 }
144 
145 
146 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
147 
148 #endif
149 
150 // ************************************************************************* //
static const longDoubleScalar longDoubleScalarGreat
static const doubleScalar doubleScalarRootGreat
Definition: doubleScalar.H:68
static const scalar GREAT
Definition: scalar.H:111
scalar incGammaRatio_P(const scalar a, const scalar x)
Normalized lower incomplete gamma function.
Definition: incGamma.C:435
static const scalar ROOTGREAT
Definition: scalar.H:112
static const longDoubleScalar longDoubleScalarVSmall
static const doubleScalar doubleScalarRootVGreat
Definition: doubleScalar.H:65
static const doubleScalar doubleScalarNaN
Definition: doubleScalar.H:72
static const scalar ROOTVGREAT
Definition: scalar.H:114
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
static const floatScalar floatScalarRootVGreat
Definition: floatScalar.H:65
static const scalar SMALL
Definition: scalar.H:115
static const longDoubleScalar longDoubleScalarRootVGreat
static const floatScalar floatScalarVSmall
Definition: floatScalar.H:58
static const floatScalar floatScalarRootVSmall
Definition: floatScalar.H:66
static const scalar ROOTVSMALL
Definition: scalar.H:118
static const doubleScalar doubleScalarRootVSmall
Definition: doubleScalar.H:66
static const doubleScalar doubleScalarGreat
Definition: doubleScalar.H:63
static const floatScalar floatScalarRootSmall
Definition: floatScalar.H:69
static const doubleScalar doubleScalarVSmall
Definition: doubleScalar.H:58
static const longDoubleScalar longDoubleScalarRootSmall
static const longDoubleScalar longDoubleScalarNaN
static const floatScalar floatScalarRootGreat
Definition: floatScalar.H:68
static const longDoubleScalar longDoubleScalarRootVSmall
static const floatScalar floatScalarVGreat
Definition: floatScalar.H:56
float floatScalar
Float precision floating point scalar type.
Definition: floatScalar.H:52
double doubleScalar
Double precision floating point scalar type.
Definition: doubleScalar.H:52
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if successful.
Definition: doubleScalar.H:75
static const scalar ROOTSMALL
Definition: scalar.H:116
scalar incGammaRatio_Q(const scalar a, const scalar x)
Normalized upper incomplete gamma function.
Definition: incGamma.C:221
scalar invIncGamma(const scalar a, const scalar P)
Inverse normalized incomplete gamma function.
Definition: invIncGamma.C:106
static const floatScalar floatScalarGreat
Definition: floatScalar.H:63
static const longDoubleScalar longDoubleScalarSmall
long double longDoubleScalar
Lang double precision floating point scalar type.
static const scalar VGREAT
Definition: scalar.H:113
static const doubleScalar doubleScalarSmall
Definition: doubleScalar.H:61
static const scalar VSMALL
Definition: scalar.H:117
static const longDoubleScalar longDoubleScalarVGreat
static const floatScalar floatScalarSmall
Definition: floatScalar.H:61
static const doubleScalar doubleScalarRootSmall
Definition: doubleScalar.H:69
scalar incGamma_P(const scalar a, const scalar x)
Lower incomplete gamma function.
Definition: incGamma.C:447
scalar incGamma_Q(const scalar a, const scalar x)
Upper incomplete gamma function.
Definition: incGamma.C:441
static const floatScalar floatScalarNaN
Definition: floatScalar.H:72
static const longDoubleScalar longDoubleScalarRootGreat
Namespace for OpenFOAM.
static const doubleScalar doubleScalarVGreat
Definition: doubleScalar.H:56