Aller au contenu

Mathc matrices/c30c

Un livre de Wikilivres.


Application


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


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

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

int i  = 1;

/* 1----------------------------------- 
       +1.000       +3.000       +3.000       +1.000
       +2.000       +8.000       +1.000       -6.000
       +1.000       +4.000       -6.000       +9.000
   ------------------------------------ */
     clrscrn();
     printf(" (%d) \n\n",i++);
     p_mR(A,S11,P2,C6);
     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,C6);
     getchar();

/* 2----------------------------------- 
      +1.000       +3.000       +3.000       +1.000
      +0.000       +2.000       -5.000       -8.000
      +0.000       +1.000       -9.000       +8.000
   ------------------------------------ */
     clrscrn();
     printf(" (%d) \n\n",i++);
     p_mR(A,S11,P2,C6);
     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,C6);
     getchar();

/* 3----------------------------------- 
       +1.000       +3.000       +3.000       +1.000
       +0.000       +2.000       -5.000       -8.000
       +0.000       +0.000      -13.000      +24.000
   ------------------------------------ */
     clrscrn();
     printf(" (%d) \n\n",i++);
     p_mR(A,S11,P2,C6);
     printf(" R1 =  13.*R1 \n");    mulR_mR(A, 13.,R1);          
     printf(" R2 =  13.*R2 \n");    mulR_mR(A, 13.,R2);          
     printf(" R3 = -1. *R3 \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,C6);
     getchar();

/* 4----------------------------------- 
      +13.000      +39.000       +0.000      +85.000
       +0.000      +26.000       +0.000     -224.000
       +0.000       +0.000      +13.000      -24.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();
     
/* 5----------------------------------- 
      +13.000      +39.000       +0.000      +85.000
       +0.000      +13.000       +0.000     -112.000
       +0.000       +0.000      +13.000      -24.000
   ------------------------------------ */
     clrscrn();
     printf(" (%d) \n\n",i++);
     p_mR(A,S11,P2,C6);
     printf(" R1 =  -3 *R2 + R1 (3*13 = 39)\n");addR_mR(A, -3.,R2,R1);    
     p_mR(A,S11,P2,C6);
     getchar();
     
  f_mR(A);
  getchar();

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



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


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

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

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


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


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

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

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




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


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

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

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

     +13.00      +39.00       +0.00      +85.00 
      +0.00      +26.00       +0.00     -224.00 
      -0.00       -0.00      +13.00      -24.00 



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


     +13.00      +39.00       +0.00      +85.00 
      +0.00      +26.00       +0.00     -224.00 
      -0.00       -0.00      +13.00      -24.00 

 R2 =  1./2.*R2 

     +13.00      +39.00       +0.00      +85.00 
      +0.00      +13.00       +0.00     -112.00 
      -0.00       -0.00      +13.00      -24.00 


 ------------------------------------ 

 (5) 


     +13.00      +39.00       +0.00      +85.00 
      +0.00      +13.00       +0.00     -112.00 
      -0.00       -0.00      +13.00      -24.00 

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

     +13.00       +0.00       +0.00     +421.00 
      +0.00      +13.00       +0.00     -112.00 
      -0.00       -0.00      +13.00      -24.00