Linear Algebra and the C Language/a0kz
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as: c00b.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
void X_gj3_T_mR(
double **Ab,
int above
)
{
int r= R1;
int c= C1;
while( (r<Ab[R_SIZE][C0]) &&
(c<Ab[C_SIZE_A][C0]) )
{
if(pivotbest_gj3Ab_mR(Ab,r,c)>ERROR_E) /* Select the best pivot */
zero_under_pivot_gj3Ab_mR(Ab,r,c); /* zero under the pivot */
else r--;
r++;
c++;
}
r = Ab[R_SIZE][C0];
if(above)
while(r>R1)
{
r--;
c=C1;
while(fabs(Ab[r][c])<ERROR_E && c<(Ab[C_SIZE_A][C0]-C1) ) c++;
if(fabs(Ab[r][c])>ERROR_E)
/* if above == YES */
zero_above_pivot_gj3Ab_mR(Ab,r,c); /* zero above the pivot */
}
}
/* ------------------------------------ */
double **X_gj_PP_mR(
double **Ab,
int above
)
{
X_gj3_T_mR(Ab,above);
return(Ab);
}
/* ------------------------------------ */
/* ------------------------------------ */
void fun(int r)
{
double **A = r_mR( i_mR(r,r),999.);
double **b = r_mR( i_mR(r,C1),999.);
double **Ab = c_A_b_Ab_mR(A,b, i_Abr_Ac_bc_mR( r, r, C1));;
/* i_Abr_Ac_bc_mR(RAb, CA, Cb)); */
clrscrn();
printf(" Copy/Paste into the octave window.\n\n");
p_Octave_mR(Ab,"Ab",P0);
printf("\n rref(Ab,.00000000001)\n\n");
X_gj_PP_mR(Ab,YES);
printf(" See above for the function code: gj3_T_mR();\n\n"
" gj_PP_mR(Ab,YES);");
p_mR(Ab,S10,P4,C7);
f_mR(Ab);
f_mR(b);
f_mR(A);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun(R5);
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Screen output example:
Copy/Paste into the octave window.
Ab=[
+2,+652,+824,+735,-147,-508;
-400,-60,+709,-779,-827,-145;
+418,+288,+850,+25,+411,+524;
+262,-651,+451,-931,-590,-9;
-116,-908,-661,+395,+786,+247]
rref(Ab,.00000000001)
See above for the function code: gj3_T_mR();
gj_PP_mR(Ab,YES);
+1.0000 +0.0000 +0.0000 +0.0000 -0.0000 -0.1095
+0.0000 +1.0000 +0.0000 +0.0000 -0.0000 +0.2316
+0.0000 +0.0000 +1.0000 +0.0000 +0.0000 +0.1045
+0.0000 +0.0000 +0.0000 +1.0000 +0.0000 -0.8022
-0.0000 -0.0000 -0.0000 -0.0000 +1.0000 +1.0567
Press return to continue
Press X return to stop