add numerical recipes library
This commit is contained in:
12
lib/nr/cpp/recipes/factln.cpp
Normal file
12
lib/nr/cpp/recipes/factln.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#include "nr.h"
|
||||
|
||||
DP NR::factln(const int n)
|
||||
{
|
||||
static DP a[101];
|
||||
|
||||
if (n < 0) nrerror("Negative factorial in routine factln");
|
||||
if (n <= 1) return 0.0;
|
||||
if (n <= 100)
|
||||
return (a[n] != 0.0 ? a[n] : (a[n]=gammln(n+1.0)));
|
||||
else return gammln(n+1.0);
|
||||
}
|
||||
Reference in New Issue
Block a user