Linear Algebra and the C Language/a05n


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :  c00a.c                   */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
double Xdet_R(
double **A
)
{
double **T = c_mR(A,
                i_RC_mR(A[R_SIZE][C0],A[C_SIZE][C0]));
double deter=1;
int rc;
/* ------------------------------------ */
		clrscrn();
		printf("p_mR(T,S8,P4,C6);\n\n");   
		p_mR(T,S10,P4,C6);
		stop();
/* ------------------------------------ */
    for( rc=C1; rc<T[C_SIZE][C0]; rc++)
       {
        deter *= pivotbest_mR(T,rc);
/* ------------------------------------ */
		clrscrn();
		printf("deter *= pivotbest_mR(T,rc);\n\n");   
		p_mR(T,S10,P4,C6);
		stop();
/* ------------------------------------ */        
        deter *= zero_under_pivot_mR(T,rc);
/* ------------------------------------ */
		clrscrn();
		printf("deter *= zero_under_pivot_mR(T,rc);\n\n");   
		p_mR(T,S10,P4,C6);
	    if(rc+C1<T[C_SIZE][C0]) stop();
/* ------------------------------------ */          
       }

   f_mR(T);

return(deter);
}
/* ------------------------------------ */
/* ------------------------------------ */
void fun(int r)
{
double **A = r_mR(i_mR(R4,R4),999);

  clrscrn();
  printf(" Copy/Paste into the octave window.       \n\n");
  p_Octave_mR(A,"A",P1);
  printf(" det(A)\n\n\n");
  stop();

  printf("\n\n det(A) = %.4e\n\n\n\n",Xdet_R(A));
  
  f_mR(A);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

do
{
  fun(rp_I(RC4)+RC1);

} while(stop_w());

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


Screen output example:

 Copy/Paste into the octave window.       

 A=[
-43.0,-926.0,+708.0,-349.0;
+392.0,+579.0,-665.0,-705.0;
+58.0,-14.0,-95.0,+185.0;
-273.0,+93.0,-214.0,-128.0]

 det(A)


 Press return to continue. 


p_mR(T,S8,P4,C6);


  -43.0000  -926.0000  +708.0000  -349.0000 
 +392.0000  +579.0000  -665.0000  -705.0000 
  +58.0000   -14.0000   -95.0000  +185.0000 
 -273.0000   +93.0000  -214.0000  -128.0000 

 Press return to continue. 


deter *= pivotbest_mR(T,rc);


 -926.0000   -43.0000  +708.0000  -349.0000 
 +579.0000  +392.0000  -665.0000  -705.0000 
  -14.0000   +58.0000   -95.0000  +185.0000 
  +93.0000  -273.0000  -214.0000  -128.0000 

 Press return to continue. 


deter *= zero_under_pivot_mR(T,rc);


   +1.0000    +0.0464    -0.7646    +0.3769 
   +0.0000  +365.1134  -222.3089  -923.2192 
   +0.0000   +58.6501  -105.7041  +190.2765 
   +0.0000  -277.3186  -142.8942  -163.0508 

 Press return to continue. 


deter *= pivotbest_mR(T,rc);


   +1.0000    +0.3769    -0.7646    +0.0464 
   +0.0000  -923.2192  -222.3089  +365.1134 
   +0.0000  +190.2765  -105.7041   +58.6501 
   +0.0000  -163.0508  -142.8942  -277.3186 

 Press return to continue. 


deter *= zero_under_pivot_mR(T,rc);


   +1.0000    +0.3769    -0.7646    +0.0464 
   -0.0000    +1.0000    +0.2408    -0.3955 
   +0.0000    +0.0000  -151.5222  +133.9004 
   +0.0000    +0.0000  -103.6320  -341.8016 

 Press return to continue. 


deter *= pivotbest_mR(T,rc);


   +1.0000    +0.3769    +0.0464    -0.7646 
   -0.0000    +1.0000    -0.3955    +0.2408 
   +0.0000    +0.0000  -341.8016  -103.6320 
   +0.0000    +0.0000  +133.9004  -151.5222 

 Press return to continue. 


deter *= zero_under_pivot_mR(T,rc);


   +1.0000    +0.3769    +0.0464    -0.7646 
   -0.0000    +1.0000    -0.3955    +0.2408 
   -0.0000    -0.0000    +1.0000    +0.3032 
   +0.0000    +0.0000    +0.0000  -192.1199 

 Press return to continue. 


deter *= pivotbest_mR(T,rc);


   +1.0000    +0.3769    +0.0464    -0.7646 
   -0.0000    +1.0000    -0.3955    +0.2408 
   -0.0000    -0.0000    +1.0000    +0.3032 
   +0.0000    +0.0000    +0.0000  -192.1199 

 Press return to continue. 


deter *= zero_under_pivot_mR(T,rc);


   +1.0000    +0.3769    +0.0464    -0.7646 
   -0.0000    +1.0000    -0.3955    +0.2408 
   -0.0000    -0.0000    +1.0000    +0.3032 
   -0.0000    -0.0000    -0.0000    +1.0000 



 det(A) = 5.6139e+10




 Press   return to continue
 Press X return to stop