diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/matrixOperations/transpose/ctransposea.c | 15 | ||||
-rw-r--r-- | src/matrixOperations/transpose/dtransposea.c | 12 | ||||
-rw-r--r-- | src/matrixOperations/transpose/stransposea.c | 13 | ||||
-rw-r--r-- | src/matrixOperations/transpose/testMatrixTranspose.c | 9 | ||||
-rw-r--r-- | src/matrixOperations/transpose/ztransposea.c | 17 |
5 files changed, 31 insertions, 35 deletions
diff --git a/src/matrixOperations/transpose/ctransposea.c b/src/matrixOperations/transpose/ctransposea.c index ed4c34bc..571d3b78 100644 --- a/src/matrixOperations/transpose/ctransposea.c +++ b/src/matrixOperations/transpose/ctransposea.c @@ -12,17 +12,16 @@ #include "matrixTranspose.h" -void ctransposea ( floatComplex* in , int lines1 , int column1, floatComplex* out ){ - +void ctransposea ( floatComplex* in , int lines , int columns, floatComplex* out ){ - int newCoord = 0 ; - int index = 0 ; + int i = 0 ; + int j = 0 ; - for(index = 0 ; index < lines1 * column1 ; index++) + for(i = 0 ; i < lines ; i++) { - newCoord = index % column1 * lines1 + ( index / column1); + for(j = 0 ; j < columns ; j++) - out[newCoord] = FloatComplex ( creals( in[index]) , cimags ( in[index])); + out[j+i*columns] = in[i+j*lines]; } - + } diff --git a/src/matrixOperations/transpose/dtransposea.c b/src/matrixOperations/transpose/dtransposea.c index 50352b52..11a5fc05 100644 --- a/src/matrixOperations/transpose/dtransposea.c +++ b/src/matrixOperations/transpose/dtransposea.c @@ -12,16 +12,16 @@ #include "matrixTranspose.h" -void dtransposea ( double* in , int lines1 , int column1, double* out ){ +void dtransposea ( double* in , int lines , int columns, double* out ){ - int newCoord = 0 ; - int index = 0 ; + int i = 0 ; + int j = 0 ; - for(index = 0 ; index < lines1 * column1 ; index++) + for(i = 0 ; i < lines ; i++) { - newCoord = index % column1 * lines1 + ( index / column1); + for(j = 0 ; j < columns ; j++) - out[newCoord] = in[index]; + out[j+i*columns] = in[i+j*lines]; } diff --git a/src/matrixOperations/transpose/stransposea.c b/src/matrixOperations/transpose/stransposea.c index 27f78835..219f2216 100644 --- a/src/matrixOperations/transpose/stransposea.c +++ b/src/matrixOperations/transpose/stransposea.c @@ -11,17 +11,16 @@ */ #include "matrixTranspose.h" -void stransposea ( float* in , int lines1 , int column1, float* out ){ +void stransposea ( float* in , int lines , int columns, float* out ){ + int i = 0 ; + int j = 0 ; - int newCoord = 0 ; - int index = 0 ; - - for(index = 0 ; index < lines1 * column1 ; index++) + for(i = 0 ; i < lines ; i++) { - newCoord = index % column1 * lines1 + ( index / column1); + for(j = 0 ; j < columns ; j++) - out[newCoord] = in[index]; + out[j+i*columns] = in[i+j*lines]; } } diff --git a/src/matrixOperations/transpose/testMatrixTranspose.c b/src/matrixOperations/transpose/testMatrixTranspose.c index 790b3a4f..fe2123d3 100644 --- a/src/matrixOperations/transpose/testMatrixTranspose.c +++ b/src/matrixOperations/transpose/testMatrixTranspose.c @@ -115,7 +115,7 @@ static void stranspaTest (void ) { 0.14596485672518611f,0.07141010463237762f,0.67337385797873139f,0.65369247179478407f, 0.19968961318954825f,0.60141251794993877f,0.18993748771026731f}; - stransposea ( in , LINE , COLUMN , out ); + stransposea ( in , COLUMN , LINE , out ); @@ -225,8 +225,7 @@ static void dtranspaTest (void ) { 0.14596485672518611,0.07141010463237762,0.67337385797873139,0.65369247179478407, 0.19968961318954825,0.60141251794993877,0.18993748771026731}; - dtransposea ( in , LINE , COLUMN , out ); - + dtransposea ( in , COLUMN , LINE , out ); for ( i = 0 ; i < LINE*COLUMN ; i++ ) @@ -349,7 +348,7 @@ static void ctranspaTest (void ) { } - ctransposea ( in , LINE , COLUMN , out ); + ctransposea ( in , COLUMN , LINE , out ); @@ -480,7 +479,7 @@ static void ztranspaTest (void ) { - ztransposea ( in , LINE , COLUMN , out ); + ztransposea ( in , COLUMN , LINE, out ); diff --git a/src/matrixOperations/transpose/ztransposea.c b/src/matrixOperations/transpose/ztransposea.c index 5d78c5f6..e42d74d2 100644 --- a/src/matrixOperations/transpose/ztransposea.c +++ b/src/matrixOperations/transpose/ztransposea.c @@ -12,17 +12,16 @@ #include "matrixTranspose.h" -void ztransposea ( doubleComplex* in , int lines1 , int column1, doubleComplex* out ){ - int newCoord = 0 ; - int index = 0 ; +void ztransposea ( doubleComplex* in , int lines , int columns, doubleComplex* out ){ - for(index = 0 ; index < lines1 * column1 ; index++) - { - newCoord = index % column1 * lines1 + ( index / column1); + int i = 0 ; + int j = 0 ; - out[newCoord] = DoubleComplex ( zreals( in[index]) , zimags ( in[index])); - } + for(i = 0 ; i < lines ; i++) + { + for(j = 0 ; j < columns ; j++) + out[j+i*columns] = in[i+j*lines]; + } - } |