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





(
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; }
}
}