Aller au contenu

Mathc matrices/a85

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 **sinA        =                 i_mR(RCA,RCA);
double **sinA_EValue =                 i_mR(RCA,RCA);

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

double **EValue      =                 i_mR(RCA,RCA);
double **sin_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(" sin(A):");
  f_eigs_mR(sin,EValue,sin_EValue);

/*  sinA = EVector sin_EValue EVectorT */   
     mul_mR(EVector,sin_EValue,T1);
     mul_mR(T1,EVectorT,sinA); 
      p_mR(sinA,S10,P4,C6); 

/* ================================================================== */ 
  eigs_V_mR(sinA,EVector); 
  transpose_mR(EVector,EVectorT);  
  
/* sinA_EValue = EVectorT sinA EVector */
  mul_mR(EVectorT,sinA,T1);
  mul_mR(T1,EVector,sinA_EValue);     
  
  printf(" asin(sin(A)) = A:");
  f_eigs_mR(asin,sinA_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(sinA);

  f_mR(EVector);
  f_mR(EVectorT);
  
  f_mR(EValue);  
  f_mR(sin_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.2734    +0.1582    +0.0909    +0.1203    -0.2019 
   +0.1582    +0.4718    +0.1910    +0.2804    -0.3273 
   +0.0909    +0.1910    +0.2483    +0.1057    -0.1766 
   +0.1203    +0.2804    +0.1057    +0.3792    -0.2941 
   -0.2019    -0.3273    -0.1766    -0.2941    +0.3984 

 sin(A) :
   +0.2478    +0.1128    +0.0671    +0.0828    -0.1579 
   +0.1128    +0.3864    +0.1466    +0.2100    -0.2458 
   +0.0671    +0.1466    +0.2245    +0.0695    -0.1341 
   +0.0828    +0.2100    +0.0695    +0.3201    -0.2264 
   -0.1579    -0.2458    -0.1341    -0.2264    +0.3200 

 asin(sin(A)) = A :
   +0.2734    +0.1582    +0.0909    +0.1203    -0.2019 
   +0.1582    +0.4718    +0.1910    +0.2804    -0.3273 
   +0.0909    +0.1910    +0.2483    +0.1057    -0.1766 
   +0.1203    +0.2804    +0.1057    +0.3792    -0.2941 
   -0.2019    -0.3273    -0.1766    -0.2941    +0.3984 


 Press   return to continue
 Press X return to stop