Mathc complexes/Fichiers c : add c

Application

Installer et compiler ce fichier dans votre répertoire de travail.

addc.c
/* ------------------------------------ */
/*  Save as :   addc.c                  */
/* ------------------------------------ */
#include "w_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
int take_c(int c)
{
int r = c;

     if(r!=C1) r= (c-C1)*C2+C1;

return(r);
}
/* ------------------------------------ */
/* ------------------------------------ */
int main(void)
{                         
double a[R3*(C3*C2)] ={  1,0,   2,3,   3,6,
                         2,0,   2,2,   2,1,
                         3,0,   3,3,   3,1};
                     
double **A = ca_A_mZ(a,i_mZ(R3,C3));

nb_Z z = i_Z(0,0);  

int c1;
int c2;  

 clrscrn();
 
 c1 = take_c(C1);
 c2 = take_c(C2);
 
 z = sym_Z(i_Z(2,3));
  
 printf(" A : \n");
 p_mZ(A, S5,P0, S4,P0, C6);
     
 printf(" Multiply the column C%d by ",c1);
 p_Z(z, S1,P0, S1,P0); 
 printf("\n");
 printf(" then add the column %d and the column C%d \n",c1,((c2-C1)/C2)+C1);
 printf(" put the result into the column C%d   \n\n",      ((c2-C1)/C2)+C1);
 printf(" A : \n");
 p_mZ(addC_mZ(A,z,c1,c2), S5,P0, S4,P0, C6);
 
 stop();


 clrscrn();
 
 c1 = take_c(C1);
 c2 = take_c(C3);
 
 z = sym_Z(i_Z(3,6));
  
 printf(" A : \n");
 p_mZ(A, S5,P0, S4,P0, C6);
     
 printf(" Multiply the column C%d by ",c1);
 p_Z(z,S1,P0,S1,P0); 
 printf("\n");
 printf(" then add the column C%d and the column C%d \n",c1,((c2-C1)/C2)+C1);
 printf(" put the result into the column C%d   \n\n",       ((c2-C1)/C2)+C1);
 printf(" A : \n");
 p_mZ(addC_mZ(A,z,c1,c2), S5,P0, S4,P0, C6);
 
 stop();
 f_mZ(A);

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


La fonction addC_mZ(); multiplie la ligne c1 par un complexe z sans la modifier et l'ajoute à la ligne c2 et remplace la ligne c2 par le résultat de cette opération .

Cette opération permet de poser des zéros à droite du pivot. Voir le résultat dans la dernière matrice.


Exemple de sortie écran :

 A : 

   +1  +0i    +2  +3i    +3  +6i 
   +2  +0i    +2  +2i    +2  +1i 
   +3  +0i    +3  +3i    +3  +1i 



 Multiply the column C1 by -2-3i 
 then add the column 1 and the column C2 
 put the result into the column C2   

 A : 

   +1  +0i    +0  +0i    +3  +6i 
   +2  +0i    -2  -4i    +2  +1i 
   +3  +0i    -3  -6i    +3  +1i 

 Press return to continue. 


 A : 

   +1  +0i    +0  +0i    +3  +6i 
   +2  +0i    -2  -4i    +2  +1i 
   +3  +0i    -3  -6i    +3  +1i 

 Multiply the column C1 by -3-6i 
 then add the column C1 and the column C3 
 put the result into the column C3   

 A : 

   +1  +0i    +0  +0i    +0  +0i 
   +2  +0i    -2  -4i    -4 -11i 
   +3  +0i    -3  -6i    -6 -17i 

 Press return to continue.