Mathc complexes/Fichiers c :mswap c

Application

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

M_swapc.c
/* ------------------------------------ */
/*  Save as :   M_swapc.c                */
/* ------------------------------------ */
#include "w_a.h"
/* ------------------------------------ */
void fun(int r,int c)
{               
double **A = r_mZ(i_mZ(r,c),99); 

int c1 = C1;
int c2 = C3;

 clrscrn();
 
 printf(" A :");
 p_mZ(A, S5,P0, S4,P0, C6);

 printf(" M_swapC_mZ(A,C%d,C%d)\n\n",c1,c2);

 printf(" A :");
 p_mZ(M_swapC_mZ(A,c1,c2), S5,P0, S4,P0, C6);

 f_mZ(A);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));
  
   do 
        fun(rp_I(R3)+R2,rp_I(C3)+C3);
        
    while(stop_w());
        
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */


La fonction M_swapC_mZ(); échange deux colonnes.


Exemple de sortie écran :

 A :
  -53  -1i   -45 +39i   -85  +7i   -23 +96i 
  +24 -71i   +52 +68i    +2 -48i   -27 +58i 
  -80 -64i   +48 +63i    -1 -99i    +5 -63i 
  +68 +38i   +64 -16i   -71 -13i   -41 +75i 

 M_swapC_mZ(A,C1,C3)

 A :
  -85  +7i   -45 +39i   -53  -1i   -23 +96i 
   +2 -48i   +52 +68i   +24 -71i   -27 +58i 
   -1 -99i   +48 +63i   -80 -64i    +5 -63i 
  -71 -13i   +64 -16i   +68 +38i   -41 +75i 


 Press return to continue
 Press X      to stop