Linear Algebra and the C Language/a0cn


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :  c00b.c                   */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define   RCA C3
/* ------------------------------------ */
int main(void)
{
double a[RCA*RCA]={
+3,-5,+3,
-5,+4,+4,
+3,+4,+7
};

double R = 6;

double **A        =      ca_A_mR(a,       i_mR(RCA,RCA));
double **EVector  =    eigs_V_mR(A,       i_mR(RCA,RCA));  
double **EVectorT = transpose_mR(EVector, i_mR(RCA,RCA));

double **T1       =                       i_mR(RCA,RCA);
double **T2       =                       i_mR(RCA,RCA);

  clrscrn();
  printf(" If %+.0fx^2 %+.0fy^2 %+.0fz^2 "
         " %+.0fxy %+.0fxz %+.0fyz= %+.0f \n\n"
         " Can you give a description of the curve "
         " in the standar basis?\n\n",
                A[R1][C1],     A[R2][C2],     A[R3][C3], 
             2*(A[R2][C1]), 2*(A[R3][C1]), 2*(A[R3][C2]), R);  

  printf(" A:");
  p_mR(A,S10,P4,C6);

  printf(" EVector:"); 
  p_mR(EVector,S10,P4,C6);

  printf(" EValue : EVectorT A EVector");    
  mul_mR(EVectorT,A,T1);
  mul_mR(T1,EVector,T2);
  p_mR(T2,S10,P4,C6);  
          
  printf(" Then : %+.3f x^2 %+.3f y^2 %+.3f z^2 = %.3f \n\n"
         " It is an hyperboloid of one sheet\n\n",
           T2[R1][C1], T2[R2][C2], T2[R3][C3], R); 
  stop();

  clrscrn();
  printf(" Copy/Paste into the octave windows \n\n");
  p_Octave_mR(A,"a",P0);
  printf(" [V, E] = eigs (a,%d) \n\n",RCA);
  stop();
   
  f_mR(A);
  
  f_mR(EVector);
  f_mR(EVectorT);
   
  f_mR(T1);
  f_mR(T2);
  
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */

Screen output example:

                                                                                       
 If +3x^2 +4y^2 +7z^2  -10xy +6xz +8yz= +6 

 Can you give a description of the curve  in the standar basis?

 A:
   +3.0000    -5.0000    +3.0000 
   -5.0000    +4.0000    +4.0000 
   +3.0000    +4.0000    +7.0000 

 EVector:
   -0.1309    +0.7469    +0.6519 
   +0.6353    -0.4417    +0.6335 
   +0.7611    +0.4971    -0.4167 

 EValue : EVectorT A EVector
   +9.8227    -0.0000    -0.0000 
   -0.0000    +7.9534    +0.0000 
   +0.0000    +0.0000    -3.7761 

 Then : +9.823 x^2 +7.953 y^2 -3.776 z^2 = 6.000 

 It is an hyperboloid of one sheet

 Press return to continue.