Commit ed7b2a52 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

transpose2dArrayDP: __cplusplus branch bug fix.

parent d48a7fd8
......@@ -291,12 +291,12 @@ void transpose2dArrayDP(size_t inWidth, size_t inHeight, double *data)
const size_t cacheBlockSize = 256; // Purely an optimization parameter. Current value of 32 means we are handling 8kB blocks,
// which should be a decent compromise on many architectures.
#ifdef __cplusplus
double **out = (double**) malloc(inHeight*sizeof(double*));
double **temp = (double**) malloc(inWidth*sizeof(double*));
double **out = (double**) malloc(inWidth*sizeof(double*));
double **temp = (double**) malloc(inHeight*sizeof(double*));
temp[0] = (double *) malloc(inHeight*inWidth*sizeof(double));
memcpy(temp[0], data, inHeight*inWidth*sizeof(double));
for(size_t i = 0; i < inHeight; i++) out[i] = data + (inWidth*i);
for(size_t i = 1; i < inWidth; i++) temp[i] = temp[0] + (inHeight*i);
for (size_t i = 0; i < inWidth; i++) out[i] = data + (inHeight*i);
for (size_t i = 1; i < inHeight; i++) temp[i] = temp[0] + (inWidth*i);
#else
double (*out)[inHeight] = (double (*)[inHeight])data;
double (*temp)[inWidth] = (double (*)[inWidth]) Malloc(inHeight*sizeof(*temp));
......@@ -330,12 +330,12 @@ void transpose2dArraySP(size_t inWidth, size_t inHeight, float *data)
const size_t cacheBlockSize = 256; // Purely an optimization parameter. Current value of 32 means we are handling 8kB blocks,
// which should be a decent compromise on many architectures.
#ifdef __cplusplus
float **out = (float**) malloc(inHeight*sizeof(float*));
float **temp = (float**) malloc(inWidth*sizeof(float*));
float **out = (float**) malloc(inWidth*sizeof(float*));
float **temp = (float**) malloc(inHeight*sizeof(float*));
temp[0] = (float *) malloc(inHeight*inWidth*sizeof(float));
memcpy(temp[0], data, inHeight*inWidth*sizeof(float));
for(size_t i = 0; i < inHeight; i++) out[i] = data + (inWidth*i);
for(size_t i = 1; i < inWidth; i++) temp[i] = temp[0] + (inHeight*i);
for (size_t i = 0; i < inWidth; i++) out[i] = data + (inHeight*i);
for (size_t i = 1; i < inHeight; i++) temp[i] = temp[0] + (inWidth*i);
#else
float (*out)[inHeight] = (float (*)[inHeight])data;
float (*temp)[inWidth] = (float (*)[inWidth]) Malloc(inHeight*sizeof(*temp));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment