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 
57  typedef GV VectorType;
59  typedef std::size_t SizeType;
60 
66  static void clear(VectorType& g, std::size_t num_elem)
67  {
68  for (std::size_t i = 0; i < num_elem; i++) {
69  g[i][0] = 0;
70  g[i][1] = 0;
71  g[i][2] = 0;
72  }
73  }
74  };
75 
80  template <typename V>
81  struct GradientVectorTraits<Math::VectorArray<V> >
82  {
83 
87  typedef V ElementType;
89  typedef typename V::ValueType ValueType;
91  typedef typename VectorType::SizeType SizeType;
92 
98  static void clear(VectorType& g, std::size_t num_elem)
99  {
100  for (typename VectorType::ElementIterator it = g.getElementsBegin(), end = g.getElementsBegin() + num_elem; it != end; ++it)
101  it->clear(ValueType());
102  }
103  };
104 
109  template <typename V>
110  struct GradientVectorTraits<std::vector<V> >
111  {
112 
114  typedef std::vector<V> VectorType;
116  typedef V ElementType;
118  typedef typename V::ValueType ValueType;
120  typedef typename VectorType::size_type SizeType;
121 
127  static void clear(VectorType& g, std::size_t num_elem)
128  {
129  for (typename std::vector<V>::iterator it = g.begin(), end = g.begin() + num_elem; it != end; ++it)
130  it->clear(ValueType());
131  }
132  };
133  } // namespace ForceField
134 } // namespace CDPL
135 
136 #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:137
ConstElementIterator getElementsBegin() const
Returns a constant iterator pointing to the beginning of the array.
Definition: Array.hpp:892
std::size_t SizeType
The type of objects stored by the array.
Definition: Array.hpp:110
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:91
Math::VectorArray< V > VectorType
The gradient vector container type.
Definition: GradientVectorTraits.hpp:85
V::ValueType ValueType
The value type of the gradient vector components.
Definition: GradientVectorTraits.hpp:89
static void clear(VectorType &g, std::size_t num_elem)
Zeroes the first num_elem elements of the container g.
Definition: GradientVectorTraits.hpp:98
V ElementType
The gradient vector type stored in the container.
Definition: GradientVectorTraits.hpp:87
VectorType::size_type SizeType
The type used to specify gradient vector container element counts.
Definition: GradientVectorTraits.hpp:120
std::vector< V > VectorType
The gradient vector container type.
Definition: GradientVectorTraits.hpp:114
static void clear(VectorType &g, std::size_t num_elem)
Zeroes the first num_elem elements of the container g.
Definition: GradientVectorTraits.hpp:127
V ElementType
The gradient vector type stored in the container.
Definition: GradientVectorTraits.hpp:116
V::ValueType ValueType
The value type of the gradient vector components.
Definition: GradientVectorTraits.hpp:118
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:59
static void clear(VectorType &g, std::size_t num_elem)
Zeroes the first num_elem elements of the container g.
Definition: GradientVectorTraits.hpp:66
GV VectorType
The gradient vector container type.
Definition: GradientVectorTraits.hpp:57