add numerical recipes library
This commit is contained in:
12
lib/nr/ansi/recipes/factln.c
Normal file
12
lib/nr/ansi/recipes/factln.c
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
float factln(int n)
|
||||
{
|
||||
float gammln(float xx);
|
||||
void nrerror(char error_text[]);
|
||||
static float a[101];
|
||||
|
||||
if (n < 0) nrerror("Negative factorial in routine factln");
|
||||
if (n <= 1) return 0.0;
|
||||
if (n <= 100) return a[n] ? a[n] : (a[n]=gammln(n+1.0));
|
||||
else return gammln(n+1.0);
|
||||
}
|
||||
Reference in New Issue
Block a user