From 61fe4bb4d486a270e8f821ea1e2bbc41a5484598 Mon Sep 17 00:00:00 2001 From: boufaras Date: Thu, 12 May 2011 14:01:31 +0000 Subject: [PATCH] add constructors git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2227 331e1502-861f-0410-8da2-ba01fb791d7f --- .../src/GPUType/moGPUPermutationVector.h | 47 +++++++++++++++++-- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/branches/ParadisEO-GPU/src/GPUType/moGPUPermutationVector.h b/branches/ParadisEO-GPU/src/GPUType/moGPUPermutationVector.h index 6638a06d1..17cacf190 100644 --- a/branches/ParadisEO-GPU/src/GPUType/moGPUPermutationVector.h +++ b/branches/ParadisEO-GPU/src/GPUType/moGPUPermutationVector.h @@ -35,7 +35,7 @@ #ifndef __moGPUPermutationVector_H_ #define __moGPUPermutationVector_H_ -#include +#include /** * Implementation of Permutation vector representation on GPU. @@ -47,9 +47,27 @@ class moGPUPermutationVector: public moGPUIntVector { public: - using moGPUVector::vect; - using moGPUVector::N; + using moGPUIntVector::vect; + using moGPUIntVector::N; + /** + * Default constructor. + */ + + moGPUPermutationVector() : + moGPUIntVector () { + + } + + /** + *Constructor. + *@param _neighborhoodSize The neighborhood size. + */ + + moGPUPermutationVector(unsigned _neighborhoodSize) : + moGPUIntVector (_neighborhoodSize) { + create(); + } /** *Initializer of random permuatation vector. */ @@ -68,6 +86,29 @@ public: } } + /** + *Function inline to set the size of vector, called from host. + *@param _size the vector size + */ + + void setSize(unsigned _size) { + + if (_size < N) { + moGPUPermutationVector 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) { + moGPUPermutationVector tmp_vect(_size); + for (unsigned i = 0; i < N; i++) + tmp_vect.vect[i] = vect[i]; + (tmp_vect).invalidate(); + (*this) = tmp_vect; + } + + } + }; #endif