Aller au contenu

Mathc matrices/a71

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      RC4
/* ------------------------------------ */
/* ------------------------------------ */
void fun(void)
{  
    
double **A               = rEsymmetric_mR(i_mR(RCA,RCA),999,+1.E-3);  

double **ExpA_EValue     = i_mR(RCA,RCA);
double **ExpA            = i_mR(RCA,RCA);

double **Log_ExpA_EValue = i_mR(RCA,RCA); 
double **Log_ExpA        = i_mR(RCA,RCA);
    
double **EVector         = i_mR(RCA,RCA);
double **EVectorT        = i_mR(RCA,RCA);
double **EValue          = i_mR(RCA,RCA); 
double **T               = i_mR(RCA,RCA);

/* ================================================================== */           
   clrscrn();
   printf(" Copy/Paste into the octave window.       \n\n");
   p_Octave_mR(A, "A", P6);
   printf(" expm (A)\n\n\n");
  
   eigs_V_mR(A,EVector);
   transpose_mR(EVector,EVectorT);
    
/* EValue = EVectorT A EVector */   
   mul_mR(EVectorT,A,T);
   mul_mR(T,EVector,EValue); 
    
   printf(" ExpA");
   f_eigs_mR(exp,EValue, ExpA_EValue);  

/*  ExpA = EVector Exp_EValue EVectorT */         
      mul_mR(EVector,ExpA_EValue,T);
      mul_mR(T,EVectorT,ExpA);
        p_mR(ExpA, S9,P4, C6);
   stop();

/* ================================================================== */   
   clrscrn();     
  
   eigs_V_mR(ExpA,EVector);
   transpose_mR(EVector,EVectorT);
    
/* ExpA_EValue = EVectorT ExpA EVector */   
   mul_mR(EVectorT,ExpA,T);
   mul_mR(T,EVector,ExpA_EValue); 
   
   printf(" Log_ExpA = A");
   f_eigs_mR(log,ExpA_EValue, Log_ExpA_EValue);  

/*  A = EVector Log_ExpA_EValue EVectorT */          
      mul_mR(EVector,Log_ExpA_EValue,T);
      mul_mR(T,EVectorT,Log_ExpA);
        p_mR(Log_ExpA, S9,P6, C6);
 
    printf(" A:");
    p_mR(A, S9,P6, C6);
     
   f_mR(A);
   
   f_mR(ExpA_EValue);
   f_mR(ExpA);
    
   f_mR(Log_ExpA_EValue);
   f_mR(Log_ExpA); 
      
   f_mR(EVector);
   f_mR(EVectorT);
   f_mR(EValue); 
   f_mR(T);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

do
{
    fun();
    
} while(stop_w());

  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Exemple de sortie écran :
 Copy/Paste into the octave window.       

 A=[
+1.042586,+0.395495,-0.202399,+0.657061;
+0.395495,+2.698601,-1.296908,+0.109110;
-0.202399,-1.296908,+0.954059,-0.056233;
+0.657061,+0.109110,-0.056233,+0.812479]

 expm (A)


 ExpA
  +4.2663   +5.0611   -2.6749   +2.1256 
  +5.0611  +24.8115  -12.5089   +2.1687 
  -2.6749  -12.5089   +7.9569   -1.1450 
  +2.1256   +2.1687   -1.1450   +2.9332 

 Press return to continue. 


 Log_ExpA = A
+1.042586 +0.395495 -0.202399 +0.657061 
+0.395495 +2.698601 -1.296908 +0.109110 
-0.202399 -1.296908 +0.954059 -0.056233 
+0.657061 +0.109110 -0.056233 +0.812479 

 A:
+1.042586 +0.395495 -0.202399 +0.657061 
+0.395495 +2.698601 -1.296908 +0.109110 
-0.202399 -1.296908 +0.954059 -0.056233 
+0.657061 +0.109110 -0.056233 +0.812479 


 Press   return to continue
 Press X return to stop