ADS
Algorithms and Data Structures
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
64namespace ADS
65{
66
84inline std::uint64_t binomial( int n , int k , long * calls = nullptr );
85
103inline std::vector< std::vector< std::uint64_t > > tartaglia( int n );
104
118inline std::uint64_t fibonacciTable( int n );
119
135inline std::uint64_t fibonacci( int n );
136
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
177inline std::uint64_t factorial( int n );
178
191inline std::uint64_t factorialRec( int n );
192
205inline 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/*--------------------------------------------------------------------------*/
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
the numbers of Fibonacci, those computed kept between the calls
Definition Combinatorics.h:139
std::uint64_t value(int n) const
the number , the ones not kept yet computed from the last two kept
int size(void) const
how many numbers are kept,
std::uint64_t fibonacciTable(int n)
the number of Fibonacci, , with a vector
std::uint64_t factorial(int n)
the factorial by a loop
std::uint64_t factorialRec(int n)
the factorial by the recursion ,
std::vector< std::vector< std::uint64_t > > tartaglia(int n)
the triangle of Tartaglia, the table of the ,
std::uint64_t fibonacci(int n)
the number of Fibonacci, , in space
std::uint64_t binomial(int n, int k, long *calls=nullptr)
the binomial coefficient by the recursion; the calls added to *calls, if given
std::uint64_t binomialByFactorials(int n, int k)
the binomial coefficient as
Definition ADT.h:96