changed reading hint
[gromacs/adressmacs.git] / include / complex.h
blobd7557972b6d774f44da242cb54ef020ee61f0e90
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 _complex_h
31 #define _complex_h
33 static char *SRCID_complex_h = "$Id$";
35 #include <math.h>
36 #include "typedefs.h"
38 typedef struct {
39 real re,im;
40 } t_complex;
42 typedef t_complex cvec[DIM];
44 static t_complex cnul = { 0.0, 0.0 };
46 static t_complex rcmul(real r,t_complex c)
48 t_complex d;
50 d.re = r*c.re;
51 d.im = r*c.im;
53 return d;
56 static t_complex rcexp(real r)
58 t_complex c;
60 c.re = cos(r);
61 c.im = sin(r);
63 return c;
67 static t_complex cadd(t_complex a,t_complex b)
69 t_complex c;
71 c.re = a.re+b.re;
72 c.im = a.im+b.im;
74 return c;
77 static t_complex csub(t_complex a,t_complex b)
79 t_complex c;
81 c.re = a.re-b.re;
82 c.im = a.im-b.im;
84 return c;
87 static t_complex cmul(t_complex a,t_complex b)
89 t_complex c;
91 c.re = a.re*b.re - a.im*b.im;
92 c.im = a.re*b.im + a.im*b.re;
94 return c;
97 static t_complex conjugate(t_complex c)
99 t_complex d;
101 d.re = c.re;
102 d.im = -c.im;
104 return d;
107 static t_complex cdiv(t_complex teller,t_complex noemer)
109 t_complex res,anoemer;
111 anoemer = cmul(conjugate(noemer),noemer);
112 res = cmul(teller,conjugate(noemer));
114 return rcmul(1.0/anoemer.re,res);
116 #endif