Mathc complexes/a65

Un livre de Wikilivres.


Application


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


c00b.c
/* ------------------------------------ */
/*  Save as :   c00b.c                  */
/* ------------------------------------ */
#include "w_a.h"
/* ------------------------------------ */
#define FACTOR_E        +1.E-2   
/* ------------------------------------ */
/* ------------------------------------ */
void fun(int r,int c)
{
double **A =              r_mZ(i_mZ(r,c),99);	
double **A_T = ctranspose_mZ(A,i_mZ(c,r));
double **V =                   i_mZ(r,c);
double **V_T =                 i_mZ(c,r);
double **U =                   i_mZ(r,c);
double **U_T =                 i_mZ(c,r); //             :c,r 
double **U_TA =                i_mZ(c,c); // c,r r,c     :c,c
double **U_TA2 =               i_mZ(c,r); // c,r         :c,r 
double **S =                   i_mZ(c,c); // c,r r,c     :c,c   U_TA2V

double **A2V =                 i_mZ(r,c); 
double **A2  =                 i_mZ(r,r); //  A = U * S * V_T 

  clrscrn();
  printf(" A :");
  p_mZ(A, S10,P2, S8,P2, C3);
      
  X_U_mZ(A_T,U,FACTOR_E);
  printf(" U :");
  p_mZ(U, S10,P4, S8,P4, C3);

  X_V_mZ(A_T,V,FACTOR_E);
  printf(" V :");
  p_mZ(V, S10,P4, S8,P4, C3);
  
   ctranspose_mZ(U,U_T);
   ctranspose_mZ(V,V_T);  
   
/* S = U_T * A * V */
   mul_mZ(   U_T,  A, U_TA);           // U_TA  : c,c
   c_mZ(    U_TA,    U_TA2);           // U_TA2 : c,r 
   mul_mZ( U_TA2,  V,    S);           //     V : r,c
   
   printf(" S = U_T * A * V :");
   p_mZ(S, S10,P4, S8,P4, C3);
   stop();
   
   clrscrn();
/* A = U * S * V_T    */ 
   mul_mZ(  U,  S, A2V);                // U,U_T = 1;
   mul_mZ(A2V, V_T, A2);                // V,V_T = 1;
   
   printf(" A2 = U * S * V_T  ");
   p_mZ(A2, S5,P0, S4,P0, C3);  
   printf(" A :");
   p_mZ(A, S5,P0, S4,P0, C3);
   
   f_mZ(A);
   f_mZ(A_T);
   f_mZ(V);
   f_mZ(V_T);
   f_mZ(U);
   f_mZ(U_T);
   f_mZ(U_TA);
   f_mZ(U_TA2);
   f_mZ(S);
   f_mZ(A2V);
   f_mZ(A2);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

do
{
    fun(R3,C2);
    
} while(stop_w());

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


Exemple de sortie écran :
 -----------------------------------------
 A :
    -27.00  +51.00i     -67.00  +11.00i 
    -78.00  +65.00i     -67.00  +98.00i 
    -38.00  +81.00i     +38.00  -16.00i 

 U :
   +0.1849 +0.3681i    +0.0787 -0.4985i 
   +0.5620 +0.6517i    -0.1707 +0.0176i 
   +0.2996 +0.0000i    +0.8461 +0.0000i 

 V :
   +0.7066 -0.1661i    -0.6696 +0.1574i 
   +0.6878 +0.0000i    +0.7259 +0.0000i 
   +0.0000 +0.0000i    +0.0000 +0.0000i 

 S = U_T * A * V :
  +42.5368+175.3933i    -0.0000 -0.0000i 
   -0.0000 -0.0000i   +47.6058-84.9029i 

 Press return to continue. 


 -----------------------------------------
 A2 = U * S * V_T : 
  -27 +51i   -67 +11i    +0  +0i 
  -78 +65i   -67 +98i    +0  +0i 
  -38 +81i   +38 -16i    +0  +0i 

 A :
  -27 +51i   -67 +11i 
  -78 +65i   -67 +98i 
  -38 +81i   +38 -16i 


 Press   return to continue
 Press X return to stop