Aller au contenu

Mathc matrices/c30a

Un livre de Wikilivres.


Application


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


c01a.c
/* ------------------------------------ */
/*  Save as :   c01a.c                  */
/* ------------------------------------ */
#include      "v_a.h"
/* ------------------------------------ */
int main(void)
{
double a[R3*C4]={
 -36,  +21,  -14,  +45,
 -38,  +13,  +27,  -16,
 +41,   -6,  -44,  -14,
};

double **A = ca_A_mR(a,i_mR(R3,C4));

int i  = 1;

/* 1----------------------------------- 
     -36.000      +21.000      -14.000      +45.000
     -38.000      +13.000      +27.000      -16.000
     +41.000       -6.000      -44.000      -14.000
   ------------------------------------ */
     clrscrn();
     printf(" (%d) \n\n",i++);
     p_mR(A,S11,P2,C6);        
     printf(" R2 = -36*R2   \n");   mulR_mR(A,-36.,R2);
     printf(" R3 = -36*R3 \n\n");   mulR_mR(A,-36.,R3);          
     printf(" R2 =  38*R1 + R2 \n");addR_mR(A, 38.,R1,R2);
     printf(" R3 = -41*R1 + R3 \n");addR_mR(A,-41.,R1,R3);                              
     p_mR(A,S11,P2,C6);
     getchar();

/* 2----------------------------------- 
      -36.000      +21.000      -14.000      +45.000
       +0.000     +330.000    -1504.000    +2286.000
       +0.000     -645.000    +2158.000    -1341.000
   ------------------------------------ */
     clrscrn();
     printf(" (%d) \n\n",i++);
     p_mR(A,S11,P2,C6);    
     printf(" R2 =  1./2.*R2 \n");mulR_mR(A, 1/2., R2);        
     p_mR(A,S11,P2,C6);
     getchar();

/* 3----------------------------------- 
      -36.000      +21.000      -14.000      +45.000
       +0.000     +165.000     -752.000    +1143.000
       +0.000     -645.000    +2158.000    -1341.000
   ------------------------------------ */
     clrscrn();
     printf(" (%d) \n\n",i++);
     p_mR(A,S11,P2,C6);      
     printf(" R3 = 11.*R3  (165/645 = 11/43)\n"); mulR_mR(A,11.,R3);              
     printf(" R3 = 43.*R2 + R3  \n");             addR_mR(A,43.,R2,R3);                                        
     p_mR(A,S11,P2,C6);
     getchar();

/* 4----------------------------------- 
      -36.000      +21.000      -14.000      +45.000
       +0.000     +165.000     -752.000    +1143.000
       +0.000       +0.000    -8598.000   +34398.000
   ------------------------------------ */
     clrscrn();
     printf(" (%d) \n\n",i++);
     p_mR(A,S11,P2,C6);    
     printf(" R3 =  1./6.*R3 \n");mulR_mR(A,1./6.,R3);   
     p_mR(A,S11,P2,C6);
     getchar();
     
/* 5----------------------------------- 
      -36.000      +21.000      -14.000      +45.000
       +0.000     +165.000     -752.000    +1143.000
       +0.000       +0.000    -1433.000    +5733.000
   ------------------------------------ */
     clrscrn();
     printf(" (%d) \n\n",i++);
     p_mR(A,S11,P2,C6);    
     printf(" R1 = 1433.*R1\n");    mulR_mR(A,1433.,R1);     
     printf(" R2 = 1433.*R2\n");    mulR_mR(A,1433.,R2);     
     printf(" R3 =   -1.*R3\n");    mulR_mR(A,-1.,R3);            
     printf(" R1 =  14.*R3 + R1\n");addR_mR(A,14.,R3,R1);     
     printf(" R2 = 752.*R3 + R2\n");addR_mR(A,752.,R3,R2);    
     p_mR(A,S11,P2,C6);
     getchar();

/* 6----------------------------------- 
   -51588.000   +30093.000       +0.000   -15777.000
       +0.000  +236445.000       +0.000 -2673297.000
       +0.000       +0.000    +1433.000    -5733.000
   ------------------------------------ */
     clrscrn();
     printf(" (%d) \n\n",i++);
     p_mR(A,S11,P2,C6);                                   
     printf(" R2 =  1./33.*R2 \n");mulR_mR(A,1./33.,R2);                                      
     p_mR(A,S11,P2,C6);
     getchar();

/* 7----------------------------------- 
   -51588.000   +30093.000       +0.000   -15777.000
       +0.000    +7165.000       +0.000   -81009.000
       +0.000       +0.000    +1433.000    -5733.000
   ------------------------------------ */
     clrscrn();
     printf(" (%d) \n\n",i++);
     p_mR(A,S11,P2,C6);                               
     printf(" R1 = -5.*R1 (30093/7165 = 21/5)\n");mulR_mR(A,-5.,R1);                                             
     printf(" R1 = 21.*R2 + R1  \n");             addR_mR(A,21.,R2,R1);                                        
     p_mR(A,S11,P2,C6);
     getchar();

/* 8----------------------------------- 
  +257940.000       +0.000       +0.000 -1622304.000
       +0.000    +7165.000       +0.000   -81009.000
       +0.000       +0.000    +1433.000    -5733.000
   ------------------------------------ */
     clrscrn();
     printf(" (%d) \n\n",i++);
     p_mR(A,S11,P2,C6);                                   
     printf(" R1 =  1./36.*R1 \n");mulR_mR(A,1./36.,R1);                                      
     p_mR(A,S11,P2,C6);
     getchar();

  f_mR(A);
  getchar();

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



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


     -36.00      +21.00      -14.00      +45.00 
     -38.00      +13.00      +27.00      -16.00 
     +41.00       -6.00      -44.00      -14.00 

 R2 = -36*R2   
 R3 = -36*R3 

 R2 =  38*R1 + R2 
 R3 = -41*R1 + R3 

     -36.00      +21.00      -14.00      +45.00 
      +0.00     +330.00    -1504.00    +2286.00 
      +0.00     -645.00    +2158.00    -1341.00 
      

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


     -36.00      +21.00      -14.00      +45.00 
      +0.00     +330.00    -1504.00    +2286.00 
      +0.00     -645.00    +2158.00    -1341.00 

 R2 =  1./2.*R2 

     -36.00      +21.00      -14.00      +45.00 
      +0.00     +165.00     -752.00    +1143.00 
      +0.00     -645.00    +2158.00    -1341.00 


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


     -36.00      +21.00      -14.00      +45.00 
      +0.00     +165.00     -752.00    +1143.00 
      +0.00     -645.00    +2158.00    -1341.00 

 R3 = 11.*R3  (165/645 = 11/43)
 R3 = 43.*R2 + R3  

     -36.00      +21.00      -14.00      +45.00 
      +0.00     +165.00     -752.00    +1143.00 
      +0.00       +0.00    -8598.00   +34398.00 


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


     -36.00      +21.00      -14.00      +45.00 
      +0.00     +165.00     -752.00    +1143.00 
      +0.00       +0.00    -8598.00   +34398.00 

 R3 =  1./6.*R3 

     -36.00      +21.00      -14.00      +45.00 
      +0.00     +165.00     -752.00    +1143.00 
      +0.00       +0.00    -1433.00    +5733.00 


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


     -36.00      +21.00      -14.00      +45.00 
      +0.00     +165.00     -752.00    +1143.00 
      +0.00       +0.00    -1433.00    +5733.00 

 R1 = 1433.*R1
 R2 = 1433.*R2
 R3 =   -1.*R3

 R1 =  14.*R3 + R1
 R2 = 752.*R3 + R2

  -51588.00   +30093.00       +0.00   -15777.00 
      +0.00  +236445.00       +0.00 -2673297.00 
      -0.00       -0.00    +1433.00    -5733.00 



 ------------------------------------ 
 (6) 


  -51588.00   +30093.00       +0.00   -15777.00 
      +0.00  +236445.00       +0.00 -2673297.00 
      -0.00       -0.00    +1433.00    -5733.00 

 R2 =  1./33.*R2 

  -51588.00   +30093.00       +0.00   -15777.00 
      +0.00    +7165.00       +0.00   -81009.00 
      -0.00       -0.00    +1433.00    -5733.00 



 ------------------------------------ 
 (7) 


  -51588.00   +30093.00       +0.00   -15777.00 
      +0.00    +7165.00       +0.00   -81009.00 
      -0.00       -0.00    +1433.00    -5733.00 

 R1 = -5.*R1 (30093/7165 = 21/5)
 R1 = 21.*R2 + R1  

 +257940.00       +0.00       +0.00 -1622304.00 
      +0.00    +7165.00       +0.00   -81009.00 
      -0.00       -0.00    +1433.00    -5733.00 


 ------------------------------------ 
 (8) 


 +257940.00       +0.00       +0.00 -1622304.00 
      +0.00    +7165.00       +0.00   -81009.00 
      -0.00       -0.00    +1433.00    -5733.00 

 R1 =  1./36.*R1 

   +7165.00       +0.00       +0.00   -45064.00 
      +0.00    +7165.00       +0.00   -81009.00 
      -0.00       -0.00    +1433.00    -5733.00