Linear Algebra and the C Language/a0kh


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :   c00f.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
double **X_gj1_T_mR(
double **Ab
)
{
int r= R1;

    while(r<Ab[R_SIZE][C0])                  /* Select the best pivot */
       {
        if(fabs(pivotbest_gj1Ab_mR(Ab,r))>ERROR_E)  
         
          zero_under_pivot_gj1Ab_mR(Ab,r);   /* zero under the pivot   */
          
        r++;
       } 
                
    while(r>R1)
    
        zero_above_pivot_gj1Ab_mR(Ab,--r);   /* zero above the pivot  */
        
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();
  printf(" Copy/Paste into the octave window.\n\n");
  p_Octave_mR(Ab,"Ab",P0);
  printf("\n rref(Ab,.00000000001)\n\n");
  stop();

  clrscrn();
  X_gj_TP_mR(Ab);
  printf(" See above for the function code: gj1_T_mR(Ab);\n\n"
         " The columns and 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(rp_I(R2)+R2);


} while(stop_w());

  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */

Screen output example:

                                                                                       
 Copy/Paste into the octave window.

 Ab=[
+854,-24,+671,-649;
+863,-69,+247,+167;
+455,-170,-235,+640]


 rref(Ab,.00000000001)

 Press return to continue. 


 See above for the function code: gj1_T_mR(Ab);

 The columns and the rows are not sorted:

   gj_TP_mR(Ab);
   +1.0000    +0.0000    -0.0000    +0.9062 
   +0.0000    +1.0000    +0.0000    -2.0663 
   -0.0000    +0.0000    +1.0000    +1.5171 


 Press   return to continue
 Press X return to stop