implement size setter

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2228 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
boufaras 2011-05-12 14:03:01 +00:00
commit 38b9b80a35

View file

@ -70,15 +70,6 @@ public:
create();
}
/**
*Assignment operator
*@param _vector The vector passed to the function to fix the new content.
*@return a new vector.
*/
moGPURealVector& operator=(const moGPURealVector & _vector) {
moGPUVector<float, Fitness>::operator=(_vector);
}
/**
*Initializer of random real vector.
@ -88,6 +79,31 @@ public:
vect[i] = (float) rng.rand() / RAND_MAX;
}
/**
*Function inline to set the size of vector, called from host.
*@param _size the vector size
*/
virtual inline __host__ void setSize(unsigned _size) {
if(_size<N) {
moGPURealVector<Fitness> tmp_vect(_size);
for (unsigned i = 0; i < tmp_vect.N; i++)
tmp_vect.vect[i]= vect[i];
(tmp_vect).invalidate();
(*this)=tmp_vect;
}
else if(_size>N) {
moGPURealVector<Fitness> tmp_vect(_size);
for (unsigned i = 0; i <N; i++)
tmp_vect.vect[i]= vect[i];
(tmp_vect).invalidate();
(*this)=tmp_vect;
}
}
/**
* Write object. Called printOn since it prints the object _on_ a stream.
* @param _os A std::ostream.