Application


Installer et compiler ces fichiers dans votre répertoire de travail.


c02c.c
/* ------------------------------------ */
/*  Save as :   c2c.c                   */
/* ------------------------------------ */
#include      "v_a.h"
/* ------------------------------------ */
int main(void)
{
double a[R3*C6]={
1, 3,  3,    1,0,0,
2, 8,  1,    0,1,0,
1, 4, -6,    0,0,1,
};

double inva[R3*C3]={
    +52/13.,     -30/13.,     +21/13., 
    -13/13.,      +9/13.,      -5/13., 
     -0/13.,      +1/13.,      -2/13.,
};

double **A    = ca_A_mR(a,   i_mR(R3,C6));
double **invA = ca_A_mR(inva,i_mR(R3,C3));
double **T    =              i_mR(R3,C3);

int i  = 1;

/* 1----------------------------------- 
      +1.00       +3.00       +3.00       +1.00       +0.00       +0.00 
      +2.00       +8.00       +1.00       +0.00       +1.00       +0.00 
      +1.00       +4.00       -6.00       +0.00       +0.00       +1.00 
   ------------------------------------ */
     clrscrn();
     printf(" (%d) \n\n",i++);
     p_mR(A,S11,P2,C8);
     printf(" R2 = -2*R1 + R2 \n");addR_mR(A, -2,R1,R2);           
     printf(" R3 = -1*R1 + R3 \n");addR_mR(A, -1,R1,R3);           
     p_mR(A,S11,P2,C8);
     stop();

/* 2----------------------------------- 
      +1.00       +3.00       +3.00       +1.00       +0.00       +0.00 
      +0.00       +2.00       -5.00       -2.00       +1.00       +0.00 
      +0.00       +1.00       -9.00       -1.00       +0.00       +1.00
   ------------------------------------ */
     clrscrn();
     printf(" (%d) \n\n",i++);
     p_mR(A,S11,P2,C8);
     printf(" R3 =  2*R3 \n");     mulR_mR(A, 2.,R3);          
     printf(" R3 = -1*R2 + R3 \n");addR_mR(A,-1.,R2,R3);       
     p_mR(A,S11,P2,C8);
     stop();

/* 3----------------------------------- 
      +1.00       +3.00       +3.00       +1.00       +0.00       +0.00 
      +0.00       +2.00       -5.00       -2.00       +1.00       +0.00 
      +0.00       +0.00      -13.00       +0.00       -1.00       +2.00 
   ------------------------------------ */
     clrscrn();
     printf(" (%d) \n\n",i++);
     p_mR(A,S11,P2,C8);
     printf(" R1 =  13.*R 1 \n");   mulR_mR(A, 13.,R1);          
     printf(" R2 =  13.*R2  \n");   mulR_mR(A, 13.,R2);          
     printf(" R3 = -1. *R3\n\n");   mulR_mR(A, -1.,R3 );          
     printf(" R1 =  -3*R3 + R1 \n");addR_mR(A, -3.,R3,R1);     
     printf(" R2 =  +5*R3 + R2 \n");addR_mR(A, +5.,R3,R2);     
     p_mR(A,S11,P2,C8);
     stop();

/* 4----------------------------------- 
     +13.00      +39.00       +0.00      +13.00       -3.00       +6.00 
      +0.00      +26.00       +0.00      -26.00      +18.00      -10.00 
      -0.00       -0.00      +13.00       -0.00       +1.00       -2.00 
   ------------------------------------ */
     clrscrn();
     printf(" (%d) \n\n",i++);
     p_mR(A,S11,P2,C8);
     printf(" R2 =  1./2.*R2 \n");mulR_mR(A,1./2.,R2);   
     p_mR(A,S11,P2,C8);
     stop();
     
/* 5----------------------------------- 
     +13.00      +39.00       +0.00      +13.00       -3.00       +6.00 
      +0.00      +13.00       +0.00      -13.00       +9.00       -5.00 
      -0.00       -0.00      +13.00       -0.00       +1.00       -2.00 
   ------------------------------------ */
     clrscrn();
     printf(" (%d) \n\n",i++);
     p_mR(A,S11,P2,C8);
     printf(" R1 =  -3 *R2 + R1 (3*13 = 39)\n");addR_mR(A, -3.,R2,R1);    
     p_mR(A,S11,P2,C8);
     stop();
/* 6----------------------------------- 
     +13.00       +0.00       +0.00      +52.00      -30.00      +21.00 
      +0.00      +13.00       +0.00      -13.00       +9.00       -5.00 
      -0.00       -0.00      +13.00       -0.00       +1.00       -2.00 
   ------------------------------------ */     
     
     clrscrn();
     printf(" A : ");
     ca_A_mR(a, A);
     p_mR(A,S11,P2,C6);
     
     printf(" A : inv_mR(invA, T);        [see : double inva[R3*C3] ]");
     inv_mR(invA, T);
     p_mR(T, S11, P2, C6);
     stop();     
     
  f_mR(A);
  f_mR(invA);
  f_mR(T);


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


Le but de ces exemples est d'inverser une matrice sans faire apparaître de fraction. La matrice double inva[R3*C3] donne le résultat calculé dans le fichier et permet de vérifier que inv(invA) = A.


Exemple de sortie écran :
 ------------------------------------ 
 (1) 


      +1.00       +3.00       +3.00       +1.00       +0.00       +0.00 
      +2.00       +8.00       +1.00       +0.00       +1.00       +0.00 
      +1.00       +4.00       -6.00       +0.00       +0.00       +1.00 

 R2 = -2*R1 + R2 
 R3 = -1*R1 + R3 

      +1.00       +3.00       +3.00       +1.00       +0.00       +0.00 
      +0.00       +2.00       -5.00       -2.00       +1.00       +0.00 
      +0.00       +1.00       -9.00       -1.00       +0.00       +1.00 

 Press return to continue. 


 ------------------------------------ 
 (2) 


      +1.00       +3.00       +3.00       +1.00       +0.00       +0.00 
      +0.00       +2.00       -5.00       -2.00       +1.00       +0.00 
      +0.00       +1.00       -9.00       -1.00       +0.00       +1.00 

 R3 =  2*R3 
 R3 = -1*R2 + R3 

      +1.00       +3.00       +3.00       +1.00       +0.00       +0.00 
      +0.00       +2.00       -5.00       -2.00       +1.00       +0.00 
      +0.00       +0.00      -13.00       +0.00       -1.00       +2.00 

 Press return to continue. 



 ------------------------------------ 
 (3) 


      +1.00       +3.00       +3.00       +1.00       +0.00       +0.00 
      +0.00       +2.00       -5.00       -2.00       +1.00       +0.00 
      +0.00       +0.00      -13.00       +0.00       -1.00       +2.00 

 R1 =  13.*R 1 
 R2 =  13.*R2  
 R3 = -1. *R3

 R1 =  -3*R3 + R1 
 R2 =  +5*R3 + R2 

     +13.00      +39.00       +0.00      +13.00       -3.00       +6.00 
      +0.00      +26.00       +0.00      -26.00      +18.00      -10.00 
      -0.00       -0.00      +13.00       -0.00       +1.00       -2.00 

 Press return to continue. 


 ------------------------------------ 
 (4) 


     +13.00      +39.00       +0.00      +13.00       -3.00       +6.00 
      +0.00      +26.00       +0.00      -26.00      +18.00      -10.00 
      -0.00       -0.00      +13.00       -0.00       +1.00       -2.00 

 R2 =  1./2.*R2 

     +13.00      +39.00       +0.00      +13.00       -3.00       +6.00 
      +0.00      +13.00       +0.00      -13.00       +9.00       -5.00 
      -0.00       -0.00      +13.00       -0.00       +1.00       -2.00 

 Press return to continue. 


 ------------------------------------ 
 (5) 


     +13.00      +39.00       +0.00      +13.00       -3.00       +6.00 
      +0.00      +13.00       +0.00      -13.00       +9.00       -5.00 
      -0.00       -0.00      +13.00       -0.00       +1.00       -2.00 

 R1 =  -3 *R2 + R1 (3*13 = 39)

     +13.00       +0.00       +0.00      +52.00      -30.00      +21.00 
      +0.00      +13.00       +0.00      -13.00       +9.00       -5.00 
      -0.00       -0.00      +13.00       -0.00       +1.00       -2.00 

 Press return to continue. 



 ------------------------------------ 
 A : 
      +1.00       +3.00       +3.00       +1.00       +0.00       +0.00 
      +2.00       +8.00       +1.00       +0.00       +1.00       +0.00 
      +1.00       +4.00       -6.00       +0.00       +0.00       +1.00 

 A : inv_mR(invA, T);        [see : double inva[R3*C3] ]
      +1.00       +3.00       +3.00 
      +2.00       +8.00       +1.00 
      +1.00       +4.00       -6.00 

 Press return to continue.