4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
12 * Copyright (c) 1991-1999
13 * BIOSON Research Institute, Dept. of Biophysical Chemistry
14 * University of Groningen, The Netherlands
17 * GROMACS: A message-passing parallel molecular dynamics implementation
18 * H.J.C. Berendsen, D. van der Spoel and R. van Drunen
19 * Comp. Phys. Comm. 91, 43-56 (1995)
21 * Also check out our WWW page:
22 * http://md.chem.rug.nl/~gmx
27 * Green Red Orange Magenta Azure Cyan Skyblue
29 static char *SRCID_lutab_c
= "$Id$";
32 * Invsqrt lookup tables @(#) gentab.c 1.9 11/5/92
34 * Copyright (c) 1992, A. Sijbers, Groningen University
40 /* Global variable that is exported */
43 static void init_table(t_lutab
*lookup_table
)
47 t_convert bit_in
,bit_out
;
49 for (i
=0; i
<EXP_SEED_SIZE
; i
++)
50 lookup_table
->exp_seed
[i
]=NOT_INITIALISED
;
51 for (i
=0; i
<FRACT_SEED_SIZE
; i
++)
52 lookup_table
->fract_seed
[i
]=NOT_INITIALISED
;
53 for (i
=0; i
<EXP_SEED_SIZE
; i
++)
55 if ((exp
=(i
-127))<0) new_exp
=127-((exp
+1)/2); else new_exp
=127-(exp
/2)-1;
56 lookup_table
->exp_seed
[i
]=((new_exp
)<<EXP_SHIFT
)&EXP_MASK
;
59 for (i
=0; i
<FRACT_SEED_SIZE
; i
++)
61 bit_in
.bval
=(index
<<FRACT_SHIFT
);
62 addr
=FRACT_ADDR(bit_in
.bval
);
63 bit_out
.fval
=(1.0/sqrt(bit_in
.fval
));
64 lookup_table
->fract_seed
[addr
]=(bit_out
.bval
&FRACT_MASK
);
65 if (lookup_table
->fract_seed
[addr
]==0)
66 lookup_table
->fract_seed
[addr
]=(MAX_FRACT
&FRACT_MASK
);
71 void init_lookup_table(FILE *log
)
75 fprintf(log
,"Generating lookup table for invsqrt calculation in C\n");
76 init_table(&lookup_table
);
81 fprintf(log
,"Generating lookup table for invsqrt calculation in Fortran\n");