All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
label.C
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-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 \*---------------------------------------------------------------------------*/
25 
26 #include "label.H"
27 #include "error.H"
28 
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 
31 #if WM_LABEL_SIZE == 32
32 const char* const Foam::pTraits<int64_t>::typeName = "int64";
33 const char* const Foam::pTraits<int32_t>::typeName = "label";
34 #elif WM_LABEL_SIZE == 64
35 const char* const Foam::pTraits<int64_t>::typeName = "label";
36 const char* const Foam::pTraits<int32_t>::typeName = "int32";
37 #endif
38 
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
43 {
44  label ans = 1;
45  for (label i=0; i<b; i++)
46  {
47  ans *= a;
48  }
49 
50  #ifdef FULLDEBUG
51  if (b < 0)
52  {
54  << "negative value for b is not supported"
55  << abort(FatalError);
56  }
57  #endif
58 
59  return ans;
60 }
61 
62 
64 {
65  static label factTable[13] =
66  {
67  1, 1, 2, 6, 24, 120, 720, 5040, 40320,
68  362880, 3628800, 39916800, 479001600
69  };
70 
71  #ifdef FULLDEBUG
72  if (n > 12 || n < 0)
73  {
75  << "n value out of range"
76  << abort(FatalError);
77  }
78  #endif
79 
80  return factTable[n];
81 }
82 
83 
84 // ************************************************************************* //
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
const dimensionedScalar b
Wien displacement law constant: default SI units: [m K].
Definition: createFields.H:27
Traits class for primitives.
Definition: pTraits.H:50
label factorial(label n)
Return n! : 0 < n <= 12.
Definition: label.C:63
errorManip< error > abort(error &err)
Definition: errorManip.H:131
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
label n