Aller au contenu

Mathc complexes/a272

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         
#define RCA          RC4  
/* ------------------------------------ */
void fun(void)
{                          
double **A    =          r_mZ(       i_mZ(RCA,RCA),99);
double **A_T  = ctranspose_mZ(A,     i_mZ(RCA,RCA)   );
double **A_TA =        mul_mZ(A_T,A, i_mZ(RCA,RCA)   );

double **P                  = i_mZ(RCA,RCA);
double **invP               = i_mZ(RCA,RCA);

double **U                  = i_mZ(RCA,RCA);

double **EigsVector         = i_mZ(RCA,RCA);
double **EigsVector_T       = i_mZ(RCA,RCA);
double **EigsValue          = i_mZ(RCA,RCA);
double **SqrtEigsValue      = i_mZ(RCA,RCA);

double **T                  = i_mZ(RCA,RCA);

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

  printf(" A_TA :");
  p_mZ(A_TA, S7,P0, S7,P0, C6); 
  
/* EigsVector and EigsVector_T*/    
  eigs_V_mZ(A_TA,EigsVector,FACTOR_E);
  ctranspose_mZ(EigsVector,EigsVector_T);
    
/* EigsValue = EigsVector_T * A_TA * EigsVector */   
  mul_mZ(EigsVector_T,A_TA,T);
  mul_mZ(T,EigsVector,EigsValue); 
   
  f_eigs_mZ(sqrt,EigsValue,SqrtEigsValue); 

/* P = EigsVector * sqrt(EigsValue) * EigsVector_T*/     
  mul_mZ(EigsVector,SqrtEigsValue,T);
  mul_mZ(T,EigsVector_T,P);          
  printf(" P = (A_TA)**(1/2)\n"
         "   = EigsVector * sqrt(EigsValue) * EigsVector_T");
  p_mZ(P, S9,P3, S8,P3, C6); 
  stop(); 

  clrscrn();  
  mul_mZ(A,inv_mZ(P,invP),U);
  printf(" U = A*invP");
  p_mZ(U, S9,P3, S8,P3, C6);
  
  f_mZ(A);
  f_mZ(A_T);
  f_mZ(A_TA);
  
  f_mZ(P);
  f_mZ(invP); 
   
  f_mZ(U);
    
  f_mZ(EigsVector);
  f_mZ(EigsVector_T);
  
  f_mZ(T); 
  
  f_mZ(SqrtEigsValue);
  f_mZ(EigsValue);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

do
{
    fun();
    
} while(stop_w());

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


Exemple de sortie écran :

 ------------------------------------
 A :
    -52    -62i     -92    -15i      +3    +39i     -15    -20i 
    -69    +86i     -41    -29i     -29    -58i     +32    -24i 
    -82    -18i     -29     +5i     +52    -82i     +29     +1i 
    +81    +88i     -23    +32i     +76    +50i     +41    -89i 

 A_TA :
 +40058     +0i   +9290  +4287i   +2207  +9676i   -9159 -11363i 
  +9290  -4287i  +13630     +0i     -56  -3470i   -3563  +4088i 
  +2207  -9676i     -56  +3470i  +23439     +0i    -269  -3307i 
  -9159 +11363i   -3563  -4088i    -269  +3307i  +12669     +0i 

 P = (A_TA)**(1/2)
   = EigsVector * sqrt(EigsValue) * EigsVector_T
 +184.527  -0.000i   +38.321  +9.937i    +4.547 +34.418i   -33.519 -45.952i 
  +38.321  -9.937i  +103.774  +0.000i    +0.004 -19.424i    -7.656 +29.290i 
   +4.547 -34.418i    +0.004 +19.424i  +146.569  +0.000i    +8.589 -17.327i 
  -33.519 +45.952i    -7.656 -29.290i    +8.589 +17.327i   +90.241  +0.000i 

 Press return to continue. 

 ------------------------------------
 U = A*invP
   -0.334  -0.413i    -0.649  -0.025i    -0.097  +0.317i    -0.195  -0.385i 
   -0.276  +0.608i    -0.290  -0.543i    +0.025  -0.360i    -0.191  -0.094i 
   -0.156  -0.218i    -0.349  +0.250i    +0.256  -0.630i    +0.523  +0.094i 
   +0.289  +0.343i    -0.050  +0.110i    +0.483  +0.254i    +0.324  -0.618i 


 Press   return to continue
 Press X return to stop