VinaLC: Parallel Molecular Docking Program

Biochemical and Biophysical Systems Group
VinaLC version: 1.1.2

grid_dim.h
Go to the documentation of this file.
1 /*
2 
3  Copyright (c) 2006-2010, The Scripps Research Institute
4 
5  Licensed under the Apache License, Version 2.0 (the "License");
6  you may not use this file except in compliance with the License.
7  You may obtain a copy of the License at
8 
9  http://www.apache.org/licenses/LICENSE-2.0
10 
11  Unless required by applicable law or agreed to in writing, software
12  distributed under the License is distributed on an "AS IS" BASIS,
13  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  See the License for the specific language governing permissions and
15  limitations under the License.
16 
17  Author: Dr. Oleg Trott <ot14@columbia.edu>,
18  The Olson Lab,
19  The Scripps Research Institute
20 
21 */
22 
23 #ifndef VINA_GRID_DIM_H
24 #define VINA_GRID_DIM_H
25 
26 #include <boost/array.hpp>
27 
28 #include "common.h"
29 
30 struct grid_dim {
33  sz n; // number of intervals == number of sample points - 1
34  grid_dim() : begin(0), end(0), n(0) {}
35  fl span() const { return end - begin; }
36  bool enabled() const { return (n > 0); }
37 private:
39  template<class Archive>
40  void serialize(Archive& ar, const unsigned version) {
41  ar & begin;
42  ar & end;
43  ar & n;
44  }
45 };
46 
47 inline bool eq(const grid_dim& a, const grid_dim& b) {
48  return a.n == b.n && eq(a.begin, b.begin) && eq(a.end, b.end);
49 }
50 
51 typedef boost::array<grid_dim, 3> grid_dims;
52 
53 inline bool eq(const grid_dims& a, const grid_dims& b) {
54  return eq(a[0], b[0]) && eq(a[1], b[1]) && eq(a[2], b[2]);
55 }
56 
57 inline void print(const grid_dims& gd, std::ostream& out = std::cout) {
58  VINA_FOR_IN(i, gd)
59  std::cout << gd[i].n << " [" << gd[i].begin << " .. " << gd[i].end << "]\n";
60 }
61 
62 inline vec grid_dims_begin(const grid_dims& gd) {
63  vec tmp;
64  VINA_FOR_IN(i, gd)
65  tmp[i] = gd[i].begin;
66  return tmp;
67 }
68 
69 inline vec grid_dims_end(const grid_dims& gd) {
70  vec tmp;
71  VINA_FOR_IN(i, gd)
72  tmp[i] = gd[i].end;
73  return tmp;
74 }
75 
76 #endif