Commit b8680384 authored by ale's avatar ale

allocate the large Delta matrix in the heap

parent 2e937c86
......@@ -639,7 +639,8 @@ static void russel(double *S, double *D)
{
int i, j, found, minI = 0, minJ = 0;
double deltaMin, oldVal, diff;
double Delta[MAX_SIG_SIZE1][MAX_SIG_SIZE1];
// double Delta[MAX_SIG_SIZE1][MAX_SIG_SIZE1];
double *Delta = (double *)malloc(sizeof(double) * MAX_SIG_SIZE1 * MAX_SIG_SIZE1);
node1_t Ur[MAX_SIG_SIZE1], Vr[MAX_SIG_SIZE1];
node1_t uHead, *CurU, *PrevU;
node1_t vHead, *CurV, *PrevV;
......@@ -681,7 +682,7 @@ static void russel(double *S, double *D)
/* COMPUTE THE Delta MATRIX */
for(i=0; i < _n1 ; i++)
for(j=0; j < _n2 ; j++)
Delta[i][j] = _C[i][j] - Ur[i].val - Vr[j].val;
Delta[i * MAX_SIG_SIZE1 + j] = _C[i][j] - Ur[i].val - Vr[j].val;
/* FIND THE BASIC VARIABLES */
do
......@@ -711,9 +712,9 @@ static void russel(double *S, double *D)
{
int j;
j = CurV->i;
if (deltaMin > Delta[i][j])
if (deltaMin > Delta[i * MAX_SIG_SIZE1 + j])
{
deltaMin = Delta[i][j];
deltaMin = Delta[i * MAX_SIG_SIZE1 + j];
minI = i;
minJ = j;
PrevUMinI = PrevU;
......@@ -756,7 +757,7 @@ static void russel(double *S, double *D)
diff = oldVal - CurV->val;
if (fabs(diff) < EPSILON * _maxC)
for (CurU=uHead.Next; CurU != NULL; CurU=CurU->Next)
Delta[CurU->i][j] += diff;
Delta[CurU->i * MAX_SIG_SIZE1 + j] += diff;
}
}
}
......@@ -783,11 +784,13 @@ static void russel(double *S, double *D)
diff = oldVal - CurU->val;
if (fabs(diff) < EPSILON * _maxC)
for (CurV=vHead.Next; CurV != NULL; CurV=CurV->Next)
Delta[i][CurV->i] += diff;
Delta[i * MAX_SIG_SIZE1 + CurV->i] += diff;
}
}
}
} while (uHead.Next != NULL || vHead.Next != NULL);
free(Delta);
}
......
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