Aller au contenu

Mathc complexes/a189

Un livre de Wikilivres.


Application


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


c00a.c
/* ------------------------------------ */
/*  Save as :   c00a.c                  */
/* ------------------------------------ */
#include "w_a.h"
/* ------------------------------------ */
#define   RCA RC3
#define   Cb   C1
/* ------------------------------------ */
int main(void)
{
double a[RCA*(RCA*C2)] =   { 1,2,  3,4,  5,6,
                             5,4,  1,3,  6,8,
                             7,2,  5,1,  1,1};

double tb[RCA*(Cb*C2)] = { 1,4, 
                           2,5, 
                           3,6}; 
                         
double **A  = ca_A_mZ(a,  i_mZ(RCA,RCA));                        
double **b  = ca_A_mZ(tb, i_mZ(RCA,Cb));   
double **X  =             i_mZ(RCA,Cb);
double **Ab =             i_Abr_Ac_bc_mZ(RCA,RCA,Cb);

  c_A_b_Ab_mZ(A,b,Ab);

  clrscrn();
  printf(" We want to find X such as,   \n\n");
  printf("         AX = b               \n\n");
  printf(" We can use the function,       \n");
  printf("   gaussjordan : gj_mZ(Ab);   \n\n");
  printf(" To verify the result you can   \n");
  printf(" multiply the matrix A by X.    \n");
  printf(" You must refind b.         \n\n\n");
  stop();

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

  clrscrn();
  printf(" Ab :");
  p_mZ(Ab, S5,P0, S4,P0, C6);
  printf(" gj_mZ(Ab) :");
  p_mZ(gj_mZ(Ab), S8,P4, S8,P4, C3);
  stop();

  clrscrn();
  printf(" Ab :");
  p_mZ(Ab, S10,P3, S4,P3, C4);
  printf(" X  :");
  p_mZ(c_Ab_b_mZ(Ab,X), S10,P3, S4,P3, C4);
  stop();

  clrscrn();
  printf(" b :");
  p_mZ(b, S4,P0, S4,P0, C7);
  printf("  AX :");
  p_mZ(mul_mZ(A,X,b), S4,P0, S4,P0, C7);

  f_mZ(Ab);
  f_mZ(X);
  f_mZ(b);
  f_mZ(A);

  stop();

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



Exemple de sortie écran :
 ------------------------------------ 
 We want to find X such as,   

         AX = b               

 We can use the function,       
   gaussjordan : gj_mZ(Ab);   

 To verify the result you can   
 multiply the matrix A by X.    
 You must refind b.         


 Press return to continue. 

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

 b :
   +1  +4i 
   +2  +5i 
   +3  +6i 

 Press return to continue. 

 ------------------------------------ 
 Ab :
   +1  +2i    +3  +4i    +5  +6i    +1  +4i 
   +5  +4i    +1  +3i    +6  +8i    +2  +5i 
   +7  +2i    +5  +1i    +1  +1i    +3  +6i 

 gj1_mZ(Ab) :
 +1.0000 +0.0000i  +0.0000 -0.0000i  +0.0000 +0.0000i 
 +0.0000 +0.0000i  +1.0000 +0.0000i  +0.0000 +0.0000i 
 +0.0000 +0.0000i  +0.0000 +0.0000i  +1.0000 +0.0000i 

 +0.3085 +0.3691i 
 +0.3263 +0.4945i 
 +0.2212 -0.2204i 

 Press return to continue. 

 ------------------------------------ 
 gj1_mZ(Ab) :
    +1.000+0.000i     +0.000-0.000i     +0.000+0.000i     +0.309+0.369i 
    +0.000+0.000i     +1.000+0.000i     +0.000+0.000i     +0.326+0.495i 
    +0.000+0.000i     +0.000+0.000i     +1.000+0.000i     +0.221-0.220i 

 X  :
    +0.309+0.369i 
    +0.326+0.495i 
    +0.221-0.220i 

 Press return to continue. 


 ------------------------------------ 
 b :
  +1  +4i 
  +2  +5i 
  +3  +6i 

  AX :
  +1  +4i 
  +2  +5i 
  +3  +6i 

 Press return to continue.