Chemical Data Processing Library C++ API - Version 1.2.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 
44  template <typename GV>
46  {
47 
48  typedef GV VectorType;
49  typedef std::size_t SizeType;
50 
51  static void clear(VectorType& g, std::size_t num_elem)
52  {
53  for (std::size_t i = 0; i < num_elem; i++) {
54  g[i][0] = 0;
55  g[i][1] = 0;
56  g[i][2] = 0;
57  }
58  }
59  };
60 
61  template <typename V>
62  struct GradientVectorTraits<Math::VectorArray<V> >
63  {
64 
66  typedef V ElementType;
67  typedef typename V::ValueType ValueType;
68  typedef typename VectorType::SizeType SizeType;
69 
70  static void clear(VectorType& g, std::size_t num_elem)
71  {
72  for (typename VectorType::ElementIterator it = g.getElementsBegin(), end = g.getElementsBegin() + num_elem; it != end; ++it)
73  it->clear(ValueType());
74  }
75  };
76 
77  template <typename V>
78  struct GradientVectorTraits<std::vector<V> >
79  {
80 
81  typedef std::vector<V> VectorType;
82  typedef V ElementType;
83  typedef typename V::ValueType ValueType;
84  typedef typename VectorType::size_type SizeType;
85 
86  static void clear(VectorType& g, std::size_t num_elem)
87  {
88  for (typename std::vector<V>::iterator it = g.begin(), end = g.begin() + num_elem; it != end; ++it)
89  it->clear(ValueType());
90  }
91  };
92  } // namespace ForceField
93 } // namespace CDPL
94 
95 #endif // CDPL_FORCEFIELD_GRADIENTVECTORTRAITS_HPP
Definition of the class CDPL::Math::VectorArray.
An array for storing generic 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:884
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
Definition: GradientVectorTraits.hpp:68
Math::VectorArray< V > VectorType
Definition: GradientVectorTraits.hpp:65
V::ValueType ValueType
Definition: GradientVectorTraits.hpp:67
static void clear(VectorType &g, std::size_t num_elem)
Definition: GradientVectorTraits.hpp:70
V ElementType
Definition: GradientVectorTraits.hpp:66
VectorType::size_type SizeType
Definition: GradientVectorTraits.hpp:84
std::vector< V > VectorType
Definition: GradientVectorTraits.hpp:81
static void clear(VectorType &g, std::size_t num_elem)
Definition: GradientVectorTraits.hpp:86
V ElementType
Definition: GradientVectorTraits.hpp:82
V::ValueType ValueType
Definition: GradientVectorTraits.hpp:83
Definition: GradientVectorTraits.hpp:46
std::size_t SizeType
Definition: GradientVectorTraits.hpp:49
static void clear(VectorType &g, std::size_t num_elem)
Definition: GradientVectorTraits.hpp:51
GV VectorType
Definition: GradientVectorTraits.hpp:48