Aller au contenu

Mathc complexes/01h

Un livre de Wikilivres.
SommaireUtilise la commande "Retour en Arrière" de ton navigateur.

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

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

double **AplsAT  =       add_mZ(A,AT,           i_mZ(r,r));
double **AmnsAT  =       sub_mZ(A,AT,           i_mZ(r,r));

double **AplsAT2 =      smul_mZ(1./2., AplsAT, i_mZ(r,r));
double **AmnsAT2 =      smul_mZ(1./2., AmnsAT, i_mZ(r,r));

double **A2      = add_mZ(AplsAT2,AmnsAT2,     i_mZ(r,r));

  clrscrn();  
  printf(" A ");  
  p_mZ(A, S6,P0, S4,P0, C5); 
  
  printf("      Hermitian matrix : A + AT ");  
  p_mZ(AplsAT, S6,P0, S4,P0, C5); 
  
  printf(" Skew-Hermitian matrix : A - AT ");  
  p_mZ(AmnsAT, S6,P0, S4,P0, C5); 
  stop();
  
  clrscrn();  
  printf(" A ");  
  p_mZ(A, S6,P0, S4,P0, C5); 
  
  printf(" A = (A + AT)/2 + (A - AT)/2");  
  p_mZ(A2, S6,P0, S4,P0, C5); 
      
  f_mZ(A);
  f_mZ(A2);
  f_mZ(AT);
  f_mZ(AplsAT);
  f_mZ(AmnsAT);
  f_mZ(AplsAT2);
  f_mZ(AmnsAT2);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

do
{
  fun(rp_I(R4)+R1);

} while(stop_w());

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


Soit une matrice carré A : A = (A+AT)/2 + (A-AT)/2


Exemple de sortie écran :

 A 
    +1  +8i     +5  +9i     +4  +4i     +1  -8i     +2  +4i 
    +3  -6i     -6  -9i     -9  +4i     +5  -5i     +1  -6i 
    -2  +4i     -9  +3i     +6  +5i     -8  +8i     +6  +9i 
    +9  +2i     +3  -1i     -5  +3i     +3  +3i     +5  +6i 
    -7  -5i     -9  -5i     +3  +7i     -2  -3i     -2  -6i 

      Hermitian matrix : A + AT 
    +2  +0i     +8 +15i     +2  +0i    +10 -10i     -5  +9i 
    +8 -15i    -12  +0i    -18  +1i     +8  -4i     -8  -1i 
    +2  +0i    -18  -1i    +12  +0i    -13  +5i     +9  +2i 
   +10 +10i     +8  +4i    -13  -5i     +6  +0i     +3  +9i 
    -5  -9i     -8  +1i     +9  -2i     +3  -9i     -4  +0i 

 Skew-Hermitian matrix : A - AT 
    +0 +16i     +2  +3i     +6  +8i     -8  -6i     +9  -1i 
    -2  +3i     +0 -18i     +0  +7i     +2  -6i    +10 -11i 
    -6  +8i     +0  +7i     +0 +10i     -3 +11i     +3 +16i 
    +8  -6i     -2  -6i     +3 +11i     +0  +6i     +7  +3i 
    -9  -1i    -10 -11i     -3 +16i     -7  +3i     +0 -12i 

 Press return to continue. 


 A 
    +1  +8i     +5  +9i     +4  +4i     +1  -8i     +2  +4i 
    +3  -6i     -6  -9i     -9  +4i     +5  -5i     +1  -6i 
    -2  +4i     -9  +3i     +6  +5i     -8  +8i     +6  +9i 
    +9  +2i     +3  -1i     -5  +3i     +3  +3i     +5  +6i 
    -7  -5i     -9  -5i     +3  +7i     -2  -3i     -2  -6i 

 A = (A + AT)/2 + (A - AT)/2
    +1  +8i     +5  +9i     +4  +4i     +1  -8i     +2  +4i 
    +3  -6i     -6  -9i     -9  +4i     +5  -5i     +1  -6i 
    -2  +4i     -9  +3i     +6  +5i     -8  +8i     +6  +9i 
    +9  +2i     +3  -1i     -5  +3i     +3  +3i     +5  +6i 
    -7  -5i     -9  -5i     +3  +7i     -2  -3i     -2  -6i 


 Press   return to continue
 Press X return to stop