Linear Algebra and the C Language/a0hv


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :   c00c.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int rc)
{
double **A     = rlower_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:");
  pE_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;
}
/* ------------------------------------ */
/* ------------------------------------ */
The inverse of a lower triangular matrix

Screen output example:

                                                                                       
 A:
  +2   +0   +0   +0 
  -8   +2   +0   +0 
  -8   +3   +4   +0 
  +3   +5   -8   +9 

 invA:
+5.00000e-01 -0.00000e+00 -0.00000e+00 -0.00000e+00 
+2.00000e+00 +5.00000e-01 -0.00000e+00 -0.00000e+00 
-5.00000e-01 -3.75000e-01 +2.50000e-01 +0.00000e+00 
-1.72222e+00 -6.11111e-01 +2.22222e-01 +1.11111e-01 

 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