Linear Algebra and the C Language/a0bt


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  save as :   c00d.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define   RA R3
#define   CA C3
#define   CB C1
/* ------------------------------------ */
void fun(void)
{
double **A    =       r_Q_mR(       i_mR(RA,CA),99);
double **B    =         r_mR(       i_mR(RA,CB),99);
double **Ab   =           i_Abr_Ac_bc_mR(RA,CA,CB);

double **A_T  = transpose_mR(A,     i_mR(RA,CA));
double **A_TB =       mul_mR(A_T,B, i_mR(RA,CB));

  clrscrn();
  printf(" A:          Orthonormal");
  p_mR(A, S9,P4, C3);

  printf("  b:");
  p_mR(B, S9,P4, C3);

  printf(" Ab:");
  c_A_b_Ab_mR(A,B,Ab);
  p_mR(Ab, S9,P4, C4);
  stop();
  
  clrscrn(); 
  printf("  gj_mR(Ab);");
  p_mR(gj_TP_mR(Ab), S9,P4, C4);
  
  printf(" A_T B: ");
  p_mR(A_TB, S9,P4, C3);

  f_mR(A);
  f_mR(B);
  f_mR(Ab);  
  f_mR(A_T);
  f_mR(A_TB);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));
do
{
  fun();

} while(stop_w());

  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */


Screen output example:

                                                                                       
 A : Orthonormal
  -0.5635   -0.3324   -0.7563 
  +0.7017   -0.6757   -0.2259 
  -0.4359   -0.6580   +0.6140 

  b :
 +92.0000 
  -3.0000 
 -11.0000 

 Ab :
  -0.5635   -0.3324   -0.7563  +92.0000 
  +0.7017   -0.6757   -0.2259   -3.0000 
  -0.4359   -0.6580   +0.6140  -11.0000 

 Press return to continue. 


  gj_mR(Ab) :
  +1.0000   +0.0000   +0.0000  -49.1530 
  +0.0000   +1.0000   -0.0000  -21.3172 
  +0.0000   +0.0000   +1.0000  -75.6542 

 A_T B 
 -49.1530 
 -21.3172 
 -75.6542 


 Press   return to continue
 Press X return to stop