Helios++
Helios software for LiDAR simulations
|
Class providing common operations to work with scalars. More...
#include <Scalar.hpp>
Static Public Member Functions | |
static T | factorial (T const n) |
Compute the factorial of \(n\) ( \(n!\)) More... | |
static T | binom (T const n, T const k) |
Compute Newton binomial \({{n}\choose{k}}\). More... | |
static T | combinationsNoRepetition (T const n, T const k) |
Compute combinations (order does not matter) of $fn \( elements considering \)@_fakenlk. | |
static T | combinationsRepetition (T const n, T const k) |
Compute combinations (order does not matter) of \(n\) elements considering \(k\) allowing repetitions. More... | |
static T | variationsNoRepetition (T const n, T const k) |
Compute variations (order does matter) of \(n\) elements considering \(k\) with no repetitions. More... | |
static T | variationsRepetition (T const n, T const k) |
Compute variations (order does matter) of \(n\) elements considering \(k\) with repetitions. More... | |
static T | pow2 (T const k) |
Compute the base \(2\) power \(2^k\) in a fast way. Notice this method only works with \(k \geq 0\) exponents and integer numerical types. More... | |
Class providing common operations to work with scalars.
T | Type of scalar to work with |
|
static |
Compute Newton binomial \({{n}\choose{k}}\).
|
inlinestatic |
Compute combinations (order does not matter) of \(n\) elements considering \(k\) allowing repetitions.
\[ {{n+k-1}\choose{k}} \]
|
static |
Compute the factorial of \(n\) ( \(n!\))
n | Integer number which factorial must be computed |
|
inlinestatic |
Compute the base \(2\) power \(2^k\) in a fast way. Notice this method only works with \(k \geq 0\) exponents and integer numerical types.
If a power has base \(2\), then it can be computed exploiting bit shift operations as illustrated below:
\[ \left\{\begin{array}{lllll} 2^0 &=& 1 &=& 1 \ll 0 \\ 2^1 &=& 2 &=& 1 \ll 1 \\ 2^2 &=& 4 &=& 1 \ll 2 \\ 2^3 &=& 8 &=& 1 \ll 3 \\ \vdots &\vdots& \vdots &\vdots& \vdots \\ 2^k &=& \prod_{i=1}^{k}2 &=& 1 \ll k \end{array}\right. \]
The bit shift operation \(\ll k\) means shifting the binary representation of the number to the left, padding with \(0\). Thus, the number \(4 = 0100_2\) could be easily obtained from number \(1 = 0001_2\) simply by \(1 \ll 2 = 0001_2 \ll 2 = 0100_2 = 2\).
k | The \(k \geq 0\) integer exponent |
|
static |
Compute variations (order does matter) of \(n\) elements considering \(k\) with no repetitions.
\[ \frac{n!}{(n-k)!} \]
|
inlinestatic |
Compute variations (order does matter) of \(n\) elements considering \(k\) with repetitions.
\[ n^{k} \]