Linear Algebra and the C Language/a09t


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :  c00b.c                   */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define  ARRAY  A7 
#define    RCA  R4  
/* ------------------------------------ */
void fun(void)
{
double **A[ARRAY];
double **P[ARRAY];
double **InvP[ARRAY];

double **T = i_mR(RCA,RCA);
int i;

  for(i=A0; i<ARRAY; i++)
     {   
         A[i] =              i_mR(RCA,RCA); 
         P[i] =   r_mR(      i_mR(RCA,RCA),99); 
      InvP[i] = inv_mR(P[i], i_mR(RCA,RCA));       
	   } 

  rsymmetric_mR(A[0],99);
  
    for(i=A0; i<(ARRAY-C1); i++)
     {   
        mul_mR(InvP[i],A[i],T); 
        mul_mR(T,P[i],A[i+C1]);
	   } 
	   
  clrscrn();
  printf(" Similar matrices have the same trace.\n\n");
  
  for(i=A0; i<ARRAY; i++)
     {
      printf(" A[%d] : \t\t\t trace = %+.4f ",i,trace_R(A[i]));      
      p_mR(A[i], S9,P2,C6); 
     } 

  for(i=A0; i<ARRAY; i++)
     { 
	   f_mR(A[i]);
	   f_mR(P[i]);		 
	   f_mR(InvP[i]); 
	   }
	   
  f_mR(T);       
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));
  
  do{
        fun();
        
  }while(stop_w());

  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Similar matrices have the same trace.

Screen output example:

                                                                                       
 Similar matrices have the same trace.

 A[0] : 			 trace = +29.0000 
   -86.00    -91.00    +23.00    +98.00 
   -91.00    +90.00    -35.00    -12.00 
   +23.00    -35.00     -6.00    +63.00 
   +98.00    -12.00    +63.00    +31.00 

 A[1] : 			 trace = +29.0000 
   -94.78   +607.81    +54.50    -94.47 
   +20.47    +39.20    -38.89    -24.86 
   +45.77   +160.19    +17.13    +37.68 
   -14.39   -477.19    +63.42    +67.45 

 A[2] : 			 trace = +29.0000 
  -407.83   -104.66    -94.47    +86.14 
 +3393.27  +2781.45  +3174.99  -1129.50 
 -2435.90  -1957.76  -2229.96   +806.15 
   -74.78   +767.32   +994.48   -114.66 

 A[3] : 			 trace = +29.0000 
-40292.09 -28333.90  +2368.39  -7079.15 
+59764.31 +42113.96  -3772.89 +10523.63 
+19429.32 +13696.54  -1241.22  +3428.99 
 -2804.09  -2288.47  +1119.31   -551.65 

 A[4] : 			 trace = +29.0000 
-25738.82 -11618.98 -16825.32  -9641.42 
-29394.97 -12452.58 -18978.48 -11184.03 
+78446.99 +33771.43 +50806.64 +29737.89 
-32482.19 -12769.98 -20691.34 -12586.23 

 A[5] : 			 trace = +29.0000 
-20690.59 +836017.20 +1260237.78 +3064789.08 
+56830.69 -2252587.55 -3393285.55 -8242849.50 
-66998.96 +2661119.40 +4009002.62 +9739748.91 
+11907.77 -474124.65 -714333.77 -1735695.47 

 A[6] : 			 trace = +29.0000 
+4291508.53 -1881354.02 -496858.54 +6983869.60 
-315949.17 +139446.84 +36741.82 -514593.22 
-6577938.18 +2877433.31 +760484.92 -10701866.99 
-3190110.58 +1398339.37 +369312.81 -5191411.29 


 Press   return to continue
 Press X return to stop