Aller au contenu

Mathc complexes/a273

Un livre de Wikilivres.


Application


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


c00c.c
/* ------------------------------------ */
/*  Save as :   c00c.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);
  
  printf(" A :");
  p_mZ(A, S7,P1, S7,P1, C6); 
  
  printf(" A = U*P");
  p_mZ(mul_mZ(U,P,A), S7,P1, S7,P1, 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    +18i     -29    +95i     -20    +46i     +12    -35i 
    -20    +61i      +6    +56i     -22    +23i      +5     +1i 
    +89    +86i     -93    +75i     -63    +66i     -59    -20i 
    -90    -90i     +37    -15i     -71    -43i     +79    -26i 

 A_TA :
 +38666     +0i    -309 +23329i  +11960 +12406i  -11786 +10383i 
   -309 -23329i  +28906     +0i  +14933  -2133i   +3713  +6109i 
 +11960 -12406i  +14933  +2133i  +18744     +0i   -4031 +10408i 
 -11786 -10383i   +3713  -6109i   -4031 -10408i  +12193     +0i 

 P = (A_TA)**(1/2)
   = EigsVector * sqrt(EigsValue) * EigsVector_T
 +171.418  +0.000i    -7.285 +66.904i   +37.576 +30.017i   -35.235 +34.614i 
   -7.285 -66.904i  +146.748  +0.000i   +51.255  +4.748i   +10.543  +9.009i 
  +37.576 -30.017i   +51.255  -4.748i  +108.443  +0.000i   -22.170 +39.114i 
  -35.235 -34.614i   +10.543  -9.009i   -22.170 -39.114i   +86.831  +0.000i 

 Press return to continue. 


 ------------------------------------
 U = A*invP
   +0.206  -0.000i    -0.250  +0.578i    +0.182  +0.139i    +0.421  -0.576i 
   -0.319  +0.582i    +0.318  +0.561i    -0.152  -0.076i    +0.107  +0.323i 
   +0.440  +0.149i    -0.293  +0.206i    -0.637  +0.182i    -0.465  -0.006i 
   -0.258  -0.485i    +0.242  +0.026i    -0.689  -0.070i    +0.378  -0.129i 

 A :
  +52.0  +18.0i   -29.0  +95.0i   -20.0  +46.0i   +12.0  -35.0i 
  -20.0  +61.0i    +6.0  +56.0i   -22.0  +23.0i    +5.0   +1.0i 
  +89.0  +86.0i   -93.0  +75.0i   -63.0  +66.0i   -59.0  -20.0i 
  -90.0  -90.0i   +37.0  -15.0i   -71.0  -43.0i   +79.0  -26.0i 

 A = U*P
  +52.0  +18.0i   -29.0  +95.0i   -20.0  +46.0i   +12.0  -35.0i 
  -20.0  +61.0i    +6.0  +56.0i   -22.0  +23.0i    +5.0   +1.0i 
  +89.0  +86.0i   -93.0  +75.0i   -63.0  +66.0i   -59.0  -20.0i 
  -90.0  -90.0i   +37.0  -15.0i   -71.0  -43.0i   +79.0  -26.0i 


 Press   return to continue
 Press X return to stop