implement size setter
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2228 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
61fe4bb4d4
commit
38b9b80a35
1 changed files with 25 additions and 9 deletions
|
|
@ -70,15 +70,6 @@ public:
|
||||||
create();
|
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.
|
*Initializer of random real vector.
|
||||||
|
|
@ -88,6 +79,31 @@ public:
|
||||||
vect[i] = (float) rng.rand() / RAND_MAX;
|
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.
|
* Write object. Called printOn since it prints the object _on_ a stream.
|
||||||
* @param _os A std::ostream.
|
* @param _os A std::ostream.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue