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.


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

double **EigsVector    =               i_mR(RCA,RCA);
double **T_EigsVector  =               i_mR(RCA,RCA);

double **EigsValue     =               i_mR(RCA,RCA);
double **sin_EigsValue =               i_mR(RCA,RCA);

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

/* ================================================================== */ 
  eigs_V_mR(A,EigsVector); 
  transpose_mR(EigsVector,T_EigsVector);
      
/* EigsValue : T_EigsVector * A * EigsVector */
  mul_mR(T_EigsVector,A,T1);
  mul_mR(T1,EigsVector,EigsValue);     

  printf(" sin(A) :");
  f_eigs_mR(sin,EigsValue,sin_EigsValue); 
     mul_mR(EigsVector,sin_EigsValue,T1);
     mul_mR(T1,T_EigsVector,sin_A); 
      p_mR(sin_A,S10,P4,C6); 

/* ================================================================== */ 
  eigs_V_mR(sin_A,EigsVector); 
  transpose_mR(EigsVector,T_EigsVector);  
  
/* EigsValue : T_EigsVector * sin_A * EigsVector */
  mul_mR(T_EigsVector,sin_A,T1);
  mul_mR(T1,EigsVector,EigsValue);     
  
  printf(" asin(sin(A)) = A :");
  f_eigs_mR(asin,EigsValue,sin_EigsValue);
     mul_mR(EigsVector,sin_EigsValue,T1);
     mul_mR(T1,T_EigsVector,A); 
       p_mR(A,S10,P4,C6);

  f_mR(A);
  f_mR(sin_A);

  f_mR(EigsVector);
  f_mR(T_EigsVector);
  
  f_mR(EigsValue);  
  f_mR(sin_EigsValue);    
      
  f_mR(T1);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

do
{
  fun();

} while(stop_w());

  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
                         asin(sin(A)) = A :


Exemple de sortie écran :
 ------------------------------------  
 A :
   +0.3672    -0.1919    -0.1067    -0.0639    -0.0243 
   -0.1919    +0.3287    +0.1053    +0.2621    +0.0517 
   -0.1067    +0.1053    +0.2286    +0.2096    +0.0909 
   -0.0639    +0.2621    +0.2096    +0.4114    +0.1167 
   -0.0243    +0.0517    +0.0909    +0.1167    +0.4063 

 sin(A) :
   +0.3478    -0.1702    -0.0922    -0.0427    -0.0155 
   -0.1702    +0.2987    +0.0845    +0.2292    +0.0374 
   -0.0922    +0.0845    +0.2126    +0.1849    +0.0783 
   -0.0427    +0.2292    +0.1849    +0.3720    +0.0976 
   -0.0155    +0.0374    +0.0783    +0.0976    +0.3891 

 asin(sin(A)) = A :
   +0.3672    -0.1919    -0.1067    -0.0639    -0.0243 
   -0.1919    +0.3287    +0.1053    +0.2621    +0.0517 
   -0.1067    +0.1053    +0.2286    +0.2096    +0.0909 
   -0.0639    +0.2621    +0.2096    +0.4114    +0.1167 
   -0.0243    +0.0517    +0.0909    +0.1167    +0.4063 


 Press   return to continue
 Press X return to stop