add constructors
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2227 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
bc0d60e20a
commit
61fe4bb4d4
1 changed files with 44 additions and 3 deletions
|
|
@ -35,7 +35,7 @@
|
||||||
#ifndef __moGPUPermutationVector_H_
|
#ifndef __moGPUPermutationVector_H_
|
||||||
#define __moGPUPermutationVector_H_
|
#define __moGPUPermutationVector_H_
|
||||||
|
|
||||||
#include <GPUType/moGPUVector.h>
|
#include <GPUType/moGPUIntVector.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of Permutation vector representation on GPU.
|
* Implementation of Permutation vector representation on GPU.
|
||||||
|
|
@ -47,9 +47,27 @@ class moGPUPermutationVector: public moGPUIntVector<Fitness> {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
using moGPUVector<int, Fitness>::vect;
|
using moGPUIntVector<Fitness>::vect;
|
||||||
using moGPUVector<int, Fitness>::N;
|
using moGPUIntVector<Fitness>::N;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
|
||||||
|
moGPUPermutationVector() :
|
||||||
|
moGPUIntVector<Fitness> () {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*Constructor.
|
||||||
|
*@param _neighborhoodSize The neighborhood size.
|
||||||
|
*/
|
||||||
|
|
||||||
|
moGPUPermutationVector(unsigned _neighborhoodSize) :
|
||||||
|
moGPUIntVector<Fitness> (_neighborhoodSize) {
|
||||||
|
create();
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
*Initializer of random permuatation vector.
|
*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<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) {
|
||||||
|
moGPUPermutationVector<Fitness> tmp_vect(_size);
|
||||||
|
for (unsigned i = 0; i < N; i++)
|
||||||
|
tmp_vect.vect[i] = vect[i];
|
||||||
|
(tmp_vect).invalidate();
|
||||||
|
(*this) = tmp_vect;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue