gradient.h

Go to the documentation of this file.
00001 // -*- Mode: C++; tab-width: 2; -*-
00002 // vi: set ts=2:
00003 //
00004 // $Id: gradient.h,v 1.20.20.1 2007/05/18 12:02:44 oliver Exp $ 
00005 //
00006 // Author:
00007 //   Oliver Kohlbacher
00008 //
00009 
00010 // A conjugate gradient minimizer for geometry optimisation
00011 
00012 #ifndef BALL_MOLMEC_COMMON_GRADIENT_H 
00013 #define BALL_MOLMEC_COMMON_GRADIENT_H 
00014 
00015 #ifndef BALL_COMMON_H
00016 # include <BALL/common.h>
00017 #endif
00018 
00019 #ifndef BALL_MATHS_VECTOR3_H
00020 # include <BALL/MATHS/vector3.h>
00021 #endif
00022 
00023 #include <vector>
00024 
00025 namespace BALL 
00026 { 
00027   class AtomVector;
00028 
00043   class BALL_EXPORT Gradient
00044     : private std::vector<Vector3>
00045   {
00046     public:
00047 
00048     BALL_CREATE_DEEP(Gradient)
00049 
00050     
00053 
00056     typedef std::vector<Vector3>::iterator Iterator;
00057 
00060     typedef std::vector<Vector3>::const_iterator ConstIterator;
00061 
00064     typedef std::vector<Vector3>::reverse_iterator ReverseIterator;
00065 
00068     typedef std::vector<Vector3>::const_reverse_iterator ConstReverseIterator;
00069 
00070 
00072 
00075 
00078     Gradient();
00079 
00082     Gradient(const AtomVector& atoms);
00083 
00086     Gradient(const Gradient& gradient, bool deep = true);
00087 
00090     virtual ~Gradient();
00092 
00096 
00099     Gradient& operator = (const Gradient& rhs);
00100 
00103     Gradient& operator = (const AtomVector& rhs);
00104 
00107     void set(const Gradient& gradient);
00108 
00111     void set(const AtomVector& atoms);
00112 
00117     void negate();
00118 
00122     void normalize();
00123 
00127     double operator * (const Gradient& gradient) const;
00129 
00133 
00134     /*  Return the number of components of the gradient.
00135     */
00136     using std::vector<Vector3>::size;
00137 
00138     /* Return the component for an atom.
00139     */
00140     //?????: GCC3 using std::vector<Vector3>::operator [];
00141     const Vector3& operator [] (int i) const { return std::vector<Vector3>::operator [] (i); }
00142     Vector3& operator [] (int i) { return std::vector<Vector3>::operator [] (i); }
00143 
00146     void invalidate();
00147 
00150     bool isValid() const;
00152 
00153 
00157       
00160     //?????: GCC3 using std::vector<Vector3>::begin;
00161     Iterator begin() { return vector<Vector3>::begin(); }
00162     ConstIterator begin() const { return vector<Vector3>::begin(); }
00163 
00166     //?????: GCC3 using std::vector<Vector3>::end;
00167     Iterator end() { return vector<Vector3>::end(); }
00168     ConstIterator end() const { return vector<Vector3>::end(); }
00169 
00172     //?????: GCC3 using std::vector<Vector3>::begin;
00173     ReverseIterator rbegin() { return vector<Vector3>::rbegin(); }
00174     ConstReverseIterator rbegin() const { return vector<Vector3>::rbegin(); }
00175 
00178     //?????: GCC3 using std::vector<Vector3>::end;
00179     ReverseIterator rend() { return vector<Vector3>::rend(); }
00180     ConstReverseIterator rend() const { return vector<Vector3>::rend(); }
00182 
00186 
00189     double norm;
00190 
00193     double inv_norm;
00194 
00197     double rms;
00198 
00200 
00201     protected:
00202       
00203     /*_ The validity flag.
00204     */
00205     bool valid_;
00206     
00207     };
00208   } // end of namespace BALL
00209 
00210 #endif // BALL_MOLMEC_COMMON_GRADIENT_H