label.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "error.H"
00028 #include "label.H"
00029
00030
00031
00032 namespace Foam
00033 {
00034
00035
00036
00037 const char* const pTraits<label>::typeName = "label";
00038 const label pTraits<label>::zero = 0;
00039 const label pTraits<label>::one = 1;
00040 const label pTraits<label>::min = labelMin;
00041 const label pTraits<label>::max = labelMax;
00042
00043 const char* pTraits<label>::componentNames[] = { "x" };
00044
00045 pTraits<label>::pTraits(Istream& is)
00046 {
00047 is >> p_;
00048 }
00049
00050
00051
00052
00053
00054 label pow(label a, label b)
00055 {
00056 register label ans = 1;
00057 for (register label i=0; i<b; i++)
00058 {
00059 ans *= a;
00060 }
00061
00062 # ifdef FULLDEBUG
00063 if (b < 0)
00064 {
00065 FatalErrorIn("pow(label a, label b)")
00066 << "negative value for b is not supported"
00067 << abort(FatalError);
00068 }
00069 # endif
00070
00071 return ans;
00072 }
00073
00074
00075
00076 label factorial(label n)
00077 {
00078 static label factTable[13] =
00079 {
00080 1, 1, 2, 6, 24, 120, 720, 5040, 40320,
00081 362880, 3628800, 39916800, 479001600
00082 };
00083
00084 # ifdef FULLDEBUG
00085 if (n > 12 && n < 0)
00086 {
00087 FatalErrorIn("factorial(label n)")
00088 << "n value out of range"
00089 << abort(FatalError);
00090 }
00091 # endif
00092
00093 return factTable[n];
00094 }
00095
00096
00097
00098
00099 }
00100
00101
Copyright © 2000-2009 OpenCFD Ltd