Chemical Data Processing Library C++ API - Version 1.4.0
GradientVectorTraits.hpp
Go to the documentation of this file.
1 /*
2  * GradientVectorTraits.hpp
3  *
4  * This file is part of the Chemical Data Processing Toolkit
5  *
6  * Copyright (C) 2003 Thomas Seidel <thomas.seidel@univie.ac.at>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this library; see the file COPYING. If not, write to
20  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23 
29 #ifndef CDPL_FORCEFIELD_GRADIENTVECTORTRAITS_HPP
30 #define CDPL_FORCEFIELD_GRADIENTVECTORTRAITS_HPP
31 
32 #include <cstddef>
33 #include <vector>
34 
36 
37 
38 namespace CDPL
39 {
40 
41  namespace ForceField
42  {
43 
52  template <typename GV>
54  {
55 
59  typedef GV VectorType;
60 
64  typedef std::size_t SizeType;
65 
71  static void clear(VectorType& g, std::size_t num_elem)
72  {
73  for (std::size_t i = 0; i < num_elem; i++) {
74  g[i][0] = 0;
75  g[i][1] = 0;
76  g[i][2] = 0;
77  }
78  }
79  };
80 
85  template <typename V>
86  struct GradientVectorTraits<Math::VectorArray<V> >
87  {
88 
93 
97  typedef V ElementType;
98 
102  typedef typename V::ValueType ValueType;
103 
107  typedef typename VectorType::SizeType SizeType;
108 
114  static void clear(VectorType& g, std::size_t num_elem)
115  {
116  for (typename VectorType::ElementIterator it = g.getElementsBegin(), end = g.getElementsBegin() + num_elem; it != end; ++it)
117  it->clear(ValueType());
118  }
119  };
120 
125  template <typename V>
126  struct GradientVectorTraits<std::vector<V> >
127  {
128 
132  typedef std::vector<V> VectorType;
133 
137  typedef V ElementType;
138 
142  typedef typename V::ValueType ValueType;
143 
147  typedef typename VectorType::size_type SizeType;
148 
154  static void clear(VectorType& g, std::size_t num_elem)
155  {
156  for (typename std::vector<V>::iterator it = g.begin(), end = g.begin() + num_elem; it != end; ++it)
157  it->clear(ValueType());
158  }
159  };
160  } // namespace ForceField
161 } // namespace CDPL
162 
163 #endif // CDPL_FORCEFIELD_GRADIENTVECTORTRAITS_HPP
Definition of class CDPL::Math::VectorArray.
Array data type for the ordered storage of vector objects.
Definition: VectorArray.hpp:49
StorageType::iterator ElementIterator
A mutable random access iterator used to iterate over the elements of the array.
Definition: Array.hpp:140
ConstElementIterator getElementsBegin() const
Returns a constant iterator pointing to the beginning of the array.
Definition: Array.hpp:895
std::size_t SizeType
An unsigned integral type used to represent sizes and indices.
Definition: Array.hpp:113
constexpr unsigned int V
Specifies Vanadium.
Definition: AtomType.hpp:177
The namespace of the Chemical Data Processing Library.
VectorType::SizeType SizeType
The type used to specify gradient vector container element counts.
Definition: GradientVectorTraits.hpp:107
Math::VectorArray< V > VectorType
The gradient vector container type.
Definition: GradientVectorTraits.hpp:92
V::ValueType ValueType
The value type of the gradient vector components.
Definition: GradientVectorTraits.hpp:102
static void clear(VectorType &g, std::size_t num_elem)
Zeroes the first num_elem elements of the container g.
Definition: GradientVectorTraits.hpp:114
V ElementType
The gradient vector type stored in the container.
Definition: GradientVectorTraits.hpp:97
VectorType::size_type SizeType
The type used to specify gradient vector container element counts.
Definition: GradientVectorTraits.hpp:147
std::vector< V > VectorType
The gradient vector container type.
Definition: GradientVectorTraits.hpp:132
static void clear(VectorType &g, std::size_t num_elem)
Zeroes the first num_elem elements of the container g.
Definition: GradientVectorTraits.hpp:154
V ElementType
The gradient vector type stored in the container.
Definition: GradientVectorTraits.hpp:137
V::ValueType ValueType
The value type of the gradient vector components.
Definition: GradientVectorTraits.hpp:142
Generic primary traits template providing zero-initialization for a 3D gradient vector container of t...
Definition: GradientVectorTraits.hpp:54
std::size_t SizeType
The type used to specify gradient vector container element counts.
Definition: GradientVectorTraits.hpp:64
static void clear(VectorType &g, std::size_t num_elem)
Zeroes the first num_elem elements of the container g.
Definition: GradientVectorTraits.hpp:71
GV VectorType
The gradient vector container type.
Definition: GradientVectorTraits.hpp:59