source: proiecte/Parallel-DT/R8/Src/genlogs.c @ 24

Last change on this file since 24 was 24, checked in by (none), 14 years ago

blabla

File size: 1.1 KB
Line 
1/*************************************************************************/
2/*                                                                       */
3/*      Tabluate logs and log factorials (to improve speed)              */
4/*      --------------------------------                                 */
5/*                                                                       */
6/*************************************************************************/
7
8
9#include "defns.i"
10#include "types.i"
11#include "extern.i"
12
13
14float   *LogItemNo;
15double  *LogFact;
16
17
18/*************************************************************************/
19/*                                                                       */
20/*  Set up the array LogItemNo to contain the logs of integers and       */
21/*  the array LogFact to contain logs of factorials (all to base 2)      */
22/*                                                                       */
23/*************************************************************************/
24
25
26    GenerateLogs()
27/*  ------------  */
28{
29    ItemNo i;
30
31    LogItemNo = (float *) malloc((MaxItem+100) * sizeof(float));
32    LogFact = (double *) malloc((MaxItem+100) * sizeof(double));
33
34    LogItemNo[0] = -1E38;
35    LogItemNo[1] = 0;
36    LogFact[0] = LogFact[1] = 0;
37
38    ForEach(i, 2, MaxItem+99)
39    {
40        LogItemNo[i] = log((float) i) / Log2;
41        LogFact[i] = LogFact[i-1] + LogItemNo[i];
42    }
43}
Note: See TracBrowser for help on using the repository browser.