eoVectorParticle.h

00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
00002 
00003 //-----------------------------------------------------------------------------
00004 // eoVectorParticle.h
00005 // (c) OPAC 2007
00006 /*
00007     Contact: paradiseo-help@lists.gforge.inria.fr
00008  */
00009 //-----------------------------------------------------------------------------
00010 
00011 #ifndef _EOVECTORPARTICLE_H
00012 #define _EOVECTORPARTICLE_H
00013 
00014 #include <PO.h>
00015 
00021 template < class FitT, class PositionType, class VelocityType > class eoVectorParticle:public PO < FitT >,
00022             public std::vector <
00023             PositionType >
00024 {
00025 
00026 public:
00027 
00028     using PO < FitT >::invalidate;
00029     using
00030     std::vector <
00031     PositionType >::operator[];
00032     using
00033     std::vector <
00034     PositionType >::begin;
00035     using
00036     std::vector <
00037     PositionType >::end;
00038     using
00039     std::vector <
00040     PositionType >::size;
00041 
00042     typedef
00043     PositionType
00044     AtomType;
00045     typedef
00046     VelocityType
00047     ParticleVelocityType;
00048 
00055     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,
00056                     velocity)
00057     {
00058     }
00059 
00060 
00061     // we can't have a Ctor from a std::vector, it would create ambiguity
00062     //  with the copy Ctor
00063     void
00064     position (const std::vector < PositionType > &_v)
00065     {
00066         if (_v.size () != size ())      // safety check
00067         {
00068             if (size ())                // NOT an initial empty std::vector
00069                 std::
00070                 cout <<
00071                 "Warning: Changing position size in eoVectorParticle assignation"
00072                 << std::endl;
00073             resize (_v.size ());
00074         }
00075 
00076         std::copy (_v.begin (), _v.end (), begin ());
00077         invalidate ();
00078     }
00079 
00083     void
00084     resize (unsigned _size)
00085     {
00086         std::vector < PositionType >::resize (_size);
00087         bestPositions.resize (_size);
00088         velocities.resize (_size);
00089     }
00090 
00091 
00095     void
00096     resizeBestPositions (unsigned _size)
00097     {
00098         bestPositions.resize (_size);
00099     }
00100     
00101     
00105     void
00106     resizeVelocities (unsigned _size)
00107     {
00108         velocities.resize (_size);
00109     }
00110     
00111 
00112     /* public attributes */
00113     std::vector < PositionType > bestPositions;
00114     std::vector < ParticleVelocityType > velocities;
00115 
00116 };
00117 
00118 #endif /*_EOVECTORPARTICLE_H*/

Generated on Thu Apr 19 11:02:28 2007 for EO by  doxygen 1.4.7