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





(
Rate It)
/* xbmid.h freeware [[Email Removed]] */
/* --------------------------------- FUNCTION ------------------------------ */
/* Do : */
/* */
/* Call : */
/* Debug : */
/* -------------------------------------------------------------------------- */
void mid(
pmatrix mID)
{
int i;
int j;
if (mID->rows * TWOCOL != mID->cols)
{
printf("\n mid() error - matrix must be square");
printf("\n Press return to continue");
getchar();
exit(1);
}
for ( i = 0 ; i < mID->rows ; i++)
{
for ( j = 0 ; j < mID->cols ; j++,j++)
{
*(mID->pblock+i *mID->cols+j ) = 0;
*(mID->pblock+i *mID->cols+j+1 ) = 1;
*(mID->pblock+i *mID->cols+i*TWOCOL) = 1;
}
}
}
/* --------------------------------- FUNCTION ------------------------------ */
/* Do : */
/* */
/* Call : */
/* Debug : */
/* -------------------------------------------------------------------------- */
void mzero(
pmatrix mZero)
{
int i;
int j;
for ( i = 0 ; i < mZero->rows ; i++)
{
for ( j = 0 ; j < mZero->cols ; j++,j++)
{
*(mZero->pblock+i *mZero->cols+j ) = 0;
*(mZero->pblock+i *mZero->cols+j+1) = 1;
}
}
}
/* --------------------------------- FUNCTION ------------------------------ */
/* Do : */
/* */
/* Call : */
/* Debug : */
/* -------------------------------------------------------------------------- */
void mone(
pmatrix mOne)
{
int i;
int j;
for ( i = 0 ; i < mOne->rows ; i++)
{
for ( j = 0 ; j < mOne->cols ; j++,j++)
{
*(mOne->pblock+i *mOne->cols+j ) = 1;
*(mOne->pblock+i *mOne->cols+j+1) = 1;
}
}
}
/* --------------------------------- FUNCTION ------------------------------ */
/* Do : */
/* */
/* Call : */
/* Debug : */
/* -------------------------------------------------------------------------- */
void mdiag123F(
pmatrix m)
{
int i;
int j;
if (m->rows * TWOCOL != m->cols)
{
printf("\n mdiag123F() 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) = i+1;
}
}
}
}