source: tags/initial/ARBDB/admath.c

Last change on this file was 2, checked in by oldcode, 23 years ago

Initial revision

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 532 bytes
Line 
1#include <stdlib.h>
2#include <stdio.h>
3#include <malloc.h>
4#include <string.h>
5#include <math.h>
6
7/*#include <arbdb.h>*/
8#include "adlocal.h"
9
10double GB_log_fak(int n){
11    /* returns log(n!) */
12    static int max_n = 0;
13    static double *res = 0;
14    if (n<=1) return 0.0;       /* log 1 = 0 */
15   
16    if (n >= max_n){
17        double sum = 0;
18        int i;
19        GB_DELETE(res);
20        max_n = n + 100;
21        res = (double *)GB_calloc(sizeof(double),max_n);
22        for (i=1;i<max_n;i++){
23            sum += log((double)i);
24            res[i] = sum;
25        }
26    }
27    return res[n];
28}
29
30
31
32
Note: See TracBrowser for help on using the repository browser.