Aller au contenu

Mathc matrices/a87

Un livre de Wikilivres.


Fonctions matricielles ex : cos(A)

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

c00b.c
/* ------------------------------------ */
/*  Save as:  c00b.c                    */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define   RCA        RC5
/* ------------------------------------ */
/* ------------------------------------ */
void fun(void)
{
double **A            = rEsymmetric_mR( i_mR(RCA,RCA),455.,1E-3);
double **sinhA        =                 i_mR(RCA,RCA);
double **sinhA_EValue =                 i_mR(RCA,RCA);

double **EVector      =                 i_mR(RCA,RCA);
double **EVectorT     =                 i_mR(RCA,RCA);

double **EValue       =                 i_mR(RCA,RCA);
double **sinh_EValue  =                 i_mR(RCA,RCA);

double **T1           =                 i_mR(RCA,RCA);
  
  clrscrn();
  printf(" A:");
  p_mR(A,S10,P4,C6); 

/* ================================================================== */
  eigs_V_mR(A,EVector); 
  transpose_mR(EVector,EVectorT);
      
/* EValue = EVectorT A EVector */
  mul_mR(EVectorT,A,T1);
  mul_mR(T1,EVector,EValue);     
  
  printf(" sinh(A):");
  f_eigs_mR(sinh,EValue,sinh_EValue);

/*  sinhA = EVector sinh_EValue EVectorT */    
     mul_mR(EVector,sinh_EValue,T1);
     mul_mR(T1,EVectorT,sinhA);
       p_mR(sinhA,S10,P4,C6); 

/* ================================================================== */ 
  eigs_V_mR(sinhA,EVector); 
  transpose_mR(EVector,EVectorT);  
  
/* sinhA_EValue =EVectorT sinhA EVector */
  mul_mR(EVectorT,sinhA,T1);
  mul_mR(T1,EVector,sinhA_EValue);     
  
  printf(" asinh(sinh(A)) = A:");
  f_eigs_mR(asinh,sinhA_EValue,EValue);

/*  A = EVector EValue EVectorT */     
     mul_mR(EVector,EValue,T1);
     mul_mR(T1,EVectorT,A); 
       p_mR(A,S10,P4,C6);

  f_mR(A);
  f_mR(sinhA);
  f_mR(sinhA_EValue);

  f_mR(EVector);
  f_mR(EVectorT);
  
  f_mR(EValue);  
  f_mR(sinh_EValue);    
      
  f_mR(T1);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

do
{
  fun();

} while(stop_w());

  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Exemple de sortie écran :
 A :
   +0.2724    +0.0131    -0.1520    +0.0900    -0.0196 
   +0.0131    +0.1715    +0.1096    -0.0507    +0.0558 
   -0.1520    +0.1096    +0.1897    -0.1034    +0.1239 
   +0.0900    -0.0507    -0.1034    +0.0630    -0.1004 
   -0.0196    +0.0558    +0.1239    -0.1004    +0.3966 

 sinh(A) :
   +0.2802    +0.0105    -0.1593    +0.0943    -0.0254 
   +0.0105    +0.1745    +0.1141    -0.0534    +0.0612 
   -0.1593    +0.1141    +0.1988    -0.1089    +0.1339 
   +0.0943    -0.0534    -0.1089    +0.0664    -0.1069 
   -0.0254    +0.0612    +0.1339    -0.1069    +0.4127 

 asinh(sinh(A)) = A :
   +0.2724    +0.0131    -0.1520    +0.0900    -0.0196 
   +0.0131    +0.1715    +0.1096    -0.0507    +0.0558 
   -0.1520    +0.1096    +0.1897    -0.1034    +0.1239 
   +0.0900    -0.0507    -0.1034    +0.0630    -0.1004 
   -0.0196    +0.0558    +0.1239    -0.1004    +0.3966 


 Press   return to continue
 Press X return to stop