diff options
Diffstat (limited to 'src/matrixOperations/division')
-rw-r--r-- | src/matrixOperations/division/ddiva.c | 17 | ||||
-rw-r--r-- | src/matrixOperations/division/sdiva.c | 23 |
2 files changed, 21 insertions, 19 deletions
diff --git a/src/matrixOperations/division/ddiva.c b/src/matrixOperations/division/ddiva.c index ce319908..8fe660ba 100644 --- a/src/matrixOperations/division/ddiva.c +++ b/src/matrixOperations/division/ddiva.c @@ -14,8 +14,6 @@ #include "matrixDivision.h" #include "lapack.h" -#include "stdio.h" - void drdiva ( double* in1, int lines1, int columns1 , double* in2, int lines2, int columns2 , double* out ){ @@ -54,7 +52,10 @@ void drdiva ( double* in1, int lines1, int columns1 , - +/* adaptation of the original code in scilab + iWorkMin = Max(4 * _iCols1, Max(Min(_iRows1, _iCols1) + 3 * _iRows1 + 1, + 2 * Min(_iRows1, _iCols1) + _iRows2)); + */ if (lines1 > columns1) tMinLinCol1 = columns1 ; else @@ -69,6 +70,9 @@ void drdiva ( double* in1, int lines1, int columns1 , iwork = 4* columns1 ; else iwork = temp ; + + + work = (double*) malloc (sizeof(double) *(unsigned int) iwork ); @@ -80,7 +84,8 @@ void drdiva ( double* in1, int lines1, int columns1 , dtransposea ( in1, lines1, columns1, transpOfIn1); dtransposea ( in2, lines2, columns2, transpOfIn2) ; - + +/* case of a square matrix */ if ( lines1 == columns1 ) { drowcata ( in1, lines1, columns1, NULL, 0 , 0 , copyOfTransIn1 ) ; @@ -111,7 +116,7 @@ void drdiva ( double* in1, int lines1, int columns1 , } - +/* non-square matrix case */ if ( iexit== 0) { rcond = sqrt(epsilon ); @@ -126,7 +131,7 @@ void drdiva ( double* in1, int lines1, int columns1 , transpOfIn2, &imax, pJpvt, &rcond, &rank, work, &iwork, &info); - + if (info == 0) for(j = 0 ; j < lines1 ; j++) { diff --git a/src/matrixOperations/division/sdiva.c b/src/matrixOperations/division/sdiva.c index a20d14df..f5b21eaa 100644 --- a/src/matrixOperations/division/sdiva.c +++ b/src/matrixOperations/division/sdiva.c @@ -15,7 +15,7 @@ /**** Because of problem of conversion float-> double ****/ #include "matrixDivision.h" #include "lapack.h" -#include "stdio.h" + void srdiva ( float* in1, int lines1, int columns1 , float* in2, int lines2, int columns2 , @@ -53,8 +53,7 @@ void srdiva ( float* in1, int lines1, int columns1 , float* copyOfTransIn1 = (float*) malloc( sizeof(float) * (unsigned int) lines1 * (unsigned int) columns1); - -printf("\n>fin alloc \n"); + if (lines1 > columns1) tMinLinCol1 = columns1 ; else @@ -71,9 +70,9 @@ printf("\n>fin alloc \n"); iwork = temp ; work = (double*) malloc (sizeof(double) *(unsigned int) iwork ); - printf("\n>debut partie rigolote \n"); + anorm = getOneNorm( &lines1, &columns1 , (double* ) in1 , work); - printf("\n>debut partie rigolote 2\n"); + /* end of allocation area*/ @@ -119,7 +118,9 @@ printf("\n>fin alloc \n"); imax = lines1; -/* cette fonction genere des nombres aleatoires , youpi ! */ +/* if you uncomment this function you will get a fabulous random number generator + actually the problem come from the convertion from float* to double* + that also cause the free() of these cast variables to crash * */ /* dgelsy_ (&columns1, &lines1, &lines2, (double*) transpOfIn1 , &columns1, (double*) transpOfIn2, &imax, pJpvt, &rcond, &rank, work, &iwork, &info);*/ @@ -140,16 +141,12 @@ printf("\n>fin alloc \n"); } - /* here put algo dgelsy1 which do maybe interesting things but i dunno what - - // if info return by dgelsy1 != 0 - // return ;*/ + } - - printf("\n>debut partie 2\n"); + /* then we free all the allocated memory */ @@ -158,7 +155,7 @@ printf("\n>fin alloc \n"); free ( pIwork) ; free ( work ) ; - /* le probleme vient de ces trois free */ + /* the cast from float* to double* make these 3 functions crashing */ free (transpOfIn1) ; free (transpOfIn2) ; free (copyOfTransIn1); |