Chemical Data Processing Library C++ API - Version 1.1.1
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
CDPL::ForceField::GradientVectorTraits< std::vector< V > >::clear
static void clear(VectorType &g, std::size_t num_elem)
Definition: GradientVectorTraits.hpp:86
CDPL::ForceField::GradientVectorTraits< Math::VectorArray< V > >::SizeType
VectorType::SizeType SizeType
Definition: GradientVectorTraits.hpp:68
CDPL::ForceField::GradientVectorTraits::SizeType
std::size_t SizeType
Definition: GradientVectorTraits.hpp:49
CDPL::ForceField::GradientVectorTraits< Math::VectorArray< V > >::VectorType
Math::VectorArray< V > VectorType
Definition: GradientVectorTraits.hpp:65
VectorArray.hpp
Definition of the class CDPL::Math::VectorArray.
CDPL::ForceField::GradientVectorTraits< std::vector< V > >::VectorType
std::vector< V > VectorType
Definition: GradientVectorTraits.hpp:81
CDPL::Util::Array< V >::SizeType
std::size_t SizeType
The type of objects stored by the array.
Definition: Array.hpp:110
CDPL::Math::VectorArray
An array for storing generic vector objects.
Definition: VectorArray.hpp:49
CDPL::ForceField::GradientVectorTraits< Math::VectorArray< V > >::clear
static void clear(VectorType &g, std::size_t num_elem)
Definition: GradientVectorTraits.hpp:70
CDPL::Util::Array::getElementsBegin
ConstElementIterator getElementsBegin() const
Returns a constant iterator pointing to the beginning of the array.
Definition: Array.hpp:884
CDPL::ForceField::GradientVectorTraits::VectorType
GV VectorType
Definition: GradientVectorTraits.hpp:48
CDPL::ForceField::GradientVectorTraits< Math::VectorArray< V > >::ValueType
V::ValueType ValueType
Definition: GradientVectorTraits.hpp:67
V
CDPL::ForceField::GradientVectorTraits::clear
static void clear(VectorType &g, std::size_t num_elem)
Definition: GradientVectorTraits.hpp:51
CDPL::ForceField::GradientVectorTraits
Definition: GradientVectorTraits.hpp:46
CDPL::ForceField::GradientVectorTraits< std::vector< V > >::ElementType
V ElementType
Definition: GradientVectorTraits.hpp:82
CDPL
The namespace of the Chemical Data Processing Library.
CDPL::ForceField::GradientVectorTraits< Math::VectorArray< V > >::ElementType
V ElementType
Definition: GradientVectorTraits.hpp:66
CDPL::ForceField::GradientVectorTraits< std::vector< V > >::ValueType
V::ValueType ValueType
Definition: GradientVectorTraits.hpp:83
CDPL::Util::Array< V >::ElementIterator
StorageType::iterator ElementIterator
A mutable random access iterator used to iterate over the elements of the array.
Definition: Array.hpp:137
CDPL::ForceField::GradientVectorTraits< std::vector< V > >::SizeType
VectorType::size_type SizeType
Definition: GradientVectorTraits.hpp:84