00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _EOVECTORPARTICLE_H
00026 #define _EOVECTORPARTICLE_H
00027
00028 #include <PO.h>
00029
00036 template < class FitT, class PositionType, class VelocityType > class eoVectorParticle:public PO < FitT >,
00037 public std::vector <
00038 PositionType >
00039 {
00040
00041 public:
00042
00043 using PO < FitT >::invalidate;
00044 using
00045 std::vector <
00046 PositionType >::operator[];
00047 using
00048 std::vector <
00049 PositionType >::begin;
00050 using
00051 std::vector <
00052 PositionType >::end;
00053 using
00054 std::vector <
00055 PositionType >::size;
00056
00057 typedef PositionType AtomType;
00058 typedef VelocityType ParticleVelocityType;
00059
00060
00067 eoVectorParticle (unsigned _size = 0,PositionType _position = PositionType (), VelocityType _velocity = VelocityType (), PositionType _bestPositions = PositionType ()):PO < FitT > (),std::vector < PositionType > (_size, _position), bestPositions (_size, _bestPositions), velocities (_size,
00068 _velocity)
00069 {
00070 }
00071
00072
00073
00074
00075 void
00076 position (const std::vector < PositionType > &_v)
00077 {
00078 if (_v.size () != size ())
00079 {
00080 if (size ())
00081 std::
00082 cout <<
00083 "Warning: Changing position size in eoVectorParticle assignation"
00084 << std::endl;
00085 resize (_v.size ());
00086 }
00087
00088 std::copy (_v.begin (), _v.end (), begin ());
00089 invalidate ();
00090 }
00091
00095 void
00096 resize (unsigned _size)
00097 {
00098 std::vector < PositionType >::resize (_size);
00099 bestPositions.resize (_size);
00100 velocities.resize (_size);
00101 }
00102
00103
00107 void
00108 resizeBestPositions (unsigned _size)
00109 {
00110 bestPositions.resize (_size);
00111 }
00112
00113
00117 void
00118 resizeVelocities (unsigned _size)
00119 {
00120 velocities.resize (_size);
00121 }
00122
00124 bool operator<(const eoVectorParticle<FitT, PositionType, VelocityType >& _eo) const
00125 {
00126 if (_eo.best() > this->best())
00127 return true;
00128 else
00129 return false;
00130 }
00131
00135 virtual void printOn(std::ostream& os) const
00136 {
00137 PO<FitT>::printOn(os);
00138 os << ' ';
00139 os << size() << ' ';
00140 std::copy(bestPositions.begin(), bestPositions.end(), std::ostream_iterator<AtomType>(os, " "));
00141 }
00142
00143
00144 std::vector < PositionType > bestPositions;
00145 std::vector < ParticleVelocityType > velocities;
00146
00147 };
00148
00149 #endif