Linear Algebra and the C Language/a0gq


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :   c00c.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int rc)
{
double **A     = rsymmetric_mR(i_mR(rc,rc),9);
double **invA  =               i_mR(rc,rc);
double **AinvA =               i_mR(rc,rc);

  clrscrn();

  printf(" A:");
  p_mR(A, S4,P0,C6);

  printf(" invA:");
  p_mR(invgj_mR(A,invA), S4,P5,C6);

  printf(" A invA:");
  p_mR(mul_mR(A,invA,AinvA), S4,P5,C6);
    
  f_mR(A);
  f_mR(invA);
  f_mR(AinvA);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));
  
   do 
         fun(rp_I(RC4)+RC1);
        
    while(stop_w());
        
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
If the inverse of a symmetric matrix exists, it is symmetric.

Screen output example:

                                                                                       
 A:
  -9   +6   -1   +5 
  +6   -9   -6   +7 
  -1   -6   -7   -9 
  +5   +7   -9   +1 

 invA:
-0.08342 +0.00198 -0.04043 +0.03939 
+0.00198 -0.04749 -0.02977 +0.05459 
-0.04043 -0.02977 -0.05086 -0.04722 
+0.03939 +0.05459 -0.04722 -0.00405 

 A invA:
+1.00000 +0.00000 +0.00000 +0.00000 
+0.00000 +1.00000 -0.00000 -0.00000 
+0.00000 -0.00000 +1.00000 +0.00000 
+0.00000 -0.00000 -0.00000 +1.00000 


 Press   return to continue
 Press X return to stop