Linear Algebra and the C Language/a01f
Install this file in your working directory.
/* ------------------------------------ */
/* Save as : vepivot.h */
/* ------------------------------------ */
double pivotbest_mR(
double **A,
int pv
)
{
int r;
int c;
int best_r = pv;
int best_c = pv;
double sign = 1.;
double pv_best = fabs(A[pv][pv]);
for ( r=pv; r<A[R_SIZE][C0]; r++)
for ( c=pv; c<A[C_SIZE][C0]; c++)
if(fabs(A[r][c])>pv_best )
{
pv_best = fabs(A[r][c]);
best_r = r;
best_c = c;
}
if(best_r!=pv){ sign*=-1; swapR_mR(A,pv,best_r); }
if(best_c!=pv){ sign*=-1; swapC_mR(A,pv,best_c); }
return(sign);
}
/* ------------------------------------ */
double zero_under_pivot_mR(
double **A,
int pv
)
{
int r;
double pivot = A[pv][pv];
if(fabs(pivot)>ERROR_E)
{
mulR_mR( A,(1./pivot),pv);
for( r=(pv+R1); r<A[R_SIZE][C0]; r++)
addR_mR( A,(-A[r][pv]),pv,r);
}
else pivot= 0.0;
return(pivot);
}
/* ------------------------------------ */
/* ------------------------------------ */