Application of the identity matrix II. v05
Submitted By:
xhunga
Rating:





(
Rate It)
/* xgauss.h freeware [[Email Removed]] */
/* --------------------------------- FUNCTION ------------------------------ */
/* Do : */
/* */
/* Call : */
/* Debug : */
/* -------------------------------------------------------------------------- */
void growminiF(
pmatrix m,
int row)
{
int j;
int i;
double ValueOfN;
int nb1er;
int ttrue;
int row0;
/* ************************************************************************** */
/* In this function 0 = 0/0. In other part 0 = 0/1. */
/* Why : rowminiF(1, 2, 4, 6, 8) = 1, 2, 4, 6, 8 */
/* rowminiF(0, 2, 4, 6, 8) = 0, 1, 2, 3, 4 */
/* 0 is a multiple of any numbers */
/* 1 is a multiple of 1 */
/* ************************************************************************** */
row0 = 0;
for (j = 0; j < m->cols ; j++, j++)
{
ValueOfN = *(m->pblock+row *m->cols+j);
if(!ValueOfN)
{
*(m->pblock+row *m->cols+j+1) = 0;
row0++;
}
}
/* ************************************************************************** */
if((row0 * TWOCOL) != (m->cols))
{
for(i = 0; i < 2 ; i++)
{
nb1er = FIRSTNB1ER;
while(nb1er < LASTNB1ER )
{
j = i; ttrue = 1;
/* -------------------------------------------------------------------------- */
while((j < m->cols) && ttrue )
{
ValueOfN = *(m->pblock+row *m->cols+j);
if(fmod(ValueOfN,tnb1er[nb1er]))
{
nb1er++;
ttrue = 0;
if( (tnb1er[nb1er]) > fabs(ValueOfN))
{
nb1er = LASTNB1ER-1;
}
}
j++;j++;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------- true = y -------------------------------- */
if(ttrue)
{
for(j = i; j < m->cols ; j++, j++)
{
*(m->pblock+row *m->cols+j) =
*(m->pblock+row *m->cols+j) / tnb1er[nb1er];
}
}
/* -------------------------------- true = y -------------------------------- */
}
}
}
/* ************************************************************************** */
/* In this function 0 = 0/0. */
/* In other part 0 = 0/1. */
/* Now you must write 0 = 0/1. */
/* ************************************************************************** */
for (j = 0; j < m->cols ; j++, j++)
{
ValueOfN = *(m->pblock+row *m->cols+j);
if(!ValueOfN)
{
*(m->pblock+row *m->cols+j+1 ) = 1;
}
}
/* ************************************************************************** */
}
/* --------------------------------- FUNCTION ------------------------------ */
/* Do : */
/* */
/* Call : */
/* Debug : */
/* -------------------------------------------------------------------------- */
void gausspivotbestF(
pmatrix m,
int row,
int col)
{
int row2 = row+1;
fraction pivot;
fraction belowpivot;
frowminiF(m,row);
growminiF(m,row);
pivot.numer = fabs(*(m->pblock+row *m->cols+col*TWOCOL));
while(row2 < m->rows)
{
growminiF(m,row2);
frowminiF(m,row2);
belowpivot.numer = *(m->pblock+row2 *m->cols+col*TWOCOL );
belowpivot.denom = *(m->pblock+row2 *m->cols+col*TWOCOL+1);
if(fabs(belowpivot.numer) < fabs(pivot.numer))
{
if(belowpivot.numer)
{
swaprowF(m,row,row2);
pivot.numer = belowpivot.numer;
pivot.denom = belowpivot.denom;
}
}
if(fabs(belowpivot.numer) == fabs(pivot.numer))
{
if(fabs(belowpivot.denom) < fabs(pivot.denom))
{
swaprowF(m,row,row2);
pivot.numer = belowpivot.numer;
pivot.denom = belowpivot.denom;
}
}
row2++;
}
}