Helios++
Helios software for LiDAR simulations
SurfaceInspector::maths::Scalar< T > Class Template Reference

Class providing common operations to work with scalars. More...

#include <Scalar.hpp>

Inheritance diagram for SurfaceInspector::maths::Scalar< T >:
Collaboration diagram for SurfaceInspector::maths::Scalar< T >:

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...
 

Detailed Description

template<typename T>
class SurfaceInspector::maths::Scalar< T >

Class providing common operations to work with scalars.

Author
Alberto M. Esmoris Pena
Version
1.0
Template Parameters
TType of scalar to work with

Member Function Documentation

◆ binom()

template<typename T >
static T SurfaceInspector::maths::Scalar< T >::binom ( T const  n,
T const  k 
)
static

Compute Newton binomial \({{n}\choose{k}}\).

Returns
Newton binomial \({{n}\choose{k}}\)

◆ combinationsRepetition()

template<typename T >
static T SurfaceInspector::maths::Scalar< T >::combinationsRepetition ( T const  n,
T const  k 
)
inlinestatic

Compute combinations (order does not matter) of \(n\) elements considering \(k\) allowing repetitions.

\[ {{n+k-1}\choose{k}} \]

◆ factorial()

template<typename T >
static T SurfaceInspector::maths::Scalar< T >::factorial ( T const  n)
static

Compute the factorial of \(n\) ( \(n!\))

Parameters
nInteger number which factorial must be computed
Returns
Factorial of \(n\) ( \(n!\))

◆ pow2()

template<typename T >
static T SurfaceInspector::maths::Scalar< T >::pow2 ( T const  k)
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\).

Parameters
kThe \(k \geq 0\) integer exponent
Returns
Computed power \(2^k \in \mathbb{Z}_{\geq 0}\)

◆ variationsNoRepetition()

template<typename T >
static T SurfaceInspector::maths::Scalar< T >::variationsNoRepetition ( T const  n,
T const  k 
)
static

Compute variations (order does matter) of \(n\) elements considering \(k\) with no repetitions.

\[ \frac{n!}{(n-k)!} \]

◆ variationsRepetition()

template<typename T >
static T SurfaceInspector::maths::Scalar< T >::variationsRepetition ( T const  n,
T const  k 
)
inlinestatic

Compute variations (order does matter) of \(n\) elements considering \(k\) with repetitions.

\[ n^{k} \]


The documentation for this class was generated from the following file: