From 4949f43de73ef14ad3b13aa04ad9f365841878dd Mon Sep 17 00:00:00 2001 From: Raffaele Date: Thu, 13 Jan 2022 23:14:03 +0100 Subject: [PATCH] added test unit --- lina.o | Bin 2320 -> 0 bytes test.c | 45 +++++++++++++++++++++++++++++++++------------ 2 files changed, 33 insertions(+), 12 deletions(-) delete mode 100644 lina.o diff --git a/lina.o b/lina.o deleted file mode 100644 index 75858f83ea2c69b491bc90169e7fe1fc4a9bdb70..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2320 zcmbVM-%Aux6u#s7tFmSdA4(;*2eBxJwT#+|SkRmE;6?-s3W<*Es*&!>?ksBbLs&_s zC6J)-A?nq){sAA9jFli*%7=ZFAW~d#+YFXiuygO+t9Qof#S3@NIp25Az2|(hv(IqX z?J`M1d`ajQ+K)Jjkh^l<_fyx8YS1zCTR!tQs2V?1<4IOE5*gJ9t{Q=r4g)WB7=cAK zg;&)ZI4jTmfg%=VdU%M zB!ok7jMLtoY9?=FZ7vb#EkcPx1so|m`ep@Q7A4Ecd#LGA_zu1(?{395Z~ zY2uarwpHg-FjUu~B+f%&-iH_E*{(fhK#oKn?gvpzLRSw$? zy8?FSoggYhXo+Ah*ksk221$?ZA!*VrHPlp9&%p=O2sqhfHIWYrpKw1fYd>D;YLp;_ zayKc9&^KZ^U-p^Ml)umTcNYHj9{-r}r$zoQr5SV3kXFjkuib+TnaSzPCpb*)uv~j8 zSV&!cpwcrDfCIT1+13gJf@lgR?qMv8;xoSSQEqF zu+gZ7fT7U`5lsnE(>EB^O-CCXG@W=z8x5PT9@8T6@n}3us*s015mic5%WuPZfBiO` z_cv|Bd4EWWPmSr?09ZX{+7a&Q;Yl4SgPN`(Wgs3$N+>!u7LEWGiRxhmezq-fT?;*A z@o*%ejK`wm;g~*!lvsFFQ^F&CLosd49EEjoIMV=SL~8q+_Os(Yh~ltZMp1K?Vf_2z z+_tTb^UG=VEZk*I*yl z!|FXeky$dUxOyQVXWHxitbSfh2H#%a4H)@<^TQUGT46^03_Jps^vUZ_G2H2HLS@E0V8MF>j~y0m7Cq)2E4fJ`jP(ur}_m}KP(o5Z?FFcL931* diff --git a/test.c b/test.c index 67df82d..f683522 100644 --- a/test.c +++ b/test.c @@ -3,11 +3,8 @@ #include #include "lina.h" -#define NUM_TESTS 100 //Number of tests case to create -#define MATRIX_MAX_ROWS 4 //Max rows that a matrix can have -#define MATRIX_MAX_COLLUMNS 4 //Max collumns a matrix can have -#define MAX_VALUE 15 //Max value a matrix can have -//Matrix type. A is m by n +#define NUM_TESTS 6 //Number of tests case to create +#define MAX_VALUE 15 //Max value a matrix can have typedef struct matrix_t { @@ -17,8 +14,9 @@ typedef struct matrix_t }matrix_t; //Dinamically create NUM_TESTS tests case randomly generating matrices with random values (whom max is MAX_VALUE) -//and random collumns and row numbers (whom max is MATRIX_MAX_ROWS and MATRIX_MAX_COLLUMNS) +//index from 0 to NUM_TESTS/3 will contain 2x3 matrices, index from NUM_TESTS/3 to 2*NUM_TESTS/3 3x3, and index from 2*NUM_TESTS/3 to NUM_TESTS 4x3 void create_tests(matrix_t **tests); + //Free the heap memory from the test structure void delete_tests(matrix_t **tests); @@ -27,18 +25,23 @@ void pmatrix(double *A, int m, int n); int main() { - - matrix_t *tests[NUM_TESTS]; create_tests(tests); - pmatrix(tests[0]->A,tests[0]->m,tests[0]->n); + for(int i=0;i< NUM_TESTS;i++) + pmatrix(tests[i]->A,tests[i]->m,tests[i]->n); + double *C = malloc(sizeof(*C)*tests[0]->m*tests[0]->n); + + lina_scale(tests[0]->A,C,1.5,tests[0]->m,tests[0]->n); + + pmatrix(C,tests[0]->m,tests[0]->n); + + delete_tests(tests); return 0; } - void pmatrix(double *A,int m,int n){ for(int i = 0; i= NUM_TESTS/3 && i < 2*NUM_TESTS/3) + { + rows = 3; + cols = 3; + } + else{ + rows = 4; + cols = 3; + } + + + double *ptr = malloc(sizeof(*ptr)*rows*cols);