*/
Know a good article or link that we're missing? Submit it!
*/

View \xglu.h

Application of the identity matrix II. v05

Submitted By: xhunga
Rating: starstar (Rate It)


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

/* --------------------------------- FUNCTION ------------------------------  */
/* Do    :                                                                    */
/*                                                                            */
/* Call  :                                                                    */
/* Debug :                                                                    */
/* -------------------------------------------------------------------------- */
void LU(
pmatrix m,
pmatrix mL,
pmatrix mU
)
{
fraction pivot;
fraction underpivot;
     int rowpivot;
     int rowunder;
     int col;

    mzero(  mL);
   copymF(m,mU);

         col = 0;
for(rowpivot = 0; rowpivot<(mU->rows); rowpivot++)
{
  pivot.numer = *(mU->pblock+rowpivot *mU->cols+col+1);
  pivot.denom = *(mU->pblock+rowpivot *mU->cols+col  );
  if(pivot.denom<0){pivot.numer*= -1;pivot.denom *= -1;}
  if(!pivot.numer)
    {
     printf("\n Pivot error - A pivot is Zero");
     printf("\n Press return to continue");
     getchar();
     exit(1);
    }

  *(mL->pblock+rowpivot *mL->cols+col  )=*(mU->pblock+rowpivot *mU->cols+col  );
  *(mL->pblock+rowpivot *mL->cols+col+1)=*(mU->pblock+rowpivot *mU->cols+col+1);

    mulrowF(mU,rowpivot,pivot);
  frowminiF(mU,rowpivot);

  for(rowunder = rowpivot+1; rowunder<mU->rows; rowunder++)
     {

*(mL->pblock+rowunder *mL->cols+col  )= (*(mU->pblock+rowunder *mU->cols+col ));
*(mL->pblock+rowunder *mL->cols+col+1)=  *(mU->pblock+rowunder *mU->cols+col+1);

                     underpivot.numer =-(*(mU->pblock+rowunder *mU->cols+col ));
                     underpivot.denom =  *(mU->pblock+rowunder *mU->cols+col+1);

        addrowF(mU,underpivot,rowpivot,rowunder);
      frowminiF(mU,                    rowunder);
     }
  col++;
  col++;
}
}

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.