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





(
Rate It)
/* --------------------------------- FUNCTION ------------------------------ */
/* Do : */
/* */
/* Call : */
/* Debug : */
/* -------------------------------------------------------------------------- */
void mdiagF(
pmatrix m,
int maxnumer,
int maxdenom)
{
int i;
int j;
int row;
if (m->rows * TWOCOL != m->cols)
{
printf("\n mdiagF() error - matrix must be square");
printf("\n Press return to continue");
getchar();
exit(1);
}
for ( i = 0 ; i < m->rows ; i++)
{
for ( j = 0 ; j < m->cols ; j++,j++)
{
*(m->pblock+i *m->cols+j ) = 0;
*(m->pblock+i *m->cols+j+1) = 1;
if( (i*TWOCOL) == j)
{
*(m->pblock+i *m->cols+j ) = rndI(maxnumer);
*(m->pblock+i *m->cols+j+1) = rndpI(maxdenom);
}
}
}
for ( row = 0; row < m->rows ; row++)
{
frowminiF(m,row); /* a) fraction mini */
}
}
/* ------------------------------ FUNCTION ---------------------------- mid() */
/* */
/* -------------------------------------------------------------------------- */
void mdiagI(
pmatrix m,
int maxnumer)
{
int i;
int j;
if (m->rows * TWOCOL != m->cols)
{
printf("\n mdiagI() error - matrix must be square");
printf("\n Press return to continue");
getchar();
exit(1);
}
for ( i = 0 ; i < m->rows ; i++)
{
for ( j = 0 ; j < m->cols ; j++,j++)
{
*(m->pblock+i *m->cols+j ) = 0;
*(m->pblock+i *m->cols+j+1) = 1;
if( (i*TWOCOL) == j)
{
*(m->pblock+i *m->cols+j) = rndI(maxnumer);
}
}
}
}
/* ------------------------------ FUNCTION ---------------------------- mid() */
/* */
/* -------------------------------------------------------------------------- */
void mdiagpF(
pmatrix m,
int maxnumer,
int maxdenom)
{
int i;
int j;
int row;
if (m->rows * TWOCOL != m->cols)
{
printf("\n mdiagF() error - matrix must be square");
printf("\n Press return to continue");
getchar();
exit(1);
}
for ( i = 0 ; i < m->rows ; i++)
{
for ( j = 0 ; j < m->cols ; j++,j++)
{
*(m->pblock+i *m->cols+j ) = 0;
*(m->pblock+i *m->cols+j+1) = 1;
if( (i*TWOCOL) == j)
{
*(m->pblock+i *m->cols+j ) = rndpI(maxnumer);
*(m->pblock+i *m->cols+j+1) = rndpI(maxdenom);
}
}
}
for ( row = 0; row < m->rows ; row++)
{
frowminiF(m,row); /* a) fraction mini */
}
}
/* ------------------------------ FUNCTION ---------------------------- mid() */
/* */
/* -------------------------------------------------------------------------- */
void mdiagpI(
pmatrix m,
int maxnumer)
{
int i;
int j;
if (m->rows * TWOCOL != m->cols)
{
printf("\n mdiagI() error - matrix must be square");
printf("\n Press return to continue");
getchar();
exit(1);
}
for ( i = 0 ; i < m->rows ; i++)
{
for ( j = 0 ; j < m->cols ; j++,j++)
{
*(m->pblock+i *m->cols+j ) = 0;
*(m->pblock+i *m->cols+j+1) = 1;
if( (i*TWOCOL) == j)
{
*(m->pblock+i *m->cols+j) = rndpI(maxnumer);
}
}
}
}