add Copy Constructor + pur virtual size setter
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2222 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
522d4d2a25
commit
bf8f7306e4
1 changed files with 151 additions and 141 deletions
|
|
@ -32,8 +32,8 @@
|
|||
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*/
|
||||
|
||||
#ifndef _moGPUVector_H_
|
||||
#define _moGPUVector_H_
|
||||
#ifndef __moGPUVector_H_
|
||||
#define __moGPUVector_H_
|
||||
|
||||
#include <eo>
|
||||
|
||||
|
|
@ -72,6 +72,23 @@ public:
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
*Copy Constructor
|
||||
*@param _vector The vector passed to the function to determine the new content.
|
||||
*/
|
||||
|
||||
moGPUVector(const moGPUVector & _vector) {
|
||||
|
||||
N = _vector.N;
|
||||
vect = new ElemType[N];
|
||||
for (unsigned i = 0; i < N; i++)
|
||||
vect[i] = _vector.vect[i];
|
||||
if (!(_vector.invalid()))
|
||||
fitness(_vector.fitness());
|
||||
else
|
||||
(*this).invalidate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
|
@ -93,9 +110,9 @@ public:
|
|||
*@return a new vector.
|
||||
*/
|
||||
|
||||
virtual moGPUVector& operator=(const moGPUVector & _vector) {
|
||||
moGPUVector& operator=(const moGPUVector & _vector) {
|
||||
|
||||
if (!(N == _vector.N) && (N >= 1)) {
|
||||
if (!(N == _vector.N)) {
|
||||
delete[] vect;
|
||||
N = _vector.N;
|
||||
vect = new ElemType[N];
|
||||
|
|
@ -117,9 +134,8 @@ public:
|
|||
*/
|
||||
|
||||
inline __host__ __device__ const ElemType & operator[](unsigned _i) const {
|
||||
|
||||
if(_i<N)
|
||||
return vect[_i];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -129,9 +145,8 @@ public:
|
|||
*/
|
||||
|
||||
inline __host__ __device__ ElemType & operator[](unsigned _i) {
|
||||
|
||||
if(_i<N)
|
||||
return vect[_i];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -150,12 +165,7 @@ public:
|
|||
*@param _size the vector size
|
||||
*/
|
||||
|
||||
inline __host__ __device__ void setSize(unsigned _size) {
|
||||
|
||||
N=_size;
|
||||
|
||||
}
|
||||
|
||||
virtual inline __host__ void setSize(unsigned _size)=0;
|
||||
|
||||
/**
|
||||
* Write object. Called printOn since it prints the object _on_ a stream.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue