From eb9fb85ee615dbb5f2e2edbff3aabfa4d5864845 Mon Sep 17 00:00:00 2001 From: boufaras Date: Thu, 12 May 2011 13:20:07 +0000 Subject: [PATCH] implement size setter for an integer vector git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2224 331e1502-861f-0410-8da2-ba01fb791d7f --- .../src/GPUType/moGPUIntVector.h | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/branches/ParadisEO-GPU/src/GPUType/moGPUIntVector.h b/branches/ParadisEO-GPU/src/GPUType/moGPUIntVector.h index c7bb783ed..f6c2d0386 100644 --- a/branches/ParadisEO-GPU/src/GPUType/moGPUIntVector.h +++ b/branches/ParadisEO-GPU/src/GPUType/moGPUIntVector.h @@ -78,6 +78,7 @@ public: moGPUIntVector& operator=(const moGPUIntVector & _vector) { moGPUVector::operator=(_vector); + return (*this); } /** @@ -86,7 +87,32 @@ public: virtual void create() { for (unsigned i = 0; i < N; i++) - vect[i] = (int) rng.rand() / RAND_MAX; + vect[i] = ((int) (rng.rand())) % N + 1; + + } + + /** + *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 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) { + moGPUIntVector tmp_vect(_size); + for (unsigned i = 0; i