Linear Algebra and the C Language/a0fw


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :  c00e.c                   */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define   RA R3          
/* ------------------------------------ */
void fun(void)
{
double **A         = rsymmetric_mR(         i_mR(RA,RA),999.);

double **EVector   =     eigs_V_mR(A,       i_mR(RA,RA)); 
double **EVectorT  =  transpose_mR(EVector, i_mR(RA,RA));  
double **EValue    =                        i_mR(RA,RA);

double **T1 =                               i_mR(RA,RA);

  clrscrn(); 
  printf(" A:");
  p_mR(A, S10,P4,C6);
   
  printf(" EValue = EVectorT  A  EVector");
  mul_mR(EVectorT,A,T1);
  mul_mR(T1,EVector,EValue);
  p_mR(EValue, S10,P4,C6);  
    
  printf(" trace_R(A) \t\t= %10.1f\n",       trace_R(A));
  printf(" trace_R(EValue) \t= %10.1f\n",trace_R(EValue));    
    
  f_mR(A);
  
  f_mR(EVector);
  f_mR(EVectorT);
   
  f_mR(EValue);
   
  f_mR(T1);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

do
{
  fun();

} while(stop_w());

  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
trace_R(A) = trace_R(EValues):

Screen output example:

                                                                                       
 A:
 +427.0000  +343.0000  +116.0000 
 +343.0000  +241.0000  +845.0000 
 +116.0000  +845.0000  +357.0000 

 EValue = EVectorT  A  EVector
+1269.1009    -0.0000    +0.0000 
   -0.0000  -579.0567    +0.0000 
   +0.0000    +0.0000  +334.9558 

 trace_R(A) 		=     1025.0
 trace_R(EValue) 	=     1025.0

 Press   return to continue
 Press X return to stop