Aller au contenu

Mathc complexes/c092a

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"
/* ------------------------------------ */
void fun(int r)
{
double **A   =       i_mZ(r,r);
double **Inv =       i_mZ(r,r);
double **B   = r_mZ( i_mZ(r,C1),999.);
double **X   =       i_mZ(r,C1);

 do
  {
   r_mZ(A,999.);
   printf(".");
  }while(!det_Z(A).r);

  clrscrn();
  printf(" We want to find X such as,   \n\n");
  printf("         AX = B               \n\n");
  printf(" If A is a square matrix and, \n\n");
  printf(" If A has an inverse matrix,  \n\n");
  printf(" you can find X by this method\n\n");
  printf("         X = inv(A) B       \n\n\n");
  printf(" To verify the result you can \n\n");
  printf(" multiply the matrix A by X.  \n\n");
  printf(" You must refind B.  \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(" invgj_mZ(A,Inv) :");
  pE_mZ(invgj_mZ(A,Inv), S1,P4, S1,P4, C3);
  printf(" X = invgj_mZ(A,Inv) * B :");
  p_mZ(mul_mZ(Inv,B,X), S2,P4, S2, P4, C6);
  stop();

  clrscrn();
  printf(" B :");
  p_mZ(B, S5,P0, S4,P0, C6);
  printf("  AX :");
  p_mZ(mul_mZ(A,X,B), S5,P0, S4,P0, C6);

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

  srand(time(&t));
do
{
  fun(rp_I(R5)+R1);

} while(stop_w());

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


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

         AX = B               

 If A is a square matrix and, 

 If A has an inverse matrix,  

 you can find X by this method

         X = inv(A) B       


 To verify the result you can 

 multiply the matrix A by X.  

 You must refind B.  

 Press return to continue. 


 ------------------------------------ 
 A :
+892+364i -815+830i  +10+864i 
+378-611i  -43+562i -747-975i 
+622+798i -397-977i +566-111i 

 B :
 +48+674i 
+172+672i 
-855 +78i 

 Press return to continue. 


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

 invgj_mZ(A,Inv) :
+3.529e-04-4.554e-04i +6.301e-04-5.369e-04i +1.045e-03+5.105e-05i 
+6.497e-05-4.498e-04i +6.559e-04-2.787e-04i +5.069e-04+7.702e-04i 
-1.625e-04-2.323e-04i -6.101e-04+5.187e-04i -2.516e-04-1.636e-04i 

 X = invgj_mZ(A,Inv) * B :
-0.104+0.585i 
+0.113-0.204i 
-0.077-0.321i 

 Press return to continue. 

 ------------------------------------ 
 B :
 +48+674i 
+172+672i 
-855 +78i 

  AX :
 +48+674i 
+172+672i 
-855 +78i 


 Press return to continue
 Press X      to stop