*/
Check out and contribute to CodePedia, the wiki for developers.
*/

View \xcelrop.h

Application of the identity matrix II. v05

Submitted By: xhunga
Rating: starstar (Rate It)


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


/* --------------------------------- FUNCTION ------------------------------  */
/* Do    : swap two rows in a matrix                                          */
/*                                                                            */
/* Call  :                                                                    */
/* Debug :                                                                    */
/* -------------------------------------------------------------------------- */
void swaprowF(
pmatrix m,
int     row1,
int     row2)
{
  int    j;
  double t;

    for ( j = 0 ; j < m->cols ; j++)
    {
                                t   = *(m->pblock+row1 *m->cols+j);
      *(m->pblock+row1 *m->cols+j ) = *(m->pblock+row2 *m->cols+j);
      *(m->pblock+row2 *m->cols+j ) =       t;
    }
}

/* --------------------------------- FUNCTION ------------------------------  */
/* Do    : returns a copy of the matrix m in which row is multiply by scalar  */
/*                                                                            */
/* Call  :                                                                    */
/* Debug :                                                                    */
/* -------------------------------------------------------------------------- */
void mulrowF(
pmatrix m,
int rown,
fraction f
)
{
 int j;

 for( j = 0 ; j < m->cols ; j++,j++)
 {
                 (*(m->pblock+rown *m->cols+j)) =
       f.numer * (*(m->pblock+rown *m->cols+j)) ;

                 (*(m->pblock+rown *m->cols+j+1)) =
       f.denom * (*(m->pblock+rown *m->cols+j+1)) ;
 }
}


/* --------------------------------- FUNCTION ------------------------------  */
/* Do    : returns a copy of the matrix m in which row r2 is                  */
/*         replaced  by (s*r1+r2)                                             */
/* Call  :                                                                    */
/* Debug :                                                                    */
/* -------------------------------------------------------------------------- */
void addrowF(
pmatrix  m,
fraction f,
int      row1,
int      row2

)
{
  int j;
  double t;

 for ( j = 0 ; j < m->cols ; j++,j++ )
    {
/* ---------------------------------------------------------------- numerator */
      *(m->pblock+row2 *m->cols+j) =
                       (
                    (f.numer) * (*(m->pblock+row1 *m->cols+j  ))
                               *
                                (*(m->pblock+row2 *m->cols+j+1))
                        )
                       +
                        (
                               (*(m->pblock+row2 *m->cols+j  ))
                             *
                     f.denom * (*(m->pblock+row1 *m->cols+j+1))
                         );
/* -------------------------------------------------------------- denominator */
      *(m->pblock+row2 *m->cols+j+1) =
              f.denom * (*(m->pblock+row1 *m->cols+j+1)) *
                        (*(m->pblock+row2 *m->cols+j+1));
/* -------------- denominator = 1 if numerator = 0. This is my choice 0 = 0/1 */
                t = *(m->pblock+row2 *m->cols+j);
            if(!t){ *(m->pblock+row2 *m->cols+j+1) = 1; }
    }
}

corner
© 1996-2008 CommunityHeaven LLC. 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.
North American business development: Nicolai Wadstrom. Publisher: Lars Hagelin.