Application

Installer et compiler ce fichier dans votre répertoire de travail.

c00a.c
/* ------------------------------------ */
/*  Save as :   c00a.c                  */
/* ------------------------------------ */
#include "w_a.h"
/* ------------------------------------ */
#define FACTOR_E    +1.E-2         
/* ------------------------------------ */
void fun(int r)
{
double **A        =  rdefinite_positive_mZ( i_mZ(r,r), 99);
double **SqrtA    =                         i_mZ(r,r);
double **invSqrtA =                         i_mZ(r,r);

double **V        =                         i_mZ(r,r);
double **invV     =                         i_mZ(r,r);

double **EValue   =                         i_mZ(r,r);
double **f_EValue =                         i_mZ(r,r);

double **T1       =                         i_mZ(r,r);
  
  clrscrn();
  printf(" A :");
  p_mZ(A, S10,P3, S8,P3, C4); 
  
  eigs_V_mZ(A,V,FACTOR_E);
  invgj_mZ(V,invV);
      
/* EValue : invV * A * V */
  mul_mZ(invV,A,T1);
  mul_mZ(T1,V,EValue);     
                 
  printf(" sqrt(A) = V * sqrt(EValue) * invV\n");
  f_eigs_mZ(sqrt,EValue,f_EValue);
     mul_mZ(V,f_EValue,T1);
     mul_mZ(T1,invV,SqrtA); 
       p_mZ(SqrtA, S10,P3, S8,P3, C4);   
  
  printf(" inv(sqrt(A)) ");  
  invgj_mZ(SqrtA,invSqrtA);
  p_mZ(invSqrtA, S10,P3, S8,P3, C4);   
   
  f_mZ(A);
  f_mZ(SqrtA);
  f_mZ(invSqrtA);
      
  f_mZ(V);
  f_mZ(invV);
  
  f_mZ(EValue);
  f_mZ(f_EValue);    
     
  f_mZ(T1);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

do
{
  fun(rp_I(R3)+R1);

} while(stop_w());

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


Une matrice positive est définie positive si et seulement si sa racine carrée positive est inversible.


Exemple de sortie écran :

 A :
   +82.429  +0.000i    +25.639  +1.379i    +12.378  -0.506i     -7.232  +5.578i 
   +25.639  -1.379i    +52.993  -0.000i     -5.212  -0.214i    +16.290  +3.122i 
   +12.378  +0.506i     -5.212  +0.214i    +43.381  +0.000i     -0.202 -10.765i 
    -7.232  -5.578i    +16.290  -3.122i     -0.202 +10.765i    +29.196  +0.000i 

 sqrt(A) = V * sqrt(EValue) * invV

    +8.828  -0.000i     +1.723  +0.032i     +0.902  +0.026i     -0.715  +0.444i 
    +1.723  -0.032i     +6.894  -0.000i     -0.508  -0.128i     +1.484  +0.155i 
    +0.902  -0.026i     -0.508  +0.128i     +6.427  +0.000i     +0.105  -0.986i 
    -0.715  -0.444i     +1.484  -0.155i     +0.105  +0.986i     +5.028  +0.000i 

 inv(sqrt(A)) 
    +0.127  +0.000i     -0.040  +0.004i     -0.024  -0.006i     +0.032  -0.016i 
    -0.040  -0.004i     +0.169  +0.000i     +0.020  +0.013i     -0.059  +0.002i 
    -0.024  +0.006i     +0.020  -0.013i     +0.167  -0.000i     -0.013  +0.039i 
    +0.032  +0.016i     -0.059  -0.002i     -0.013  -0.039i     +0.230  -0.000i 


 Press   return to continue
 Press X return to stop