SDA (SDA flex)  7.2
Simulation of Diffusional Association
DTGrid1D.hpp
Go to the documentation of this file.
1 
9 #ifndef DTGRID1D_HPP_
10 #define DTGRID1D_HPP_
11 
12 template<typename T, typename K>
13 class DTGrid1D {
14 
15  ~DTGrid1D();
16 
17 protected:
21 
25 
26  /*
27  * WARNING!!! definining the variables below in here instead of in functions is not parallel-safe!
28  * Private members for use inside accessx! Do not use outside this function!
29  */
30 
31  /*ArrayMix <typename ArrayPrs <K>::PairArray,K> *Rarray;
32  typename ArrayPrs <K>::PairArray ** ptt1;
33  typename ArrayPrs <K>::PairArray * coo1;
34 
35  T ** ptt3;
36  typename ArrayPrs <K>::PairArray * coo3;
37 
38  bool key1;
39  short skey1;
40  int countdown_1;
41 
42  K checkpoint_11;
43  K checkpoint_12;
44  */
45 
47 
48  template <class M, class H>
49  friend class DTGrid2D;
50  template <class M, class H>
51  friend class DTGrid3D;
52  friend class DTGrid3Dex;
53 
54  void set_value_list_1D(K*,int);
55  void set_xcoord_list(K*,int);
56  void set_ptr_list_1D(K*,int);
57 
58  //ArrayMix <typename ArrayPrs <K>::PairArray,K> * accessx(int);
59  typename ArrayPrs <K>::PairArray * accessx(int);
60  typename ArrayPrs <K>::PairArray * accessx2(int);
61  T * getVoxelxyz(T*, int, int, int);
62 
63  void Reset_pointers_1D(void);
64 };
65 
67 template <typename T, typename K>
69  delete Value_List_1D;
70  delete Xcoord_List;
71  delete Ptr_List_1D;
72 }
73 
75 
81 template <typename T, typename K>
82 void DTGrid1D<T,K>::set_value_list_1D(K* values, int length){
83  Value_List_1D = new (std::nothrow) ArrayPrs <K>;
84  Value_List_1D->Set_Pair_Array_Values(values,length);
85  Length_of_Value_List_1D = length;
86 }
87 
89 
94 template <typename T, typename K>
95 void DTGrid1D<T,K>::set_xcoord_list(K* values, int length){
96  Xcoord_List = new (std::nothrow) ArrayPrs <K>;
97  Xcoord_List->Set_Pair_Array_Values(values,length);
98  Length_of_Xcoord_List = length;
99  set_countdown_1 = length -1;
100 }
101 
103 
108 template <typename T, typename K>
109 void DTGrid1D<T,K>::set_ptr_list_1D(K* values, int length){
110  Ptr_List_1D = new (std::nothrow) ArrayPtr <T,K>;
111  Ptr_List_1D->Set_Pointer_Array_Values(Value_List_1D->PArray,values,Length_of_Value_List_1D,length);
112  Length_of_Ptr_List_1D = length;
113 }
114 
116 
119 /*template <typename T, typename K>
120 void DTGrid1D<T,K>::Reset_pointers_1D(void){
121  Value_List_1D->Reset_Set_Pair_Array_Values();
122  Xcoord_List->Reset_Set_Pair_Array_Values();
123  Ptr_List_1D->Reset_Set_Pointer_Array_Values();
124 }*/
125 
127 
131 template <typename T, typename K>
133 
134  bool key1 = false; // a local logical operation variable.
135  int countdown_1 = set_countdown_1; // Use the predetermined number of connected components in the 1D tubular grid.
136 
137  typename ArrayPrs <K>::PairArray ** ptt1 = Ptr_List_1D->PtrArray; // a temporary pointer to store an acc array member.
138  typename ArrayPrs <K>::PairArray * coo1 = Xcoord_List->PArray; // a temporary pointer to store an xCoord array pair.
139 
140  // iterate over the connected components in DTGrid1D
141  for (;countdown_1>0;countdown_1--){
142  // check whether index a is inside one of the connected components using the xCoord index array.
143  key1 = a>=coo1->v1 ? (a<=coo1->v2 ? true : false) : false;
144  if (key1 == true){
145  return *(ptt1) + a - coo1->v1;
146  }
147  else {
148  // increment the pointer for the next connected component.
149  ++ptt1;
150  ++coo1;
151  continue;
152  }
153  }
154  return NULL;
155 }
156 
158 
162 template <typename T, typename K>
164 
165  // Same as that of accessx
166  bool key1 = false;
167  typename ArrayPrs <K>::PairArray ** ptt1 = Ptr_List_1D->PtrArray;
168  typename ArrayPrs <K>::PairArray * coo1 = Xcoord_List->PArray;
169 
171 
175  key1 = a>=coo1->v1 ? (a<=coo1->v2 ? true : false) : false;
176  if (key1 == true){
177  return *(ptt1) + a - coo1->v1;
178  }
179  else
180  return NULL;
181 }
182 
183 /*template <typename T, typename K>
184 T * DTGrid1D<T,K>::getVoxelxyz(T * Voxel, int a, int b, int c){
185 
186  int ainc = a+1;
187  short skey1 = 0;
188  int countdown_1 = Length_of_Xcoord_List-1;
189 
190  typename ArrayPrs <K>::PairArray ** ptt1 = Ptr_List_1D->PtrArray;
191  typename ArrayPrs <K>::PairArray * coo1 = Xcoord_List->PArray;
192 
193  for (;countdown_1>0;countdown_1--){
194  skey1 = a>=coo1->v1 ? (ainc<=coo1->v2 ? 1 : 2 ) : (ainc>=coo1->v1 ? 3 : 0);
195  //key1 = a>=coo1->v1 ? (a<=coo1->v2 ? true : false) : false;
196  switch (skey1)
197  {
198  case 0:
199  ++ptt1;
200  ++coo1;
201  break;
202  case 1:
203  getVoxelyz(Voxel, 0,b,c, *(ptt1) + a - coo1->v1);
204  getVoxelyz(Voxel, 1,b,c, *(ptt1) + ainc - coo1->v1);
205  return Voxel;
206  case 2:
207  getVoxelyz(Voxel, 0,b,c, *(ptt1) + a - coo1->v1);
208  return Voxel;
209  case 3:
210  getVoxelyz(Voxel, 1,b,c, *(ptt1) + ainc - coo1->v1);
211  return Voxel;
212  }
213  }
214  return Voxel;
215 }*/
216 
217 #endif /* DTGRID1D_HPP_ */
Definition: ArrayPrs.hpp:42
K v2
index into the icoord array (min connected component)
Definition: ArrayPrs.hpp:45
K v1
Definition: ArrayPrs.hpp:44
Definition: ArrayPrs.hpp:19
void Set_Pair_Array_Values(K *, int)
Setup the array that stores the complete icoord values.
Definition: ArrayPrs.hpp:74
Definition: ArrayPtr.hpp:20
void Set_Pointer_Array_Values(typename ArrayPrs< K >::PairArray *, K *, int, int)
Setup the array that stores the IndexPair values.
Definition: ArrayPtr.hpp:108
Definition: DTGrid1D.hpp:13
ArrayPrs< K >::PairArray * accessx2(int)
A more compact version of the random access function of DTGrid1D class.
Definition: DTGrid1D.hpp:163
void set_value_list_1D(K *, int)
DTGrid1D 'value' array setup.
Definition: DTGrid1D.hpp:82
ArrayPtr< T, K > * Ptr_List_1D
Definition: DTGrid1D.hpp:20
void set_xcoord_list(K *, int)
xCoord array setup
Definition: DTGrid1D.hpp:95
ArrayPrs< K > * Value_List_1D
Definition: DTGrid1D.hpp:18
int Length_of_Ptr_List_1D
Definition: DTGrid1D.hpp:24
void set_ptr_list_1D(K *, int)
acc (1D) array setup
Definition: DTGrid1D.hpp:109
int set_countdown_1
Definition: DTGrid1D.hpp:46
ArrayPrs< K >::PairArray * accessx(int)
Reset pointers for random access. Similar to that for DT-Grid2D.
Definition: DTGrid1D.hpp:132
~DTGrid1D()
DTGrid3D destructor.
Definition: DTGrid1D.hpp:68
T * getVoxelxyz(T *, int, int, int)
ArrayPrs< K > * Xcoord_List
Definition: DTGrid1D.hpp:19
int Length_of_Xcoord_List
Definition: DTGrid1D.hpp:23
int Length_of_Value_List_1D
Definition: DTGrid1D.hpp:22
void Reset_pointers_1D(void)
Definition: DTGrid2D.hpp:17
Definition: DTGrid3D.hpp:65
Definition: DTGrid3Dex.hpp:73
Imprint/Privacy