Linear Algebra and the C Language/a0mu


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :  c03b.c                   */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
#define   RA R3
#define   CA C3

#define   RX R3
#define   CX C1
/* ------------------------------------ */
/* ------------------------------------ */
int main(void)
{
double a[RA*CA]={
    +3, -4, -2,  
    +5, -3, -1,
    +4, -3, -1   
};

double x_S[RX*CX]={
  +23.00, 
  +14.00, 
  +21.00  
};

double **A    = ca_A_mR(a,     i_mR(RA,CA));
double **x_s  = ca_A_mR(x_S,   i_mR(RX,CX));
double **Ax_s =  mul_mR(A,x_s, i_mR(RA,CX));

  clrscrn();
  printf(" In the Standard basis\n\n"
         " Calculate the linear application T(x_s) = A x_s \n\n"
         " With A :");
  p_mR(A,S6,P2,C7);
  
  printf(" And x_s:");
  p_mR(x_s,S6,P2,C7);
  
  printf(" T(x_s) = A x_s");
  p_mR(Ax_s,S7,P2,C7);
  stop();


  f_mR(A);
  f_mR(x_s);
  f_mR(Ax_s);
  
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */

Screen output example:

                                                                                       
 In the Standard basis

 Calculate the linear application T(x_s) = A x_s 

 With A :
 +3.00  -4.00  -2.00 
 +5.00  -3.00  -1.00 
 +4.00  -3.00  -1.00 

 And x_s:
+23.00 
+14.00 
+21.00 

 T(x_s) = A x_s
 -29.00 
 +52.00 
 +29.00 

 Press return to continue.