openGPMP
Open Source Mathematics Package
Static Public Member Functions | List of all members
gpmp::core::Misc Class Reference

A class containing miscellaneous utility functions. More...

#include <utils.hpp>

Static Public Member Functions

template<typename T >
static T factorial (T n)
 Calculates the factorial of the given integer or double. More...
 

Detailed Description

A class containing miscellaneous utility functions.

Definition at line 201 of file utils.hpp.

Member Function Documentation

◆ factorial()

template<typename T >
static T gpmp::core::Misc::factorial ( n)
inlinestatic

Calculates the factorial of the given integer or double.

Template Parameters
TThe type of the input (int or double)
Parameters
nThe input value for which factorial is calculated
Returns
The factorial of the input value
Note
For negative integer inputs, the result will be 0

Definition at line 211 of file utils.hpp.

211  {
212  if (n < 0)
213  return 0; // Invalid input
214  T result = 1;
215  for (T i = 1; i <= n; ++i) {
216  result *= i;
217  }
218  return result;
219  }

Referenced by gpmp::stats::PDF::poisson().


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