Linear Algebra and the C Language/a0dg


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :  c00g.c                   */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int r)
{
double **A       = rsymmetric_mR(   i_mR(r,r),999.);
double **EVector =     eigs_V_mR(A, i_mR(r,r));   ;

  clrscrn();
  printf(" A:");
  p_mR(A,S5,P0,C6);
 
  printf(" EVector:");
  p_mR(EVector,S5,P6,C6);
  
  printf(" det_R(EVector)  = %+.0f"
         " (The vectors form an orthonormal basis.)\n",det_R(EVector));
     
  f_mR(A);
  f_mR(EVector);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

do
{
 fun(rp_I(R4)+R2);

} while(stop_w());

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


Screen output example:

                                                                                       
 A:
 +754   -84  -516  -742   -70 
  -84  -734  -698  +672  +398 
 -516  -698  -538   -40  +689 
 -742  +672   -40  -377  -520 
  -70  +398  +689  -520  +608 

 EVector:
-0.001475 +0.871954 -0.007307 +0.463264 -0.158200 
+0.674772 -0.111963 -0.097306 -0.035241 -0.722105 
+0.514680 -0.224206 +0.404166 +0.577893 +0.433042 
-0.407738 -0.415000 -0.345917 +0.670955 -0.302796 
-0.336948 -0.068318 +0.841112 -0.001799 -0.417523 

 det_R(EVector)  = +1 (The vectors form an orthonormal basis.)

 Press   return to continue
 Press X return to stop