1 |
|
|
/*************************************** |
2 |
|
|
Auteur : Pierre Aubert |
3 |
|
|
Mail : pierre.aubert@lapp.in2p3.fr |
4 |
|
|
Licence : CeCILL-C |
5 |
|
|
****************************************/ |
6 |
|
|
|
7 |
|
|
#ifndef __PBLOCK_IMPL_H__ |
8 |
|
|
#define __PBLOCK_IMPL_H__ |
9 |
|
|
|
10 |
|
|
#include "PBlock.h" |
11 |
|
|
|
12 |
|
|
///Default constructeur of PBlock |
13 |
|
|
/** @param allocMode : allocation mode (AllocMode::NONE, AllocMode::ALIGNED, AllocMode::PADDING) |
14 |
|
|
* @param nbElement : number of elements of the PBlock |
15 |
|
|
*/ |
16 |
|
|
template<typename T> |
17 |
|
|
PBlock<T>::PBlock(AllocMode::AllocMode allocMode, size_t nbElement) |
18 |
|
|
:PTensor<T>(allocMode, nbElement) |
19 |
|
|
{ |
20 |
|
|
initialisationPBlock(); |
21 |
|
|
} |
22 |
|
|
|
23 |
|
|
///Default constructeur of PBlock |
24 |
|
|
/** @param allocMode : allocation mode (AllocMode::NONE, AllocMode::ALIGNED, AllocMode::PADDING) |
25 |
|
|
* @param nbRow : number of rows to be allocated |
26 |
|
|
* @param nbCol : number of columns to be allocated |
27 |
|
|
*/ |
28 |
|
|
template<typename T> |
29 |
|
|
PBlock<T>::PBlock(AllocMode::AllocMode allocMode, size_t nbRow, size_t nbCol) |
30 |
|
|
:PTensor<T>(allocMode, nbRow, nbCol) |
31 |
|
|
{ |
32 |
|
|
initialisationPBlock(); |
33 |
|
|
} |
34 |
|
|
|
35 |
|
|
///Default constructeur of PBlock |
36 |
|
|
/** @param allocMode : allocation mode (AllocMode::NONE, AllocMode::ALIGNED, AllocMode::PADDING) |
37 |
|
|
* @param nbSlice : number of slices to be allocated |
38 |
|
|
* @param nbRow : number of rows to be allocated |
39 |
|
|
* @param nbCol : number of columns to be allocated |
40 |
|
|
*/ |
41 |
|
|
template<typename T> |
42 |
|
|
PBlock<T>::PBlock(AllocMode::AllocMode allocMode, size_t nbSlice, size_t nbRow, size_t nbCol) |
43 |
|
|
:PTensor<T>(allocMode, nbSlice, nbRow, nbCol) |
44 |
|
|
{ |
45 |
|
|
initialisationPBlock(); |
46 |
|
|
} |
47 |
|
|
|
48 |
|
|
///Default constructeur of PBlock |
49 |
|
|
/** @param allocMode : allocation mode (AllocMode::NONE, AllocMode::ALIGNED, AllocMode::PADDING) |
50 |
|
|
* @param tabShape : shape of the block |
51 |
|
|
* @param nbDim : number of dimensions of the block |
52 |
|
|
*/ |
53 |
|
|
template<typename T> |
54 |
|
142 |
PBlock<T>::PBlock(AllocMode::AllocMode allocMode, const size_t * tabShape, size_t nbDim) |
55 |
|
142 |
:PTensor<T>(allocMode, tabShape, nbDim) |
56 |
|
|
{ |
57 |
|
142 |
initialisationPBlock(); |
58 |
|
142 |
} |
59 |
|
|
|
60 |
|
|
///Copy constructor of PBlock |
61 |
|
|
/** @param other : class to copy |
62 |
|
|
*/ |
63 |
|
|
template<typename T> |
64 |
|
|
PBlock<T>::PBlock(const PBlock<T> & other) |
65 |
|
|
:PTensor<T>(other) |
66 |
|
|
{ |
67 |
|
|
initialisationPBlock(); |
68 |
|
|
copyPBlock(other); |
69 |
|
|
} |
70 |
|
|
|
71 |
|
|
///Destructor of PBlock |
72 |
|
|
template<typename T> |
73 |
|
284 |
PBlock<T>::~PBlock(){ |
74 |
|
284 |
if(p_location != NULL){ |
75 |
✓✗ |
284 |
delete [] p_location; |
76 |
|
|
} |
77 |
|
|
} |
78 |
|
|
|
79 |
|
|
///Definition of equal operator of PBlock |
80 |
|
|
/** @param other : class to copy |
81 |
|
|
* @return copied class |
82 |
|
|
*/ |
83 |
|
|
template<typename T> |
84 |
|
|
PBlock<T> & PBlock<T>::operator = (const PBlock<T> & other){ |
85 |
|
|
copyPTensor(other); |
86 |
|
|
copyPBlock(other); |
87 |
|
|
return *this; |
88 |
|
|
} |
89 |
|
|
|
90 |
|
|
///Set the location of the current PBlock |
91 |
|
|
/** @param idxRow : location of the current PBlock in rows |
92 |
|
|
* @param idxCol : location of the current PBlock in columns |
93 |
|
|
*/ |
94 |
|
|
template<typename T> |
95 |
|
142 |
void PBlock<T>::setLocation(size_t idxRow, size_t idxCol){ |
96 |
✓✗ |
142 |
if(PTensor<T>::getNbDim() >= 2lu){ |
97 |
✓✗ |
142 |
if(p_location == NULL){ |
98 |
|
142 |
p_location = new size_t[2lu]; |
99 |
|
|
} |
100 |
|
|
}else{ |
101 |
|
|
throw std::runtime_error("PBlock<T>::setLocation : at least 2 dimensions PBlock"); |
102 |
|
|
} |
103 |
|
142 |
p_location[0lu] = idxRow; |
104 |
|
142 |
p_location[1lu] = idxCol; |
105 |
|
142 |
} |
106 |
|
|
|
107 |
|
|
///Get the location of the PBlock in rows |
108 |
|
|
/** @return location of the PBlock in rows |
109 |
|
|
*/ |
110 |
|
|
template<typename T> |
111 |
|
58765 |
size_t PBlock<T>::getLocationRow() const{ |
112 |
✓✗ |
58765 |
if(p_location != NULL){ |
113 |
|
58765 |
return p_location[0lu]; |
114 |
|
|
}else{ |
115 |
|
|
return 0lu; |
116 |
|
|
} |
117 |
|
|
} |
118 |
|
|
|
119 |
|
|
///Get the location of the PBlock in columns |
120 |
|
|
/** @return location of the PBlock in columns |
121 |
|
|
*/ |
122 |
|
|
template<typename T> |
123 |
|
58765 |
size_t PBlock<T>::getLocationCol() const{ |
124 |
|
58765 |
size_t nbDim(PTensor<T>::getNbDim()); |
125 |
✓✗ |
58765 |
if(nbDim >= 2lu){ |
126 |
|
58765 |
return p_location[1lu]; |
127 |
|
|
}else{ |
128 |
|
|
return 0lu; |
129 |
|
|
} |
130 |
|
|
} |
131 |
|
|
|
132 |
|
|
///Initialise the PBlock |
133 |
|
|
template<typename T> |
134 |
|
142 |
void PBlock<T>::initialisationPBlock(){ |
135 |
|
142 |
p_location = NULL; |
136 |
|
142 |
} |
137 |
|
|
|
138 |
|
|
///Copy function of PBlock |
139 |
|
|
/** @param other : class to copy |
140 |
|
|
*/ |
141 |
|
|
template<typename T> |
142 |
|
|
void PBlock<T>::copyPBlock(const PBlock<T> & other){ |
143 |
|
|
tensor_copyShape(p_location, other.p_location, other.p_nbDimension); |
144 |
|
|
} |
145 |
|
|
|
146 |
|
|
|
147 |
|
|
#endif |
148 |
|
|
|