C++QEDCore  v2 Milestone 10
a framework for simulating open quantum dynamics – core
mathutils Namespace Reference

Comprises wrapper functions for mathematical functions taken from libraries (Boost.Math, GSL), and several other mathematical functions. More...

Classes

struct  FactOverflow
 

Functions

int sign (double)
 
int fcmp (double, double, double)
 
template<class T >
const T sqr (T x)
 
double sqr (double x)
 
double sqrAbs (const dcomp &)
 
double fact (unsigned) throw (FactOverflow)
 
double choose (unsigned, unsigned)
 
template<typename T >
bool parity (T n)
 
int round (double r)
 
template<typename T >
char minusOneToThePowerOf (T n)
 
dcomp coherentElement (unsigned long n, const dcomp &alpha)
 Calculates $\alpha^n/\sqrt{n!}$ relying on the Stirling formula if $n$ is too large for explicit calculation of factorial. More...
 

Variables

const double PI
 
const double SQRTPI
 
const double EULER
 

Detailed Description

Comprises wrapper functions for mathematical functions taken from libraries (Boost.Math, GSL), and several other mathematical functions.

Function Documentation

dcomp mathutils::coherentElement ( unsigned long  n,
const dcomp alpha 
)

Calculates $\alpha^n/\sqrt{n!}$ relying on the Stirling formula if $n$ is too large for explicit calculation of factorial.

The point of switching is determined by boost::math::max_factorial.

The Stirling formula is a very good approximation already for moderate $n$ values:

differencesInCoherentElements.svg