Linear Algebra and the C Language/a0lv


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as:   c01b.c                   */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define   RCA    RC3
/* ------------------------------------ */
#define    EV    R2  
/* ------------------------------------ */
int main(void)
{
double a[RCA*RCA]={
+8.146673651126, +0.924044002095,  +1.085385018334, 
+0.924044002095, +13.821477213201, +6.837925615505, 
+1.085385018334, +6.837925615506,  +16.031849135673   
};

double **A        =     ca_A_mR(a,                    i_mR(RCA,RCA));
double **EValue   =     eigs_mR(A,                    i_mR(RCA,RCA));

double **Ide      =      eye_mR(                      i_mR(RCA,RCA));
double **sIde     =     smul_mR(EValue[EV][C1],Ide,   i_mR(RCA,RCA));
double **AmnssIde =      sub_mR(A,sIde,               i_mR(RCA,RCA));

double **b        =       m0_mR(i_mR(RCA,C1));
double **Ab       = c_A_b_Ab_mR(AmnssIde,b, i_Abr_Ac_bc_mR(RCA,RCA,C1));

double **Ab_free  =                         i_Abr_Ac_bc_mR(RCA,RCA,RCA);
double **b_free   =                                   i_mR(RCA,RCA);

double **V        =                                   i_mR(RCA,RCA);

  clrscrn();
  printf(" The eigenvectors associated with eigenvalues\n"
         " with multiple multiplicity are not unique.  \n"
         " There exist several set of unit vectors that\n"
         " correspond to the same eigenspace.      \n\n\n"
         " A:");
  p_mR(A,S10,P5,C10);
          
                
        gj_PP_mR(Ab,YES);  
    put_zeroR_mR(Ab,Ab_free);
    put_freeV_mR(Ab_free); 
        gj_PP_mR(Ab_free,YES);      
       c_Ab_b_mR(Ab_free,b_free);

          c_c_mR(b_free,C2,V,EV); 
          c_c_mR(b_free,C3,V,EV+C1); 
                    
    Normalize_mR(V);
           
           
          printf("\n\n\n"
                 " Copy V%d into the last file\n\n"
                 " V%d:",EV,EV);
          P_mR(V,S10,P12,C10); 
           
  stop();
             
  f_mR(A);
  f_mR(EValue);
  
  f_mR(Ide);
  f_mR(sIde);
  f_mR(AmnssIde);
  
  f_mR(Ab);
  f_mR(b);
  f_mR(Ab_free);    
  f_mR(b_free);
  
  f_mR(V); 
  
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */

Screen output example:

                                                                                       
 The eigenvectors associated with eigenvalues
 with multiple multiplicity are not unique.  
 There exist several set of unit vectors that
 correspond to the same eigenspace.      


 A:
  +8.14667   +0.92404   +1.08539 
  +0.92404  +13.82148   +6.83793 
  +1.08539   +6.83793  +16.03185 




 Copy V2 into the last file

 V2:
      -nan, -0.987635528464, -0.990992430410, 
      -nan, +0.156767544201, +0.000000000000, 
      -nan, +0.000000000000, +0.133917896001  

 Press return to continue.