uLabel.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
28#include "error.H"
29#include "uLabel.H"
30
31// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32
33#if WM_LABEL_SIZE == 32
34const char* const Foam::pTraits<uint64_t>::typeName = "uint64";
35const char* const Foam::pTraits<uint32_t>::typeName = "uLabel";
36#elif WM_LABEL_SIZE == 64
37const char* const Foam::pTraits<uint64_t>::typeName = "uLabel";
38const char* const Foam::pTraits<uint32_t>::typeName = "uint32";
39#endif
40
41
42// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43
44Foam::uLabel Foam::pow(uLabel a, uLabel b)
45{
46 uLabel ans = 1;
47 for (uLabel i=0; i<b; i++)
48 {
49 ans *= a;
50 }
51
52 return ans;
53}
54
55
56Foam::uLabel Foam::factorial(uLabel n)
57{
58 static uLabel factTable[13] =
59 {
60 1, 1, 2, 6, 24, 120, 720, 5040, 40320,
61 362880, 3628800, 39916800, 479001600
62 };
63
64 #ifdef FULLDEBUG
65 if (n > 12)
66 {
68 << "n value out of range (> 12)"
69 << abort(FatalError);
70 }
71 #endif
72
73 return factTable[n];
74}
75
76
77// ************************************************************************* //
label n
A traits class, which is primarily used for primitives.
Definition: pTraits.H:59
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
errorManip< error > abort(error &err)
Definition: errorManip.H:144
label factorial(label n)
Evaluate n! : 0 < n <= 12.
Definition: label.C:145
error FatalError
volScalarField & b
Definition: createFields.H:27