Linear Algebra and the C Language/a0kj
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as : c00h.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
double **X_gj1_T_mR(
double **Ab
)
{
int r= R1;
while(r<Ab[R_SIZE][C0])
{
if(fabs(pivotbest_gj1Ab_mR(Ab,r))>ERROR_E)
zero_under_pivot_gj1Ab_mR(Ab,r);
r++;
}
while(r>R2)
{
printf(" Ab : pivot[%d][[%d] \n",r-R1,r-R1); /* See : --r */
p_mR(Ab, S8,P4,C8);
zero_above_pivot_gj1Ab_mR(Ab,--r);
printf(" Ab : pivot[%d][%d] zero_above_pivot_gj1Ab_mR();\n",
r,r);
p_mR(Ab, S8,P4,C8);
stop();
clrscrn();
}
return(Ab);
}
/* ------------------------------------ */
/* ------------------------------------ */
double **X_gj_TP_mR(
double **Ab
)
{
X_gj1_T_mR(Ab);
/* sort_c_mR(Ab); */
/* sort_r_mR(Ab); */
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();
X_gj_TP_mR(Ab);
printf(" The columns and the rows are not sorted:\n\n"
" Zero above the pivot:\n\n gj_TP_mR(Ab);");
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:
Ab : pivot[5][[5]
+1.0000 +0.5163 -0.0786 -0.6745 +0.2908 +0.8510
-0.0000 +1.0000 +0.3427 +0.4902 +0.1711 +0.8963
-0.0000 -0.0000 +1.0000 +0.5729 +0.1012 -1.3655
-0.0000 -0.0000 -0.0000 +1.0000 +0.4102 -0.6692
-0.0000 -0.0000 -0.0000 -0.0000 +1.0000 -6.1131
Ab : pivot[5][5] zero_above_pivot_gj1Ab_mR();
+1.0000 +0.5163 -0.0786 -0.6745 +0.0000 +2.6288
+0.0000 +1.0000 +0.3427 +0.4902 +0.0000 +1.9425
+0.0000 +0.0000 +1.0000 +0.5729 +0.0000 -0.7471
+0.0000 +0.0000 +0.0000 +1.0000 +0.0000 +1.8381
-0.0000 -0.0000 -0.0000 -0.0000 +1.0000 -6.1131
Press return to continue.
Ab : pivot[4][[4]
+1.0000 +0.5163 -0.0786 -0.6745 +0.0000 +2.6288
+0.0000 +1.0000 +0.3427 +0.4902 +0.0000 +1.9425
+0.0000 +0.0000 +1.0000 +0.5729 +0.0000 -0.7471
+0.0000 +0.0000 +0.0000 +1.0000 +0.0000 +1.8381
-0.0000 -0.0000 -0.0000 -0.0000 +1.0000 -6.1131
Ab : pivot[4][4] zero_above_pivot_gj1Ab_mR();
+1.0000 +0.5163 -0.0786 +0.0000 +0.0000 +3.8686
+0.0000 +1.0000 +0.3427 +0.0000 +0.0000 +1.0415
+0.0000 +0.0000 +1.0000 +0.0000 +0.0000 -1.8001
+0.0000 +0.0000 +0.0000 +1.0000 +0.0000 +1.8381
-0.0000 -0.0000 -0.0000 -0.0000 +1.0000 -6.1131
Press return to continue.
Ab : pivot[3][[3]
+1.0000 +0.5163 -0.0786 +0.0000 +0.0000 +3.8686
+0.0000 +1.0000 +0.3427 +0.0000 +0.0000 +1.0415
+0.0000 +0.0000 +1.0000 +0.0000 +0.0000 -1.8001
+0.0000 +0.0000 +0.0000 +1.0000 +0.0000 +1.8381
-0.0000 -0.0000 -0.0000 -0.0000 +1.0000 -6.1131
Ab : pivot[3][3] zero_above_pivot_gj1Ab_mR();
+1.0000 +0.5163 +0.0000 +0.0000 +0.0000 +3.7272
+0.0000 +1.0000 +0.0000 +0.0000 +0.0000 +1.6583
+0.0000 +0.0000 +1.0000 +0.0000 +0.0000 -1.8001
+0.0000 +0.0000 +0.0000 +1.0000 +0.0000 +1.8381
-0.0000 -0.0000 -0.0000 -0.0000 +1.0000 -6.1131
Press return to continue.
Ab : pivot[2][[2]
+1.0000 +0.5163 +0.0000 +0.0000 +0.0000 +3.7272
+0.0000 +1.0000 +0.0000 +0.0000 +0.0000 +1.6583
+0.0000 +0.0000 +1.0000 +0.0000 +0.0000 -1.8001
+0.0000 +0.0000 +0.0000 +1.0000 +0.0000 +1.8381
-0.0000 -0.0000 -0.0000 -0.0000 +1.0000 -6.1131
Ab : pivot[2][2] zero_above_pivot_gj1Ab_mR();
+1.0000 +0.0000 +0.0000 +0.0000 +0.0000 +2.8709
+0.0000 +1.0000 +0.0000 +0.0000 +0.0000 +1.6583
+0.0000 +0.0000 +1.0000 +0.0000 +0.0000 -1.8001
+0.0000 +0.0000 +0.0000 +1.0000 +0.0000 +1.8381
-0.0000 -0.0000 -0.0000 -0.0000 +1.0000 -6.1131
Press return to continue.
The columns and the rows are not sorted:
Zero above the pivot:
gj_TP_mR(Ab);
+1.0000 +0.0000 +0.0000 +0.0000 +0.0000 +2.8709
+0.0000 +1.0000 +0.0000 +0.0000 +0.0000 +1.6583
+0.0000 +0.0000 +1.0000 +0.0000 +0.0000 -1.8001
+0.0000 +0.0000 +0.0000 +1.0000 +0.0000 +1.8381
-0.0000 -0.0000 -0.0000 -0.0000 +1.0000 -6.1131
Press return to continue
Press X return to stop