Linear Algebra and the C Language/a0ke


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :   c00c.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
double **X_sort_c_mR(
double **Ab
)
{
double **T = i_RC_mR(Ab[R_SIZE][C0],Ab[C_SIZE][C0]);
int c;

  for(c=C1; c<Ab[C_SIZE][C0]; c++)
  {
clrscrn(); 
printf("/* --------- DEBUG 1 ---------- */\n\n");	           
printf(" Copy  C[%d] of Ab into C[%.0f] of T\n",c,Ab[R0][c]);
pall_mR(Ab, S8,P4,C8);

           c_c_withR0_mR(  Ab,        c,
                            T, Ab[R0][c]);
                            
printf(" T[R0][%.0f]\n",Ab[R0][c]);
pall_mR(T, S8,P4,C8);
stop();
clrscrn(); 
/* --------- DEBUG 1 ---------- */
   }

   printf(" Ab : before\n");
   pall_mR(Ab, S8,P4,C8);
 
      
 c_withR0_mR(T,Ab);
 
   printf(" Ab : after \n");
   pall_mR(Ab, S8,P4,C8);
   stop();
   clrscrn();  
  
 f_mR(T);
 
 return(Ab);
}
/* ------------------------------------ */
/* ------------------------------------ */
double **X_gj_TP_mR(
double **Ab
)
{
       gj1_T_mR(Ab);  
    X_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 rows are not sorted:\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:

                                                                                       
/* --------- DEBUG 1 ---------- */

 Copy  C[1] of Ab into C[4] of T
+6                +4       +3       +1       +5       +2       +6 

+7           +1.0000  +0.0000  +0.0000  +0.0000  +0.0000  +1.4702 
+6           +0.0000  +1.0000  +0.0000  +0.0000  +0.0000  +0.2617 
+0           -0.0000  -0.0000  +1.0000  +0.0000  +0.0000  +0.5601 
+0           +0.0000  +0.0000  +0.0000  +1.0000  +0.0000  -1.3011 
+0           +0.0000  +0.0000  +0.0000  +0.0000  +1.0000  +0.1527 

 T[R0][4]
+6                +1       +2       +3       +4       +5       +6 

+7           +0.0000  +0.0000  +0.0000  +1.0000  +0.0000  +0.0000 
+0           +0.0000  +0.0000  +0.0000  +0.0000  +0.0000  +0.0000 
+0           +0.0000  +0.0000  +0.0000  -0.0000  +0.0000  +0.0000 
+0           +0.0000  +0.0000  +0.0000  +0.0000  +0.0000  +0.0000 
+0           +0.0000  +0.0000  +0.0000  +0.0000  +0.0000  +0.0000 

 Press return to continue. 


/* --------- DEBUG 1 ---------- */

 Copy  C[2] of Ab into C[3] of T
+6                +4       +3       +1       +5       +2       +6 

+7           +1.0000  +0.0000  +0.0000  +0.0000  +0.0000  +1.4702 
+6           +0.0000  +1.0000  +0.0000  +0.0000  +0.0000  +0.2617 
+0           -0.0000  -0.0000  +1.0000  +0.0000  +0.0000  +0.5601 
+0           +0.0000  +0.0000  +0.0000  +1.0000  +0.0000  -1.3011 
+0           +0.0000  +0.0000  +0.0000  +0.0000  +1.0000  +0.1527 

 T[R0][3]
+6                +1       +2       +3       +4       +5       +6 

+7           +0.0000  +0.0000  +0.0000  +1.0000  +0.0000  +0.0000 
+0           +0.0000  +0.0000  +1.0000  +0.0000  +0.0000  +0.0000 
+0           +0.0000  +0.0000  -0.0000  -0.0000  +0.0000  +0.0000 
+0           +0.0000  +0.0000  +0.0000  +0.0000  +0.0000  +0.0000 
+0           +0.0000  +0.0000  +0.0000  +0.0000  +0.0000  +0.0000 

 Press return to continue. 

/* --------- DEBUG 1 ---------- */

 Copy  C[3] of Ab into C[1] of T
+6                +4       +3       +1       +5       +2       +6 

+7           +1.0000  +0.0000  +0.0000  +0.0000  +0.0000  +1.4702 
+6           +0.0000  +1.0000  +0.0000  +0.0000  +0.0000  +0.2617 
+0           -0.0000  -0.0000  +1.0000  +0.0000  +0.0000  +0.5601 
+0           +0.0000  +0.0000  +0.0000  +1.0000  +0.0000  -1.3011 
+0           +0.0000  +0.0000  +0.0000  +0.0000  +1.0000  +0.1527 

 T[R0][1]
+6                +1       +2       +3       +4       +5       +6 

+7           +0.0000  +0.0000  +0.0000  +1.0000  +0.0000  +0.0000 
+0           +0.0000  +0.0000  +1.0000  +0.0000  +0.0000  +0.0000 
+0           +1.0000  +0.0000  -0.0000  -0.0000  +0.0000  +0.0000 
+0           +0.0000  +0.0000  +0.0000  +0.0000  +0.0000  +0.0000 
+0           +0.0000  +0.0000  +0.0000  +0.0000  +0.0000  +0.0000 

 Press return to continue. 


/* --------- DEBUG 1 ---------- */

 Copy  C[4] of Ab into C[5] of T
+6                +4       +3       +1       +5       +2       +6 

+7           +1.0000  +0.0000  +0.0000  +0.0000  +0.0000  +1.4702 
+6           +0.0000  +1.0000  +0.0000  +0.0000  +0.0000  +0.2617 
+0           -0.0000  -0.0000  +1.0000  +0.0000  +0.0000  +0.5601 
+0           +0.0000  +0.0000  +0.0000  +1.0000  +0.0000  -1.3011 
+0           +0.0000  +0.0000  +0.0000  +0.0000  +1.0000  +0.1527 

 T[R0][5]
+6                +1       +2       +3       +4       +5       +6 

+7           +0.0000  +0.0000  +0.0000  +1.0000  +0.0000  +0.0000 
+0           +0.0000  +0.0000  +1.0000  +0.0000  +0.0000  +0.0000 
+0           +1.0000  +0.0000  -0.0000  -0.0000  +0.0000  +0.0000 
+0           +0.0000  +0.0000  +0.0000  +0.0000  +1.0000  +0.0000 
+0           +0.0000  +0.0000  +0.0000  +0.0000  +0.0000  +0.0000 

 Press return to continue. 

 .... .... .... 

 Ab : before
+6                +4       +3       +1       +5       +2       +6 

+7           +1.0000  +0.0000  +0.0000  +0.0000  +0.0000  +1.4702 
+6           +0.0000  +1.0000  +0.0000  +0.0000  +0.0000  +0.2617 
+0           -0.0000  -0.0000  +1.0000  +0.0000  +0.0000  +0.5601 
+0           +0.0000  +0.0000  +0.0000  +1.0000  +0.0000  -1.3011 
+0           +0.0000  +0.0000  +0.0000  +0.0000  +1.0000  +0.1527 

 Ab : after 
+6                +1       +2       +3       +4       +5       +6 

+7           +0.0000  +0.0000  +0.0000  +1.0000  +0.0000  +1.4702 
+6           +0.0000  +0.0000  +1.0000  +0.0000  +0.0000  +0.2617 
+0           +1.0000  +0.0000  -0.0000  -0.0000  +0.0000  +0.5601 
+0           +0.0000  +0.0000  +0.0000  +0.0000  +1.0000  -1.3011 
+0           +0.0000  +1.0000  +0.0000  +0.0000  +0.0000  +0.1527 

 Press return to continue. 


 The rows are not sorted:

 gj_TP_mR(Ab);
   +0.0000    +0.0000    +0.0000    +1.0000    +0.0000    +1.4702 
   +0.0000    +0.0000    +1.0000    +0.0000    +0.0000    +0.2617 
   +1.0000    +0.0000    -0.0000    -0.0000    +0.0000    +0.5601 
   +0.0000    +0.0000    +0.0000    +0.0000    +1.0000    -1.3011 
   +0.0000    +1.0000    +0.0000    +0.0000    +0.0000    +0.1527 


 Press   return to continue
 Press X return to stop