Got something to write about? Check out our Article Builder.

View \xrmtria0.h

Application of the identity matrix II. v05

Submitted By: xhunga
Rating: starstar (Rate It)


/* xkmtria0.h                   freeware                   [[Email Removed]]  */


/* --------------------------------- FUNCTION ------------------------------  */
/* Do    :                                                                    */
/*                                                                            */
/* Call  :                                                                    */
/* Debug :                                                                    */
/* -------------------------------------------------------------------------- */
void mlowertriang0F(
pmatrix m,
int maxnumer,
int maxdenom)
{
int i;
int j;
int row0;
int row;

     row0 = rndp0I(m->rows);

  if (m->rows * TWOCOL != m->cols)
    {
     printf("\n mid() 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);

          if( i == row0 && j == (i*TWOCOL))
            {
            *(m->pblock+i *m->cols+j)   = 0;
            *(m->pblock+i *m->cols+j+1) = 1;
            }
         }
       }
    }

      for ( row = 0; row < m->rows ; row++)
     {
      frowminiF(m,row);                                 /* a) fraction mini   */
     }
}

/* --------------------------------- FUNCTION ------------------------------  */
/* Do    :                                                                    */
/*                                                                            */
/* Call  :                                                                    */
/* Debug :                                                                    */
/* -------------------------------------------------------------------------- */
void mlowertriang0I(
pmatrix m,
int maxnumer)
{
int i;
int j;
int row0;

     row0 = rndp0I(m->rows);

  if (m->rows * TWOCOL != m->cols)
    {
     printf("\n mid() 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);

          if( i == row0 && j == (i*TWOCOL))
            {
            *(m->pblock+i *m->cols+j)     = 0;
            }
         }
       }
    }
}



/* --------------------------------- FUNCTION ------------------------------  */
/* Do    :                                                                    */
/*                                                                            */
/* Call  :                                                                    */
/* Debug :                                                                    */
/* -------------------------------------------------------------------------- */
void muppertriang0F(
pmatrix m,
int maxnumer,
int maxdenom)
{
int i;
int j;
int row0;
int row;

     row0 = rndp0I(m->rows);

  if (m->rows * TWOCOL != m->cols)
    {
     printf("\n mid() 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);

          if( i == row0 && j == (i*TWOCOL))
            {
            *(m->pblock+i *m->cols+j)   = 0;
            *(m->pblock+i *m->cols+j+1) = 1;
            }
         }
       }
    }

    for ( row = 0; row < m->rows ; row++)
     {
      frowminiF(m,row);                                 /* a) fraction mini   */
     }
}


/* --------------------------------- FUNCTION ------------------------------  */
/* Do    :                                                                    */
/*                                                                            */
/* Call  :                                                                    */
/* Debug :                                                                    */
/* -------------------------------------------------------------------------- */
void muppertriang0I(
pmatrix m,
int maxnumer)
{
int i;
int j;
int row0;

     row0 = rndp0I(m->rows);

  if (m->rows * TWOCOL != m->cols)
    {
     printf("\n mid() 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);

          if( i == row0 && j == (i*TWOCOL))
            {
            *(m->pblock+i *m->cols+j)     = 0;
            }
         }
       }
    }
}

corner
© 1996-2008. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Publisher: Lars Hagelin.
bootstrapLabs Logo A bootstrapLabs project.