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 }
62 
63 #elif defined(WM_DP)
64 
65 // Define scalar as a double
66 
67 namespace Foam
68 {
69  typedef doubleScalar scalar;
70 
71  static const scalar great = doubleScalarGreat;
72  static const scalar rootGreat = doubleScalarRootGreat;
73  static const scalar vGreat = doubleScalarVGreat;
74  static const scalar rootVGreat = doubleScalarRootVGreat;
75  static const scalar small = doubleScalarSmall;
76  static const scalar rootSmall = doubleScalarRootSmall;
77  static const scalar vSmall = doubleScalarVSmall;
78  static const scalar rootVSmall = doubleScalarRootVSmall;
79 }
80 
81 #elif defined(WM_LP)
82 
83 // Define scalar as a long double
84 
85 namespace Foam
86 {
87  typedef longDoubleScalar scalar;
88 
89  static const scalar great = longDoubleScalarGreat;
90  static const scalar rootGreat = longDoubleScalarRootGreat;
91  static const scalar vGreat = longDoubleScalarVGreat;
92  static const scalar rootVGreat = longDoubleScalarRootVGreat;
93  static const scalar small = longDoubleScalarSmall;
94  static const scalar rootSmall = longDoubleScalarRootSmall;
95  static const scalar vSmall = longDoubleScalarVSmall;
96  static const scalar rootVSmall = longDoubleScalarRootVSmall;
97 }
98 
99 #else
100 
101  #error "Precision not set, please set either WM_SP, WM_DP or WM_LP"
102 
103 #endif
104 
105 //- Deprecated limit constant for backward-compatibility
106 namespace Foam
107 {
108  static const scalar GREAT = great;
109  static const scalar ROOTGREAT = rootGreat;
110  static const scalar VGREAT = vGreat;
111  static const scalar ROOTVGREAT = rootVGreat;
112  static const scalar SMALL = small;
113  static const scalar ROOTSMALL = rootSmall;
114  static const scalar VSMALL = vSmall;
115  static const scalar ROOTVSMALL = rootVSmall;
116 }
117 
118 
119 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
120 // Additional global and transcendental functions
121 
122 namespace Foam
123 {
124  scalar readScalar(Istream& is);
125 
126  //- Inverse normalized incomplete gamma function
127  scalar invIncGamma(const scalar a, const scalar P);
128 
129  //- Normalized upper incomplete gamma function
130  scalar incGammaRatio_Q(const scalar a, const scalar x);
131 
132  //- Normalized lower incomplete gamma function
133  scalar incGammaRatio_P(const scalar a, const scalar x);
134 
135  //- Upper incomplete gamma function
136  scalar incGamma_Q(const scalar a, const scalar x);
137 
138  //- Lower incomplete gamma function
139  scalar incGamma_P(const scalar a, const scalar x);
140 }
141 
142 
143 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
144 
145 #endif
146 
147 // ************************************************************************* //
static const longDoubleScalar longDoubleScalarGreat
static const doubleScalar doubleScalarRootGreat
Definition: doubleScalar.H:64
static const scalar GREAT
Definition: scalar.H:108
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:109
static const longDoubleScalar longDoubleScalarVSmall
static const doubleScalar doubleScalarRootVGreat
Definition: doubleScalar.H:61
static const scalar ROOTVGREAT
Definition: scalar.H:111
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:61
static const scalar SMALL
Definition: scalar.H:112
static const longDoubleScalar longDoubleScalarRootVGreat
static const floatScalar floatScalarVSmall
Definition: floatScalar.H:56
static const floatScalar floatScalarRootVSmall
Definition: floatScalar.H:62
static const scalar ROOTVSMALL
Definition: scalar.H:115
static const doubleScalar doubleScalarRootVSmall
Definition: doubleScalar.H:62
static const doubleScalar doubleScalarGreat
Definition: doubleScalar.H:59
static const floatScalar floatScalarRootSmall
Definition: floatScalar.H:65
static const doubleScalar doubleScalarVSmall
Definition: doubleScalar.H:56
static const longDoubleScalar longDoubleScalarRootSmall
static const floatScalar floatScalarRootGreat
Definition: floatScalar.H:64
static const longDoubleScalar longDoubleScalarRootVSmall
static const floatScalar floatScalarVGreat
Definition: floatScalar.H:55
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:68
static const scalar ROOTSMALL
Definition: scalar.H:113
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:59
static const longDoubleScalar longDoubleScalarSmall
long double longDoubleScalar
Lang double precision floating point scalar type.
static const scalar VGREAT
Definition: scalar.H:110
static const doubleScalar doubleScalarSmall
Definition: doubleScalar.H:58
static const scalar VSMALL
Definition: scalar.H:114
static const longDoubleScalar longDoubleScalarVGreat
static const floatScalar floatScalarSmall
Definition: floatScalar.H:58
static const doubleScalar doubleScalarRootSmall
Definition: doubleScalar.H:65
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 longDoubleScalar longDoubleScalarRootGreat
Namespace for OpenFOAM.
static const doubleScalar doubleScalarVGreat
Definition: doubleScalar.H:55