MPQC  3.0.0-alpha
localdef.h
1 //
2 // localdef.h
3 //
4 // Copyright (C) 1996 Limit Point Systems, Inc.
5 //
6 // Author: Edward Seidl <seidl@janed.com>
7 // Maintainer: LPS
8 //
9 // This file is part of the SC Toolkit.
10 //
11 // The SC Toolkit is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU Library General Public License as published by
13 // the Free Software Foundation; either version 2, or (at your option)
14 // any later version.
15 //
16 // The SC Toolkit is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU Library General Public License for more details.
20 //
21 // You should have received a copy of the GNU Library General Public License
22 // along with the SC Toolkit; see the file COPYING.LIB. If not, write to
23 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 //
25 // The U.S. Government is granted a limited license as per AL 91-7.
26 //
27 
28 // some inline functions for dealing with 3 dimensional vectors
29 
30 #ifndef _localdef_h
31 #define _localdef_h
32 
33 #include <math.h>
34 
35 namespace sc {
36 
37 static const double pi=M_PI;
38 static const double pih=M_PI_2;
39 static const double tpi=2.0*pi;
40 
41 static const double bohr = 0.52917706;
42 
43 // /////////////////////////////////////////////////////////
44 
45 static inline void
46 delta(double u[], const double a[], const double b[])
47 {
48  u[0]=a[0]-b[0];
49  u[1]=a[1]-b[1];
50  u[2]=a[2]-b[2];
51 }
52 
53 // /////////////////////////////////////////////////////////
54 
55 inline static double
56 dot(double v[3], double w[3])
57 {
58  return v[0]*w[0] + v[1]*w[1] + v[2]*w[2];
59 }
60 
61 // /////////////////////////////////////////////////////////
62 
63 // returns the distance between two points
64 static inline double
65 dist(const double a[], const double b[])
66 {
67  double ab[3]; delta(ab, a, b);
68  return sqrt(dot(ab,ab));
69 }
70 
71 // /////////////////////////////////////////////////////////
72 
73 // given sin(x) returns cos(x)
74 static inline double
75 s2(double x)
76 {
77  double tmp = 1.0 - x*x;
78  if (tmp < 0.0) tmp = 0.0;
79  return sqrt(tmp);
80 }
81 
82 // /////////////////////////////////////////////////////////
83 
84 // returns the dot product for two vectors
85 static inline double
86 scalar(const double a[], const double b[])
87 {
88  double x = a[0]*b[0];
89  double x1 = a[1]*b[1];
90  x += a[2]*b[2];
91  return x+x1;
92 }
93 
94 // /////////////////////////////////////////////////////////
95 
96 // given vectors a and b, returns a unit vector directed along the difference
97 // of the two vectors
98 static inline void
99 norm(double u[], const double a[], const double b[])
100 {
101  delta(u,a,b);
102  double x = 1.0/sqrt(scalar(u,u));
103  u[0] *= x; u[1] *= x; u[2] *= x;
104 }
105 
106 // /////////////////////////////////////////////////////////
107 
108 // given two vectors, returns the normalized cross product of those vectors
109 static inline void
110 normal(const double a[], const double b[], double w[])
111 {
112  w[0] = a[1]*b[2]-a[2]*b[1];
113  w[1] = a[2]*b[0]-a[0]*b[2];
114  w[2] = a[0]*b[1]-a[1]*b[0];
115  double x = 1.0/sqrt(scalar(w,w));
116  w[0] *= x; w[1] *= x; w[2] *= x;
117 }
118 
119 }
120 
121 #endif
122 
123 // Local Variables:
124 // mode: c++
125 // c-file-style: "ETS"
126 // End:
sc
Contains all MPQC code up to version 3.
Definition: mpqcin.h:14

Generated at Sun Jan 26 2020 23:23:57 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.8.16.