npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
permutation.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_PERMUTATION_HH_
2 #define NPSTAT_PERMUTATION_HH_
3 
4 /*!
5 // \file permutation.hh
6 //
7 // \brief Utilities related to permuting a set of consecutive integers
8 //
9 // Author: I. Volobouev
10 //
11 // March 2010
12 */
13 
15 
16 namespace npstat {
17  /**
18  // On output, array "permutation" will be filled by the permutation
19  // of numbers from 0 to permLen-1 which correspond to the given
20  // permutation number. The input permutation number must be
21  // less than factorial(permLen).
22  */
24  unsigned *permutation, unsigned permLen);
25 
26  /**
27  // On output, array "permutation" will be filled by a random
28  // permutation of numbers from 0 to permLen-1. "permLen" can
29  // be as large as the largest unsigned integer (but you will
30  // probably run into memory limitations of your computer first).
31  */
33  unsigned *permutation, unsigned permLen);
34 
35  /**
36  // A mapping from a permuted set into a linear sequence.
37  // factorial(permLen) should be less than the largest unsigned long.
38  */
39  unsigned long permutationNumber(const unsigned *permutation,
40  unsigned permLen);
41 
42  /**
43  // Simple factorial. Will generate a run-time error if n!
44  // is larger than the largest unsigned long.
45  */
46  unsigned long factorial(unsigned n);
47 
48  /**
49  // Precise integer function for the power. Will generate a run-time
50  // error if a^n exceeds the largest unsigned long.
51  */
52  unsigned long intPower(unsigned a, unsigned n);
53 
54  /**
55  // Factorial as a long double. Although imprecise, this has much
56  // larger dynamic range than "factorial".
57  */
58  long double ldfactorial(unsigned n);
59 
60  /** Natural log of a factorial (using Stirling's series for large n) */
61  long double logfactorial(unsigned long n);
62 }
63 
64 #endif // NPSTAT_PERMUTATION_HH_
Interface definition for pseudo- and quasi-random number generators.
Definition: AbsArrayProjector.hh:14
long double logfactorial(unsigned long n)
void randomPermutation(AbsRandomGenerator &gen, unsigned *permutation, unsigned permLen)
void orderedPermutation(unsigned long permutationNumber, unsigned *permutation, unsigned permLen)
unsigned long factorial(unsigned n)
unsigned long permutationNumber(const unsigned *permutation, unsigned permLen)
long double ldfactorial(unsigned n)
unsigned long intPower(unsigned a, unsigned n)
Definition: AbsRandomGenerator.hh:27