vnl_beta.h
Go to the documentation of this file.
1 // This is core/vnl/vnl_beta.h
2 #ifndef vnl_beta_h_
3 #define vnl_beta_h_
4 //:
5 // \file
6 // \brief implementation of the beta function, also called the Euler integral of the first kind
7 // \author Gamze Tunali
8 
9 #include "vnl_gamma.h"
10 #include "vnl/vnl_export.h"
11 
12 #if 1 // implementation via vnl_log_gamma
13 //: Computation of beta function in terms of gamma function.
14 // Actually, this implementation refers to vnl_log_gamma,
15 // since this involves just a single call to std::exp instead of three.
16 template <class T>
17 inline VNL_EXPORT double vnl_beta(T x, T y) {return std::exp(vnl_log_gamma(x)+vnl_log_gamma(y)-vnl_log_gamma(x+y)); }
18 #else // implementation via vnl_gamma; less efficient since it needs 3x std::exp
19 //: Computation of beta function in terms of gamma function.
20 template <class T>
21 inline double vnl_beta(T x, T y) {return (vnl_gamma(x)*vnl_gamma(y))/vnl_gamma(x+y); }
22 #endif
23 
24 //: Computation of the log beta function in terms of the log gamma function.
25 // vnl_log_beta is just the std::log (natural logarithm) of the beta function.
26 template <class T>
27 inline VNL_EXPORT double vnl_log_beta(T x, T y) {return vnl_log_gamma(x)+vnl_log_gamma(y)-vnl_log_gamma(x+y); }
28 
29 #endif
VNL_EXPORT double vnl_beta(T x, T y)
Computation of beta function in terms of gamma function.
Definition: vnl_beta.h:17
double vnl_gamma(double x)
Approximate gamma function.
Definition: vnl_gamma.h:25
VNL_EXPORT double vnl_log_beta(T x, T y)
Computation of the log beta function in terms of the log gamma function.
Definition: vnl_beta.h:27
double vnl_log_gamma(double x)
Approximate gamma function.
Definition: vnl_gamma.cxx:18
Complete and incomplete gamma function approximations.