diff options
Diffstat (limited to 'src/matrixOperations/cat')
-rw-r--r-- | src/matrixOperations/cat/ccata.c | 2 | ||||
-rw-r--r-- | src/matrixOperations/cat/dcata.c | 2 | ||||
-rw-r--r-- | src/matrixOperations/cat/scata.c | 5 | ||||
-rw-r--r-- | src/matrixOperations/cat/testFloatMatrixConcatenation.c | 19 | ||||
-rw-r--r-- | src/matrixOperations/cat/zcata.c | 2 |
5 files changed, 24 insertions, 6 deletions
diff --git a/src/matrixOperations/cat/ccata.c b/src/matrixOperations/cat/ccata.c index d47fb613..cd2b4c92 100644 --- a/src/matrixOperations/cat/ccata.c +++ b/src/matrixOperations/cat/ccata.c @@ -28,7 +28,7 @@ void crowcata(floatComplex *in1, int lines1, int columns1, floatComplex *in2, i { out[i*(lines1 + lines2) + j] = in1[i*lines1 + j]; } - for (j = 0 ; j < lines1 ; ++j) + for (j = 0 ; j < lines2 ; ++j) { out[i*(lines1 + lines2) + lines1 + j] = in2[i*lines2 + j]; } diff --git a/src/matrixOperations/cat/dcata.c b/src/matrixOperations/cat/dcata.c index e594bf0f..0ec7c088 100644 --- a/src/matrixOperations/cat/dcata.c +++ b/src/matrixOperations/cat/dcata.c @@ -29,7 +29,7 @@ void drowcata(double *in1, int lines1, int columns1, double *in2, int lines2, i { out[i*(lines1 + lines2) + j] = in1[i*lines1 + j]; } - for (j = 0 ; j < lines1 ; ++j) + for (j = 0 ; j < lines2 ; ++j) { out[i*(lines1 + lines2) + lines1 + j] = in2[i*lines2 + j]; } diff --git a/src/matrixOperations/cat/scata.c b/src/matrixOperations/cat/scata.c index 252a054d..da0853c6 100644 --- a/src/matrixOperations/cat/scata.c +++ b/src/matrixOperations/cat/scata.c @@ -11,11 +11,12 @@ */ #include "cat.h" +#include "stdio.h" /* ** Emulate Scilab (from help cat) : ** then the concatenation is done according to the rows ** -** A1=[1 2 3 ; 4 5 6]; A2=[7 8 9 ; 10 11 12]; y=cat(1,A1,A2) => y=[1 2 3 ; 4 5 61 ;7 8 9; 10 11 12] +** A1=[1 2 3 ; 4 5 6]; A2=[7 8 9 ; 10 11 12]; y=cat(1,A1,A2) => y=[1 2 3 ; 4 5 6 ;7 8 9; 10 11 12] ** */ @@ -28,7 +29,7 @@ void srowcata(float *in1, int lines1, int columns1, float *in2, int lines2, int { out[i*(lines1 + lines2) + j] = in1[i*lines1 + j]; } - for (j = 0 ; j < lines1 ; ++j) + for (j = 0 ; j < lines2 ; ++j) { out[i*(lines1 + lines2) + lines1 + j] = in2[i*lines2 + j]; } diff --git a/src/matrixOperations/cat/testFloatMatrixConcatenation.c b/src/matrixOperations/cat/testFloatMatrixConcatenation.c index 1d4bcfb5..b34a80f0 100644 --- a/src/matrixOperations/cat/testFloatMatrixConcatenation.c +++ b/src/matrixOperations/cat/testFloatMatrixConcatenation.c @@ -70,7 +70,6 @@ static void scolumncataTest(void) { float in1[12] = {0.0, 1.0, 2.0 , 3.0 , 4.0, 5.0 , 6.0 , 7.0 , 8.0 , 9.0, 10.0 , 11.0}; float in2_1_1[1] = {12.0}; float out_1_13[13] = {0}; - float in2_2_2[4] = {FPI, FPI / 2, FPI / 3, FPI / 4}; float out_2_8[16] = {0}; @@ -99,6 +98,8 @@ static void scolumncataTest(void) { assert(out_2_8[i + 12] == in2_2_2[i]); } + + } static void srowcataTest() { @@ -107,6 +108,10 @@ static void srowcataTest() { float in2[6] = {3.0 , 4.0 , 7.0 , 8.0 , 11.0 , 12.0}; float out_4_3[12] = {0}; float out_6_2[12] = {0}; + + float inNono1[6]={1.0,3.0,5.0,2.0,4.0,6.0}; + float inNono2[2]={1.0,2.0}; + float outNono[8]={0}; /* ** [ 1 5 9 ] ; [ 3 7 11 ] => [ 1 5 9 ] ** [ 2 6 10 ] [ 4 8 12 ] [ 2 6 10 ] @@ -140,6 +145,18 @@ static void srowcataTest() { assert(out_6_2[9] == 8.0); assert(out_6_2[10] == 11.0); assert(out_6_2[11] == 12.0); + + + srowcata(inNono1, 3, 2, inNono2, 1, 2, outNono); + assert(outNono[0] == 1.0); + assert(outNono[1] == 3.0); + assert(outNono[2] == 5.0); + assert(outNono[3] == 1.0); + assert(outNono[4] == 2.0); + assert(outNono[5] == 4.0); + assert(outNono[6] == 6.0); + assert(outNono[7] == 2.0); + } static void crowcatsTest(void) { diff --git a/src/matrixOperations/cat/zcata.c b/src/matrixOperations/cat/zcata.c index a0c5e10a..485553d7 100644 --- a/src/matrixOperations/cat/zcata.c +++ b/src/matrixOperations/cat/zcata.c @@ -28,7 +28,7 @@ void zrowcata(doubleComplex *in1, int lines1, int columns1, doubleComplex *in2, { out[i*(lines1 + lines2) + j] = in1[i*lines1 + j]; } - for (j = 0 ; j < lines1 ; ++j) + for (j = 0 ; j < lines2 ; ++j) { out[i*(lines1 + lines2) + lines1 + j] = in2[i*lines2 + j]; } |