File: obutil_8h_source.shtml

package info (click to toggle)
openbabel 2.3.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 75,308 kB
  • ctags: 41,952
  • sloc: cpp: 321,252; ansic: 89,228; python: 7,262; perl: 6,418; pascal: 793; sh: 194; xml: 97; ruby: 55; makefile: 47; java: 23
file content (343 lines) | stat: -rw-r--r-- 38,296 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head><meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>obutil.h Source File</title>
<link href="/site.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="search/search.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
</head>

<body>

<!--#include file="header.html" -->
<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.shtml"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.shtml"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.shtml"><span>Modules</span></a></li>
      <li><a href="namespaces.shtml"><span>Namespaces</span></a></li>
      <li><a href="annotated.shtml"><span>Classes</span></a></li>
      <li class="current"><a href="files.shtml"><span>Files</span></a></li>
      <li><a href="examples.shtml"><span>Examples</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.shtml"><span>File&#160;List</span></a></li>
      <li><a href="globals.shtml"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">obutil.h</div>  </div>
</div>
<div class="contents">
<a href="obutil_8h.shtml">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/**********************************************************************</span>
<a name="l00002"></a>00002 <span class="comment">obutil.h - Various utility methods.</span>
<a name="l00003"></a>00003 <span class="comment"></span>
<a name="l00004"></a>00004 <span class="comment">Copyright (C) 1998-2001 by OpenEye Scientific Software, Inc.</span>
<a name="l00005"></a>00005 <span class="comment">Some portions Copyright (C) 2001-2006 by Geoffrey R. Hutchison</span>
<a name="l00006"></a>00006 <span class="comment"></span>
<a name="l00007"></a>00007 <span class="comment">This file is part of the Open Babel project.</span>
<a name="l00008"></a>00008 <span class="comment">For more information, see &lt;http://openbabel.org/&gt;</span>
<a name="l00009"></a>00009 <span class="comment"></span>
<a name="l00010"></a>00010 <span class="comment">This program is free software; you can redistribute it and/or modify</span>
<a name="l00011"></a>00011 <span class="comment">it under the terms of the GNU General Public License as published by</span>
<a name="l00012"></a>00012 <span class="comment">the Free Software Foundation version 2 of the License.</span>
<a name="l00013"></a>00013 <span class="comment"></span>
<a name="l00014"></a>00014 <span class="comment">This program is distributed in the hope that it will be useful,</span>
<a name="l00015"></a>00015 <span class="comment">but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00016"></a>00016 <span class="comment">MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<a name="l00017"></a>00017 <span class="comment">GNU General Public License for more details.</span>
<a name="l00018"></a>00018 <span class="comment">***********************************************************************/</span>
<a name="l00019"></a>00019 
<a name="l00020"></a>00020 <span class="preprocessor">#ifndef OB_UTIL_H</span>
<a name="l00021"></a>00021 <span class="preprocessor"></span><span class="preprocessor">#define OB_UTIL_H</span>
<a name="l00022"></a>00022 <span class="preprocessor"></span>
<a name="l00023"></a>00023 <span class="preprocessor">#include &lt;openbabel/babelconfig.h&gt;</span>
<a name="l00024"></a>00024 
<a name="l00025"></a>00025 <span class="preprocessor">#include &lt;string&gt;</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include &lt;iosfwd&gt;</span>
<a name="l00027"></a>00027 
<a name="l00028"></a>00028 <span class="preprocessor">#if TIME_WITH_SYS_TIME</span>
<a name="l00029"></a>00029 <span class="preprocessor"></span><span class="preprocessor">#include &lt;sys/time.h&gt;</span>
<a name="l00030"></a>00030 <span class="preprocessor">#include &lt;time.h&gt;</span>
<a name="l00031"></a>00031 <span class="preprocessor">#else</span>
<a name="l00032"></a>00032 <span class="preprocessor"></span><span class="preprocessor">#if HAVE_SYS_TIME_H</span>
<a name="l00033"></a>00033 <span class="preprocessor"></span><span class="preprocessor">#include &lt;sys/time.h&gt;</span>
<a name="l00034"></a>00034 <span class="preprocessor">#else</span>
<a name="l00035"></a>00035 <span class="preprocessor"></span><span class="preprocessor">#include &lt;time.h&gt;</span>
<a name="l00036"></a>00036 <span class="preprocessor">#endif</span>
<a name="l00037"></a>00037 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00038"></a>00038 <span class="preprocessor"></span>
<a name="l00039"></a>00039 <span class="preprocessor">#include &lt;math.h&gt;</span>
<a name="l00040"></a>00040 
<a name="l00041"></a>00041 <span class="preprocessor">#ifndef M_PI</span>
<a name="l00042"></a><a class="code" href="obutil_8h.shtml#ae71449b1cc6e6250b91f539153a7a0d3">00042</a> <span class="preprocessor"></span><span class="preprocessor">#define M_PI 3.14159265358979323846</span>
<a name="l00043"></a>00043 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00044"></a>00044 <span class="preprocessor"></span>
<a name="l00045"></a>00045 <span class="comment">// For backwards compatibility. Will be removed in the future</span>
<a name="l00046"></a>00046 <span class="preprocessor">#include &lt;<a class="code" href="rand_8h.shtml" title="Pseudo random number generator.">openbabel/rand.h</a>&gt;</span>
<a name="l00047"></a>00047 
<a name="l00048"></a>00048 <span class="keyword">namespace </span>OpenBabel
<a name="l00049"></a>00049 {
<a name="l00050"></a>00050 
<a name="l00051"></a>00051   <span class="comment">// class introduction in obutil.cpp</span>
<a name="l00052"></a><a class="code" href="classOpenBabel_1_1OBStopwatch.shtml">00052</a>   <span class="keyword">class </span>OBAPI <a class="code" href="classOpenBabel_1_1OBStopwatch.shtml" title="Stopwatch class used for timing length of execution.">OBStopwatch</a>
<a name="l00053"></a>00053   {
<a name="l00054"></a>00054 <span class="preprocessor">#if HAVE_CLOCK_T</span>
<a name="l00055"></a>00055 <span class="preprocessor"></span>    clock_t start; 
<a name="l00056"></a>00056     clock_t stop;  
<a name="l00057"></a>00057 <span class="preprocessor">#else</span>
<a name="l00058"></a>00058 <span class="preprocessor"></span>    timeval start; 
<a name="l00059"></a>00059     timeval stop;  
<a name="l00060"></a>00060 <span class="preprocessor">#endif</span>
<a name="l00061"></a>00061 <span class="preprocessor"></span>
<a name="l00062"></a>00062   <span class="keyword">public</span>:
<a name="l00063"></a>00063 <span class="preprocessor">#if HAVE_CLOCK_T</span>
<a name="l00064"></a>00064 <span class="preprocessor"></span>
<a name="l00066"></a>00066     <span class="keywordtype">void</span>  Start()
<a name="l00067"></a>00067     {
<a name="l00068"></a>00068       start= clock();
<a name="l00069"></a>00069     }
<a name="l00071"></a>00071     <span class="keywordtype">double</span> Lap()
<a name="l00072"></a>00072     {
<a name="l00073"></a>00073       stop= clock();
<a name="l00074"></a>00074       <span class="keywordflow">return</span>((stop - start) / CLOCKS_PER_SEC);
<a name="l00075"></a>00075     }
<a name="l00076"></a>00076 <span class="preprocessor">#else</span>
<a name="l00077"></a>00077 <span class="preprocessor"></span>
<a name="l00078"></a><a class="code" href="classOpenBabel_1_1OBStopwatch.shtml#a07aaf1227e4d645f15e0a964f54ef291">00078</a>     <span class="keywordtype">void</span> Start()
<a name="l00079"></a>00079     {
<a name="l00080"></a>00080       gettimeofday(&amp;start, NULL);
<a name="l00081"></a>00081     }
<a name="l00083"></a><a class="code" href="classOpenBabel_1_1OBStopwatch.shtml#a594d12c3e3c5ff7b9903a4bdc24ea1b4">00083</a>     <span class="keywordtype">double</span> Lap()
<a name="l00084"></a>00084     {
<a name="l00085"></a>00085       gettimeofday(&amp;stop, NULL);
<a name="l00086"></a>00086       <span class="keywordflow">return</span>((stop.tv_sec - start.tv_sec)
<a name="l00087"></a>00087              + (stop.tv_usec - start.tv_usec)/1000000.0);
<a name="l00088"></a>00088     }
<a name="l00089"></a>00089 <span class="preprocessor">#endif</span>
<a name="l00090"></a>00090 <span class="preprocessor"></span>
<a name="l00092"></a><a class="code" href="classOpenBabel_1_1OBStopwatch.shtml#a9e01ac3f5e0f092b6dffe54421ce9c33">00092</a>     <span class="keywordtype">double</span> Elapsed()
<a name="l00093"></a>00093     {
<a name="l00094"></a>00094       <span class="keywordflow">return</span>(Lap());
<a name="l00095"></a>00095     }
<a name="l00096"></a>00096   };
<a name="l00097"></a>00097 
<a name="l00098"></a>00098 
<a name="l00101"></a><a class="code" href="classOpenBabel_1_1OBSqrtTbl.shtml">00101</a>   <span class="keyword">class </span>OBAPI <a class="code" href="classOpenBabel_1_1OBSqrtTbl.shtml" title="Square Root lookup table - given a distance squared returns distance.">OBSqrtTbl</a>
<a name="l00102"></a>00102   {
<a name="l00103"></a>00103     <span class="keywordtype">double</span> _max,_incr,*_tbl;
<a name="l00104"></a>00104   <span class="keyword">public</span>:
<a name="l00105"></a><a class="code" href="classOpenBabel_1_1OBSqrtTbl.shtml#af238629f406442e9c3e03aab5f92e5db">00105</a>   <a class="code" href="classOpenBabel_1_1OBSqrtTbl.shtml" title="Square Root lookup table - given a distance squared returns distance.">OBSqrtTbl</a>():
<a name="l00106"></a>00106     _max(0.0), _incr(0.0),  _tbl(NULL)
<a name="l00107"></a>00107       { }
<a name="l00112"></a><a class="code" href="classOpenBabel_1_1OBSqrtTbl.shtml#a9184aa6879afeed8d2b2e9bdc9331fce">00112</a>   <a class="code" href="classOpenBabel_1_1OBSqrtTbl.shtml" title="Square Root lookup table - given a distance squared returns distance.">OBSqrtTbl</a>(<span class="keyword">const</span> <span class="keywordtype">double</span> max, <span class="keyword">const</span> <span class="keywordtype">double</span> incr):
<a name="l00113"></a>00113     _max(max*max), _incr(incr), _tbl(NULL)
<a name="l00114"></a>00114       {
<a name="l00115"></a>00115         Init(max,incr);
<a name="l00116"></a>00116       }
<a name="l00117"></a><a class="code" href="classOpenBabel_1_1OBSqrtTbl.shtml#ac88c1cb13c0f062f244660ed46baea4d">00117</a>     ~<a class="code" href="classOpenBabel_1_1OBSqrtTbl.shtml" title="Square Root lookup table - given a distance squared returns distance.">OBSqrtTbl</a>()
<a name="l00118"></a>00118       {
<a name="l00119"></a>00119         <span class="keywordflow">if</span> (_tbl)
<a name="l00120"></a>00120           {
<a name="l00121"></a>00121             <span class="keyword">delete</span> [] _tbl;
<a name="l00122"></a>00122             _tbl = NULL;
<a name="l00123"></a>00123           }
<a name="l00124"></a>00124       }
<a name="l00127"></a><a class="code" href="classOpenBabel_1_1OBSqrtTbl.shtml#ae6ef1b74d5b395dc9598d5d86b913a5c">00127</a>     <span class="keywordtype">double</span> Sqrt(<span class="keywordtype">double</span> d2)<span class="keyword"> const</span>
<a name="l00128"></a>00128 <span class="keyword">    </span>{
<a name="l00129"></a>00129       <span class="keywordflow">if</span> (_tbl)
<a name="l00130"></a>00130         <span class="keywordflow">return</span>((d2 &lt; _max) ? _tbl[static_cast&lt;int&gt;(d2*_incr)]:sqrt(d2));
<a name="l00131"></a>00131       <span class="keywordflow">else</span>
<a name="l00132"></a>00132         <span class="keywordflow">return</span> 0.0;
<a name="l00133"></a>00133     }
<a name="l00137"></a><a class="code" href="classOpenBabel_1_1OBSqrtTbl.shtml#a01dd1b037ecbe7bd8d23b50689fa6b50">00137</a>     <span class="keywordtype">void</span> Init(<span class="keywordtype">double</span> max,<span class="keywordtype">double</span> incr)
<a name="l00138"></a>00138     {
<a name="l00139"></a>00139       <span class="comment">// parameters are potentially unneeded, but let&#39;s do this until we can</span>
<a name="l00140"></a>00140       <span class="comment">// deprecate them</span>
<a name="l00141"></a>00141       _max = max * max;
<a name="l00142"></a>00142       _incr = incr;
<a name="l00143"></a>00143 
<a name="l00144"></a>00144       <span class="comment">//array size needs to be large enough to account for fp error</span>
<a name="l00145"></a>00145       <span class="keywordtype">int</span> i;
<a name="l00146"></a>00146       <span class="keywordtype">double</span> r;
<a name="l00147"></a>00147       _tbl = <span class="keyword">new</span> <span class="keywordtype">double</span> [<span class="keyword">static_cast&lt;</span><span class="keywordtype">int</span><span class="keyword">&gt;</span>((_max/_incr)+10)];
<a name="l00148"></a>00148       <span class="keywordflow">for</span> (r = (_incr/2.0),i=0;r &lt;= _max;r += _incr,++i)
<a name="l00149"></a>00149         _tbl[i] = sqrt(r);
<a name="l00150"></a>00150 
<a name="l00151"></a>00151       _incr = 1/_incr;
<a name="l00152"></a>00152     }
<a name="l00153"></a>00153   };
<a name="l00154"></a>00154 
<a name="l00155"></a>00155   <span class="comment">//***RMS helper methods***/</span>
<a name="l00156"></a>00156 <span class="preprocessor">#ifndef __KCC</span>
<a name="l00157"></a>00157 <span class="preprocessor"></span>  <span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span> {
<a name="l00158"></a>00158   OBAPI <span class="keywordtype">void</span>  <a class="code" href="namespaceOpenBabel.shtml#a60625165cc16932d1c2f34976dbc54dd">rotate_coords</a>(<span class="keywordtype">double</span>*,<span class="keywordtype">double</span> m[3][3],<span class="keywordtype">unsigned</span>);
<a name="l00159"></a>00159   OBAPI <span class="keywordtype">double</span> <a class="code" href="namespaceOpenBabel.shtml#a25d610b9255993505f2dbdd9690d068f" title="Calculate the RMS deviation between the first N coordinates of *r and *f.">calc_rms</a>(<span class="keywordtype">double</span>*,<span class="keywordtype">double</span>*,<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>);
<a name="l00160"></a>00160   }
<a name="l00161"></a>00161 <span class="preprocessor">#else</span>
<a name="l00162"></a>00162 <span class="preprocessor"></span>  OBAPI <span class="keywordtype">void</span>  <a class="code" href="namespaceOpenBabel.shtml#a60625165cc16932d1c2f34976dbc54dd">rotate_coords</a>(<span class="keywordtype">double</span>*,<span class="keywordtype">double</span> m[3][3],<span class="keywordtype">unsigned</span>);
<a name="l00163"></a>00163   OBAPI <span class="keywordtype">double</span> <a class="code" href="namespaceOpenBabel.shtml#a25d610b9255993505f2dbdd9690d068f" title="Calculate the RMS deviation between the first N coordinates of *r and *f.">calc_rms</a>(<span class="keywordtype">double</span>*,<span class="keywordtype">double</span>*,<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>);
<a name="l00164"></a>00164 <span class="preprocessor">#endif</span>
<a name="l00165"></a>00165 <span class="preprocessor"></span> 
<a name="l00166"></a>00166 <span class="preprocessor">#ifndef SWIG</span>
<a name="l00167"></a>00167 <span class="preprocessor"></span>
<a name="l00168"></a>00168 
<a name="l00169"></a>00169   <span class="comment">// Documentation in obutil.cpp</span>
<a name="l00170"></a>00170   OBAPI <span class="keywordtype">void</span> <a class="code" href="namespaceOpenBabel.shtml#aae157b7c5a3145dff9e938888d41d46f" title="Shift the supplied string to uppercase.">ToUpper</a>(std::string&amp;);
<a name="l00171"></a>00171   OBAPI <span class="keywordtype">void</span> <a class="code" href="namespaceOpenBabel.shtml#aae157b7c5a3145dff9e938888d41d46f" title="Shift the supplied string to uppercase.">ToUpper</a>(<span class="keywordtype">char</span>*);
<a name="l00172"></a>00172   OBAPI <span class="keywordtype">void</span> <a class="code" href="namespaceOpenBabel.shtml#a8e8df618618aa53bf4cf202b0230c7ac" title="Shift the supplied string to lowercase.">ToLower</a>(std::string&amp;);
<a name="l00173"></a>00173   OBAPI <span class="keywordtype">void</span> <a class="code" href="namespaceOpenBabel.shtml#a8e8df618618aa53bf4cf202b0230c7ac" title="Shift the supplied string to lowercase.">ToLower</a>(<span class="keywordtype">char</span> *);
<a name="l00174"></a>00174   OBAPI <span class="keywordtype">void</span> <a class="code" href="namespaceOpenBabel.shtml#ae254bae8e13592739edfdf24b917a943">InvertCase</a>(std::string&amp;, <span class="keywordtype">int</span>);
<a name="l00175"></a>00175   OBAPI <span class="keywordtype">void</span> <a class="code" href="namespaceOpenBabel.shtml#ae254bae8e13592739edfdf24b917a943">InvertCase</a>(<span class="keywordtype">char</span> *);
<a name="l00177"></a>00177   OBAPI <span class="keywordtype">void</span> <a class="code" href="namespaceOpenBabel.shtml#ae7fd604c6cfd7cbb0067721106af8ca9" title="&quot;Clean&quot; the supplied atom type">CleanAtomType</a>(<span class="keywordtype">char</span>*);
<a name="l00179"></a>00179 
<a name="l00182"></a>00182   OBAPI <span class="keywordtype">bool</span> <a class="code" href="namespaceOpenBabel.shtml#a4216f2e0672bf6a9ee72d3029838a213">OBCompareInt</a>(<span class="keyword">const</span> <span class="keywordtype">int</span> &amp;a,<span class="keyword">const</span> <span class="keywordtype">int</span> &amp;b);
<a name="l00185"></a>00185   OBAPI <span class="keywordtype">bool</span> <a class="code" href="namespaceOpenBabel.shtml#abb48ec7a1b3301248a1147cf2dbbe600">OBCompareUnsigned</a>(<span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> &amp;a,<span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> &amp;b);
<a name="l00192"></a>00192   OBAPI <span class="keywordtype">bool</span> <a class="code" href="namespaceOpenBabel.shtml#a362770307f86a3b9acd494d9ccbbcf51" title="Comparison for doubles: returns fabs(a - b) &lt; epsilon.">IsNear</a>(<span class="keyword">const</span> <span class="keywordtype">double</span> &amp;, <span class="keyword">const</span> <span class="keywordtype">double</span> &amp;, <span class="keyword">const</span> <span class="keywordtype">double</span> epsilon=2e-6);
<a name="l00199"></a>00199   OBAPI <span class="keywordtype">bool</span> <a class="code" href="namespaceOpenBabel.shtml#a29e51098e105d63b04b5517299d1b772" title="Comparison for doubles: returns fabs(a) &lt; epsilon.">IsNearZero</a>(<span class="keyword">const</span> <span class="keywordtype">double</span> &amp;, <span class="keyword">const</span> <span class="keywordtype">double</span> epsilon=2e-6);
<a name="l00200"></a>00200   OBAPI <span class="keywordtype">bool</span> <a class="code" href="namespaceOpenBabel.shtml#a227ab5b29e8122dd6d8ac76d2b58778a" title="Comparison for nan (not a number)">IsNan</a>(<span class="keyword">const</span> <span class="keywordtype">double</span> &amp;);
<a name="l00207"></a><a class="code" href="namespaceOpenBabel.shtml#ae3802301a4e7c389095313a77861a959">00207</a>   OBAPI <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="namespaceOpenBabel.shtml#ae3802301a4e7c389095313a77861a959">IsNegligible</a>(<span class="keyword">const</span> <span class="keywordtype">double</span> &amp; a, <span class="keyword">const</span> <span class="keywordtype">double</span> &amp; b,
<a name="l00208"></a>00208                                  <span class="keyword">const</span> <span class="keywordtype">double</span> precision = 1e-11)
<a name="l00209"></a>00209   {
<a name="l00210"></a>00210     <span class="keywordflow">return</span>( fabs(a) &lt;= precision * fabs(b) );
<a name="l00211"></a>00211   }
<a name="l00229"></a><a class="code" href="namespaceOpenBabel.shtml#af464b3279bc3db8c58ca552ddb0e8e79">00229</a>   OBAPI <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="namespaceOpenBabel.shtml#af464b3279bc3db8c58ca552ddb0e8e79">IsApprox</a>(<span class="keyword">const</span> <span class="keywordtype">double</span> &amp; a, <span class="keyword">const</span> <span class="keywordtype">double</span> &amp; b,
<a name="l00230"></a>00230                              <span class="keyword">const</span> <span class="keywordtype">double</span> precision = 1e-11)
<a name="l00231"></a>00231   {
<a name="l00232"></a>00232     <span class="keywordflow">return</span>( fabs(a - b) &lt;= precision * std::min&lt;const double&gt;( fabs(a), fabs(b) ) );
<a name="l00233"></a>00233   }
<a name="l00235"></a><a class="code" href="namespaceOpenBabel.shtml#a470b9e69978e49f27b85b48077bd7c72">00235</a>   OBAPI <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="namespaceOpenBabel.shtml#a470b9e69978e49f27b85b48077bd7c72" title="Same as IsApprox(), but only for positive numbers. Faster.">IsApprox_pos</a>(<span class="keyword">const</span> <span class="keywordtype">double</span> &amp;a, <span class="keyword">const</span> <span class="keywordtype">double</span> &amp;b,
<a name="l00236"></a>00236                                  <span class="keyword">const</span> <span class="keywordtype">double</span> precision = 1e-11)
<a name="l00237"></a>00237   {
<a name="l00238"></a>00238     <span class="keywordflow">return</span>( fabs(a - b) &lt;= precision * std::min&lt;const double&gt;( a, b ) );
<a name="l00239"></a>00239   }
<a name="l00243"></a>00243   OBAPI <span class="keywordtype">bool</span> <a class="code" href="namespaceOpenBabel.shtml#a95b1c21368d148cb45ac6f604984c357" title="Tests whether its argument can be squared without triggering an overflow or underflow.">CanBeSquared</a>(<span class="keyword">const</span> <span class="keywordtype">double</span> &amp;);
<a name="l00244"></a>00244 
<a name="l00245"></a>00245   OBAPI <span class="keywordtype">bool</span> <a class="code" href="namespaceOpenBabel.shtml#a1e68658ca81568e214ebedb8f6c4bd10">SafeOpen</a>(std::ifstream &amp;fs, <span class="keyword">const</span> <span class="keywordtype">char</span> *filename);
<a name="l00246"></a>00246   OBAPI <span class="keywordtype">bool</span> <a class="code" href="namespaceOpenBabel.shtml#a1e68658ca81568e214ebedb8f6c4bd10">SafeOpen</a>(std::ofstream &amp;fs, <span class="keyword">const</span> <span class="keywordtype">char</span> *filename);
<a name="l00247"></a>00247 <span class="preprocessor">#endif</span>
<a name="l00248"></a>00248 <span class="preprocessor"></span>  <span class="comment">// (end part to be skipped by SWIG)</span>
<a name="l00249"></a>00249 
<a name="l00250"></a>00250   <span class="comment">//******************triple template*************************</span>
<a name="l00253"></a>00253 <span class="comment"></span>  <span class="keyword">template</span> &lt;<span class="keyword">class</span> T1, <span class="keyword">class</span> T2, <span class="keyword">class</span> T3&gt;
<a name="l00254"></a><a class="code" href="structOpenBabel_1_1triple.shtml">00254</a>     <span class="keyword">struct </span><a class="code" href="structOpenBabel_1_1triple.shtml" title="A 3-element templated, based on the design of the STL pair&lt;&gt;">triple</a>
<a name="l00255"></a>00255     {
<a name="l00256"></a>00256       <span class="comment">//type names for the values</span>
<a name="l00257"></a><a class="code" href="structOpenBabel_1_1triple.shtml#a2ff1057d713f47338b9b6c4a60e5ab87">00257</a>       <span class="keyword">typedef</span> T1 <a class="code" href="structOpenBabel_1_1triple.shtml#a2ff1057d713f47338b9b6c4a60e5ab87">first_type</a>;
<a name="l00258"></a><a class="code" href="structOpenBabel_1_1triple.shtml#a75b41637f35c1f6bbf8ec5c0ebb79728">00258</a>       <span class="keyword">typedef</span> T2 <a class="code" href="structOpenBabel_1_1triple.shtml#a75b41637f35c1f6bbf8ec5c0ebb79728">second_type</a>;
<a name="l00259"></a><a class="code" href="structOpenBabel_1_1triple.shtml#a32442a804e500a7dc9ecb4a3feeb143d">00259</a>       <span class="keyword">typedef</span> T3 <a class="code" href="structOpenBabel_1_1triple.shtml#a32442a804e500a7dc9ecb4a3feeb143d">third_type</a>;
<a name="l00260"></a>00260 
<a name="l00261"></a>00261       <span class="comment">//member</span>
<a name="l00262"></a><a class="code" href="structOpenBabel_1_1triple.shtml#ae885a6822c40e26649c9dd8b476942f8">00262</a>       T1 <a class="code" href="structOpenBabel_1_1triple.shtml#ae885a6822c40e26649c9dd8b476942f8">first</a>;
<a name="l00263"></a><a class="code" href="structOpenBabel_1_1triple.shtml#a9a8a97f32d498c09c0f1f82c8a67bd6f">00263</a>       T2 <a class="code" href="structOpenBabel_1_1triple.shtml#a9a8a97f32d498c09c0f1f82c8a67bd6f">second</a>;
<a name="l00264"></a><a class="code" href="structOpenBabel_1_1triple.shtml#ab02b336e2ad870f773affd07b0f68ef8">00264</a>       T3 <a class="code" href="structOpenBabel_1_1triple.shtml#ab02b336e2ad870f773affd07b0f68ef8">third</a>;
<a name="l00265"></a>00265 
<a name="l00269"></a><a class="code" href="structOpenBabel_1_1triple.shtml#a87aa95191f543f716183080f7bfcbfd0">00269</a>     <a class="code" href="structOpenBabel_1_1triple.shtml#a87aa95191f543f716183080f7bfcbfd0">triple</a>():
<a name="l00270"></a>00270       <a class="code" href="structOpenBabel_1_1triple.shtml#ae885a6822c40e26649c9dd8b476942f8">first</a>(T1()),<a class="code" href="structOpenBabel_1_1triple.shtml#a9a8a97f32d498c09c0f1f82c8a67bd6f">second</a>(T2()),<a class="code" href="structOpenBabel_1_1triple.shtml#ab02b336e2ad870f773affd07b0f68ef8">third</a>(T3())
<a name="l00271"></a>00271       {}
<a name="l00272"></a>00272 
<a name="l00274"></a><a class="code" href="structOpenBabel_1_1triple.shtml#aa519d64ebe02cf77be9fce8401bbfc59">00274</a>     <a class="code" href="structOpenBabel_1_1triple.shtml#a87aa95191f543f716183080f7bfcbfd0">triple</a>(<span class="keyword">const</span> T1 &amp;a, <span class="keyword">const</span> T2 &amp;b, <span class="keyword">const</span> T3 &amp;c):
<a name="l00275"></a>00275       <a class="code" href="structOpenBabel_1_1triple.shtml#ae885a6822c40e26649c9dd8b476942f8">first</a>(a), <a class="code" href="structOpenBabel_1_1triple.shtml#a9a8a97f32d498c09c0f1f82c8a67bd6f">second</a>(b), <a class="code" href="structOpenBabel_1_1triple.shtml#ab02b336e2ad870f773affd07b0f68ef8">third</a>(c)
<a name="l00276"></a>00276       {}
<a name="l00277"></a>00277 
<a name="l00279"></a>00279       <span class="keyword">template</span>&lt;<span class="keyword">class</span> U, <span class="keyword">class</span> V, <span class="keyword">class</span> W&gt;
<a name="l00280"></a><a class="code" href="structOpenBabel_1_1triple.shtml#afee4dc46913f1067c86f65ac9de2886f">00280</a>         <a class="code" href="structOpenBabel_1_1triple.shtml#a87aa95191f543f716183080f7bfcbfd0">triple</a>(<span class="keyword">const</span> <a class="code" href="structOpenBabel_1_1triple.shtml" title="A 3-element templated, based on the design of the STL pair&lt;&gt;">triple&lt;U,V,W&gt;</a> &amp;t):
<a name="l00281"></a>00281         <a class="code" href="structOpenBabel_1_1triple.shtml#ae885a6822c40e26649c9dd8b476942f8">first</a>(t.<a class="code" href="structOpenBabel_1_1triple.shtml#ae885a6822c40e26649c9dd8b476942f8">first</a>), <a class="code" href="structOpenBabel_1_1triple.shtml#a9a8a97f32d498c09c0f1f82c8a67bd6f">second</a>(t.<a class="code" href="structOpenBabel_1_1triple.shtml#a9a8a97f32d498c09c0f1f82c8a67bd6f">second</a>), <a class="code" href="structOpenBabel_1_1triple.shtml#ab02b336e2ad870f773affd07b0f68ef8">third</a>(t.<a class="code" href="structOpenBabel_1_1triple.shtml#ab02b336e2ad870f773affd07b0f68ef8">third</a>)
<a name="l00282"></a>00282       {}
<a name="l00283"></a>00283 
<a name="l00284"></a>00284     };
<a name="l00285"></a>00285 
<a name="l00286"></a>00286   <span class="comment">//**************quad template********************</span>
<a name="l00289"></a>00289 <span class="comment"></span>  <span class="keyword">template</span> &lt;<span class="keyword">class</span> T1, <span class="keyword">class</span> T2, <span class="keyword">class</span> T3, <span class="keyword">class</span> T4&gt;
<a name="l00290"></a><a class="code" href="structOpenBabel_1_1quad.shtml">00290</a>     <span class="keyword">struct </span><a class="code" href="structOpenBabel_1_1quad.shtml" title="A 4-element templated, based on the design of the STL pair&lt;&gt;">quad</a>
<a name="l00291"></a>00291     {
<a name="l00292"></a>00292       <span class="comment">//type names for the values</span>
<a name="l00293"></a><a class="code" href="structOpenBabel_1_1quad.shtml#a2ff1057d713f47338b9b6c4a60e5ab87">00293</a>       <span class="keyword">typedef</span> T1 <a class="code" href="structOpenBabel_1_1quad.shtml#a2ff1057d713f47338b9b6c4a60e5ab87">first_type</a>;
<a name="l00294"></a><a class="code" href="structOpenBabel_1_1quad.shtml#a75b41637f35c1f6bbf8ec5c0ebb79728">00294</a>       <span class="keyword">typedef</span> T2 <a class="code" href="structOpenBabel_1_1quad.shtml#a75b41637f35c1f6bbf8ec5c0ebb79728">second_type</a>;
<a name="l00295"></a><a class="code" href="structOpenBabel_1_1quad.shtml#a32442a804e500a7dc9ecb4a3feeb143d">00295</a>       <span class="keyword">typedef</span> T3 <a class="code" href="structOpenBabel_1_1quad.shtml#a32442a804e500a7dc9ecb4a3feeb143d">third_type</a>;
<a name="l00296"></a><a class="code" href="structOpenBabel_1_1quad.shtml#a003e496cf073cdc37c84c12aecee9605">00296</a>       <span class="keyword">typedef</span> T4 <a class="code" href="structOpenBabel_1_1quad.shtml#a003e496cf073cdc37c84c12aecee9605">fourth_type</a>;
<a name="l00297"></a>00297 
<a name="l00298"></a>00298       <span class="comment">//member</span>
<a name="l00299"></a><a class="code" href="structOpenBabel_1_1quad.shtml#ae885a6822c40e26649c9dd8b476942f8">00299</a>       T1 <a class="code" href="structOpenBabel_1_1quad.shtml#ae885a6822c40e26649c9dd8b476942f8">first</a>;
<a name="l00300"></a><a class="code" href="structOpenBabel_1_1quad.shtml#a9a8a97f32d498c09c0f1f82c8a67bd6f">00300</a>       T2 <a class="code" href="structOpenBabel_1_1quad.shtml#a9a8a97f32d498c09c0f1f82c8a67bd6f">second</a>;
<a name="l00301"></a><a class="code" href="structOpenBabel_1_1quad.shtml#ab02b336e2ad870f773affd07b0f68ef8">00301</a>       T3 <a class="code" href="structOpenBabel_1_1quad.shtml#ab02b336e2ad870f773affd07b0f68ef8">third</a>;
<a name="l00302"></a><a class="code" href="structOpenBabel_1_1quad.shtml#a603db4ed74155df96d6d73e4287baf66">00302</a>       T4 <a class="code" href="structOpenBabel_1_1quad.shtml#a603db4ed74155df96d6d73e4287baf66">fourth</a>;
<a name="l00303"></a>00303 
<a name="l00307"></a><a class="code" href="structOpenBabel_1_1quad.shtml#a2e71f961e39f3cad1898d5adee3ab328">00307</a>     <a class="code" href="structOpenBabel_1_1quad.shtml#a2e71f961e39f3cad1898d5adee3ab328">quad</a>():
<a name="l00308"></a>00308       <a class="code" href="structOpenBabel_1_1quad.shtml#ae885a6822c40e26649c9dd8b476942f8">first</a>(T1()),<a class="code" href="structOpenBabel_1_1quad.shtml#a9a8a97f32d498c09c0f1f82c8a67bd6f">second</a>(T2()),<a class="code" href="structOpenBabel_1_1quad.shtml#ab02b336e2ad870f773affd07b0f68ef8">third</a>(T3()),<a class="code" href="structOpenBabel_1_1quad.shtml#a603db4ed74155df96d6d73e4287baf66">fourth</a>(T4())
<a name="l00309"></a>00309       {}
<a name="l00310"></a>00310 
<a name="l00312"></a><a class="code" href="structOpenBabel_1_1quad.shtml#abfcbd8a7eb6b09894cba7994ef1a3eac">00312</a>     <a class="code" href="structOpenBabel_1_1quad.shtml#a2e71f961e39f3cad1898d5adee3ab328">quad</a>(<span class="keyword">const</span> T1 &amp;a, <span class="keyword">const</span> T2 &amp;b, <span class="keyword">const</span> T3 &amp;c, <span class="keyword">const</span> T4 &amp;d):
<a name="l00313"></a>00313       <a class="code" href="structOpenBabel_1_1quad.shtml#ae885a6822c40e26649c9dd8b476942f8">first</a>(a), <a class="code" href="structOpenBabel_1_1quad.shtml#a9a8a97f32d498c09c0f1f82c8a67bd6f">second</a>(b), <a class="code" href="structOpenBabel_1_1quad.shtml#ab02b336e2ad870f773affd07b0f68ef8">third</a>(c), <a class="code" href="structOpenBabel_1_1quad.shtml#a603db4ed74155df96d6d73e4287baf66">fourth</a>(d)
<a name="l00314"></a>00314       {}
<a name="l00315"></a>00315 
<a name="l00317"></a>00317       <span class="keyword">template</span>&lt;<span class="keyword">class</span> U, <span class="keyword">class</span> V, <span class="keyword">class</span> W, <span class="keyword">class</span> X&gt;
<a name="l00318"></a><a class="code" href="structOpenBabel_1_1quad.shtml#afb54f6bdd9b1b58db2ca1b8adb78b16b">00318</a>         <a class="code" href="structOpenBabel_1_1quad.shtml#a2e71f961e39f3cad1898d5adee3ab328">quad</a>(<span class="keyword">const</span> <a class="code" href="structOpenBabel_1_1quad.shtml" title="A 4-element templated, based on the design of the STL pair&lt;&gt;">quad&lt;U,V,W,X&gt;</a> &amp;q):
<a name="l00319"></a>00319         <a class="code" href="structOpenBabel_1_1quad.shtml#ae885a6822c40e26649c9dd8b476942f8">first</a>(q.<a class="code" href="structOpenBabel_1_1quad.shtml#ae885a6822c40e26649c9dd8b476942f8">first</a>), <a class="code" href="structOpenBabel_1_1quad.shtml#a9a8a97f32d498c09c0f1f82c8a67bd6f">second</a>(q.<a class="code" href="structOpenBabel_1_1quad.shtml#a9a8a97f32d498c09c0f1f82c8a67bd6f">second</a>), <a class="code" href="structOpenBabel_1_1quad.shtml#ab02b336e2ad870f773affd07b0f68ef8">third</a>(q.<a class="code" href="structOpenBabel_1_1quad.shtml#ab02b336e2ad870f773affd07b0f68ef8">third</a>), <a class="code" href="structOpenBabel_1_1quad.shtml#a603db4ed74155df96d6d73e4287baf66">fourth</a>(q.<a class="code" href="structOpenBabel_1_1quad.shtml#a603db4ed74155df96d6d73e4287baf66">fourth</a>)
<a name="l00320"></a>00320       {}
<a name="l00321"></a>00321 
<a name="l00322"></a>00322     };
<a name="l00323"></a>00323 
<a name="l00324"></a>00324 } <span class="comment">// end namespace OpenBabel</span>
<a name="l00325"></a>00325 
<a name="l00326"></a>00326 <span class="preprocessor">#endif // OBUTIL_H</span>
<a name="l00327"></a>00327 <span class="preprocessor"></span>
</pre></div></div>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

</div><!-- end content -->

<!--#include file="footer.html" -->

<div id="footer">
<hr size="1">
<img src="http://openbabel.org/babel256.png" width="136" height="127" alt="" style="float: left;" />
<p>This file is part of the documentation for <a href="http://openbabel.org/wiki/">Open Babel</a>, version 2.3.</p>
<div class="bottom">
Documentation copyright &copy; 1998-2007, the <a href="http://openbabel.org/wiki/THANKS">Open Babel Developers</a>.<br>
Open Babel is hosted by: <a href="http://sourceforge.net">
<img src="http://sourceforge.net/sflogo.php?group_id=40728" 
width="88" height="31" border="0" alt="SourceForge Logo"></a><br>
Generated on Thu Oct 13 2011 16:08:07 by&nbsp;<a href="http://www.doxygen.org/"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.7.5.1.
</div>

</body>
</html>