3dpcp/include/slam6d/cuda/CSystem.icc
2012-09-16 14:33:11 +02:00

45 lines
1.3 KiB
Text

template <class T>
void CSystem<T>::allocate (unsigned int unRows, unsigned int unCols, T** &aatArray)
{
aatArray = new T*[unRows];
aatArray[0] = new T[unRows*unCols];
for (unsigned int unRow = 1; unRow < unRows; unRow++)
{
aatArray[unRow] = &aatArray[0][unCols*unRow];
}
}
template <class T>
void CSystem<T>::deallocate (T**& aatArray)
{
delete[] aatArray[0];
delete[] aatArray;
aatArray = 0;
}
template <class T>
void CSystem<T>::allocate (unsigned int unRows, unsigned int unCols, unsigned int unSlices, T*** &aaatArray)
{
aaatArray = new T**[unRows];
aaatArray[0] = new T*[unRows*unCols];
aaatArray[0][0] = new T[unRows*unCols*unSlices];
for (unsigned int unRow = 0; unRow < unRows; unRow++)
{
aaatArray[unRow] = &aaatArray[0][unRow*unCols];
for (unsigned int unCol = 0; unCol < unCols; unCol++)
{
aaatArray[unRow][unCol] =
&aaatArray[0][0][unRow*(unCols*unSlices)+unCol*unSlices];
}
}
}
template <class T>
void CSystem<T>::deallocate (T***& aaatArray)
{
// fairAssert(aaatArray != NULL, "Assertion while trying to deallocate null pointer reference");
delete[] aaatArray[0][0];
delete[] aaatArray[0];
delete[] aaatArray;
aaatArray = 0;
}