Linear Algebra and the C Language/a0mf


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :   c00d.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */     
#define RCA          RC4  
#define EVALUE       RC4  
/* ------------------------------------ */       
/* ------------------------------------ */
void fun(void)
{                          
double a[RCA*RCA] ={   
+3.267287828, -0.475271661, -0.227635307, +0.991405738, 
-0.475271661, +3.181920907, -1.871467453, -1.222576216, 
-0.227635307, -1.871467453, +2.581540251, -0.755834393, 
+0.991405738, -1.222576216, -0.755834393, +1.969251014    
};
                       
double **A      =   ca_A_mR(a,        i_mR(RCA,RCA));
double **V      = eigs_V_mR(A,        i_mR(RCA,RCA));

double **V3     =    c_c_mR(V,EVALUE, i_mR(RCA, C1),C1);
double **AV3    =    mul_mR(A,V3,     i_mR(RCA, C1)); 

  clrscrn();   
  printf(" We know:  A V4 = EVALUE4 V4               \n\n"
         " Verify if A V4 = 0 with A!= 0  and V4 != 0\n\n"
         " When   EVALUE4 = 0                        \n\n");

  printf(" A:");
  p_mR(A, S9,P5, C4);     

  printf(" V:");
  p_mR(V, S9,P5, C4); 
  stop();
         
  clrscrn();   
  printf(" V%d:",EVALUE);
  p_mR(V3, S9,P5, C4);

  printf(" A V%d:",EVALUE);
  p_mR(AV3, S9,P5, C4);
  stop();
              
  f_mR(A);
  f_mR(V);  

  f_mR(V3); 
  f_mR(AV3); 
}
/* ------------------------------------ */
int main(void)
{
    fun();
    
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */

Screen output example:

                                                                                       
 We know:  A V4 = EVALUE4 V4               

 Verify if A V4 = 0 with A!= 0  and V4 != 0

 When   EVALUE4 = 0                        

 A:
 +3.26729  -0.47527  -0.22764  +0.99141 
 -0.47527  +3.18192  -1.87147  -1.22258 
 -0.22764  -1.87147  +2.58154  -0.75583 
 +0.99141  -1.22258  -0.75583  +1.96925 

 V:
 -0.31795  +0.69685  +0.64009  -0.05995 
 +0.76747  +0.13627  +0.28512  +0.55779 
 -0.47145  -0.53535  +0.40238  +0.57378 
 -0.29602  +0.45742  -0.58914  +0.59670 

 Press return to continue. 


 V4:
 -0.05995 
 +0.55779 
 +0.57378 
 +0.59670 

 A V4:
 +0.00000 
 -0.00000 
 -0.00000 
 -0.00000 

 Press return to continue.