ADS
Algorithms and Data Structures
Toggle main menu visibility
Loading...
Searching...
No Matches
Combinatorics.h
Go to the documentation of this file.
1
/*--------------------------------------------------------------------------*/
2
/*-------------------------- File Combinatorics.h --------------------------*/
3
/*--------------------------------------------------------------------------*/
42
/*--------------------------------------------------------------------------*/
43
/*----------------------------- DEFINITIONS --------------------------------*/
44
/*--------------------------------------------------------------------------*/
45
46
#ifndef __ADS_Combinatorics
47
#define __ADS_Combinatorics
48
/* self-identification: #endif constant */
49
50
/*--------------------------------------------------------------------------*/
51
/*------------------------------ INCLUDES ----------------------------------*/
52
/*--------------------------------------------------------------------------*/
53
54
#include "
ADS/Contract.h
"
55
56
#include <cstddef>
57
#include <cstdint>
58
#include <vector>
59
60
/*--------------------------------------------------------------------------*/
61
/*--------------------------- NAMESPACE ------------------------------------*/
62
/*--------------------------------------------------------------------------*/
63
64
namespace
ADS
65
{
66
84
inline
std::uint64_t
binomial
(
int
n ,
int
k ,
long
* calls =
nullptr
);
85
103
inline
std::vector< std::vector< std::uint64_t > >
tartaglia
(
int
n );
104
118
inline
std::uint64_t
fibonacciTable
(
int
n );
119
135
inline
std::uint64_t
fibonacci
(
int
n );
136
138
class
FibonacciCache
139
{
140
public
:
155
[[nodiscard]] std::uint64_t
value
(
int
n )
const
;
156
158
[[nodiscard]]
int
size
(
void
)
const
;
159
160
private
:
161
mutable
std::vector< std::uint64_t > f_F = { 1 , 1 };
162
};
163
177
inline
std::uint64_t
factorial
(
int
n );
178
191
inline
std::uint64_t
factorialRec
(
int
n );
192
205
inline
std::uint64_t
binomialByFactorials
(
int
n ,
int
k );
206
207
/*--------------------------------------------------------------------------*/
208
209
}
// end( namespace ADS )
210
211
/*--------------------------------------------------------------------------*/
212
/*-------------------------- IMPLEMENTATION --------------------------------*/
213
/*--------------------------------------------------------------------------*/
214
215
#include "ADS/numeric/impl/Combinatorics.tpp"
216
217
/*--------------------------------------------------------------------------*/
218
219
#endif
/* Combinatorics.h included */
220
221
/*--------------------------------------------------------------------------*/
222
/*------------------------ End File Combinatorics.h ------------------------*/
223
/*--------------------------------------------------------------------------*/
Contract.h
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
ADS::FibonacciCache
the numbers of Fibonacci, those computed kept between the calls
Definition
Combinatorics.h:139
ADS::FibonacciCache::value
std::uint64_t value(int n) const
the number , the ones not kept yet computed from the last two kept
ADS::FibonacciCache::size
int size(void) const
how many numbers are kept,
ADS::fibonacciTable
std::uint64_t fibonacciTable(int n)
the number of Fibonacci, , with a vector
ADS::factorial
std::uint64_t factorial(int n)
the factorial by a loop
ADS::factorialRec
std::uint64_t factorialRec(int n)
the factorial by the recursion ,
ADS::tartaglia
std::vector< std::vector< std::uint64_t > > tartaglia(int n)
the triangle of Tartaglia, the table of the ,
ADS::fibonacci
std::uint64_t fibonacci(int n)
the number of Fibonacci, , in space
ADS::binomial
std::uint64_t binomial(int n, int k, long *calls=nullptr)
the binomial coefficient by the recursion; the calls added to *calls, if given
ADS::binomialByFactorials
std::uint64_t binomialByFactorials(int n, int k)
the binomial coefficient as
ADS
Definition
ADT.h:96
ADS
numeric
Combinatorics.h
Generated by
1.17.0