changed reading hint
[gromacs/adressmacs.git] / include / lutab.h
blob3f234e6627acdc979b6b4a081f2f9c2969cfc8a6
1 /*
2 * $Id$
3 *
4 * This source code is part of
5 *
6 * G R O M A C S
7 *
8 * GROningen MAchine for Chemical Simulations
9 *
10 * VERSION 2.0
12 * Copyright (c) 1991-1999
13 * BIOSON Research Institute, Dept. of Biophysical Chemistry
14 * University of Groningen, The Netherlands
16 * Please refer to:
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
23 * or e-mail to:
24 * gromacs@chem.rug.nl
26 * And Hey:
27 * Good ROcking Metal Altar for Chronical Sinners
30 #ifndef _lutab_h
31 #define _lutab_h
33 static char *SRCID_lutab_h = "$Id$";
35 #ifdef HAVE_IDENT
36 #ident "@(#) lutab.h 1.7 2/2/97"
37 #endif /* HAVE_IDENT */
39 Fast sqrt(x) routine (actually 1.0/sqrt(x)) By A. Sijbers (c) 1992
41 Based on Newton Rhapson iteration, initial value from lookup table
43 Floating point representation:
45 msb lsb
46 3322 2222 2222 1111 1111 1000 0000 0000
47 bitnr 1098 7654 3210 9876 5432 1098 7654 3210
48 |||| |||| |+-- ---- ---- ---- ---- ---+ fraction
49 |+-- ---- + exponent
50 +sign
52 S = sign
53 E = exponent
54 F = fraction
55 S E-127
56 IEEE : value = (-1) (2 ) (1.F) <------ must be float representation
58 S E-128
59 DEC : value = (-1) (2 ) (0.1F)
62 #include <stdio.h>
64 #define EXP_LSB 0x00800000
65 #define EXP_SEED_SIZE 256
66 #define EXP_MASK 0x7f800000
67 #define EXP_SHIFT 23
68 #define MAX_FRACT 0x007fffff
69 #define FRACT_MASK 0x007fffff
70 #define FRACT_SIZE 11 /* significant part of fraction */
71 #define FRACT_SHIFT (EXP_SHIFT-FRACT_SIZE)
72 #define FRACT_SEED_SIZE (1<<(FRACT_SIZE+1)) /* one bit for even/odd */
73 #define FRACT_FIRST (0x3f800000>>FRACT_SHIFT)
74 #define NOT_INITIALISED ~0
75 #define EXP_ADDR(val) (((val)&EXP_MASK)>>EXP_SHIFT)
76 #define FRACT_ADDR(val) (((val)&(FRACT_MASK|EXP_LSB))>>FRACT_SHIFT)
78 typedef unsigned int word;
80 typedef union
82 word bval;
83 float fval;
84 } t_convert;
86 typedef struct
88 word exp_seed[EXP_SEED_SIZE];
89 word fract_seed[FRACT_SEED_SIZE];
90 } t_lutab;
92 /* Global variable, must be initiated by a call to init_lookup_table */
93 extern t_lutab lookup_table;
95 extern void init_lookup_table(FILE *log);
97 #endif /* _lutab_h */