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 **V       = i_mR(RCA,RCA);
double **V_T     = i_mR(RCA,RCA);
double **EValue  = i_mR(RCA,RCA); 
double **T       = i_mR(RCA,RCA);

/* ================================================================== */           
   clrscrn();
   printf(" Copy/Past into the octave window.       \n\n");
   p_Octave_mR(A, "A", P6);
   printf(" expm (A)\n\n\n");
  
   eigs_V_mR(A,V);
   transpose_mR(V,V_T);
    
/* EValue = V_T * A * V */   
   mul_mR(V_T,A,T);
   mul_mR(T,V,EValue); 
    
   printf(" ExpA");
   f_eigs_mR(exp,EValue, ExpA_EValue);   
      mul_mR(V,ExpA_EValue,T);
      mul_mR(T,V_T,ExpA);
        p_mR(ExpA, S9,P4, C6);
   stop();

/* ================================================================== */   
   clrscrn();     
   printf(" Copy/Past into the octave window.       \n\n");
   p_Octave_mR(ExpA,"ExpA", P6);
   printf(" logm (ExpA)\n\n\n");
  
   eigs_V_mR(ExpA,V);
   transpose_mR(V,V_T);
    
/* ExpA_EValue = V_T * ExpA * V */   
   mul_mR(V_T,ExpA,T);
   mul_mR(T,V,ExpA_EValue); 
   
   printf(" Log_ExpA = A");
   f_eigs_mR(log,ExpA_EValue, Log_ExpA_EValue);     
      mul_mR(V,Log_ExpA_EValue,T);
      mul_mR(T,V_T,Log_ExpA);
        p_mR(Log_ExpA, S9,P6, C6);
 
    printf(" A :");
    p_mR(A, S9,P6, C6);
    stop();
     
   f_mR(A);
   
   f_mR(ExpA_EValue);
   f_mR(ExpA);
    
   f_mR(Log_ExpA_EValue);
   f_mR(Log_ExpA); 
      
   f_mR(V);
   f_mR(V_T);
   f_mR(EValue); 
   f_mR(T);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

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

  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
                         Log( Exp(A) ) = A


Exemple de sortie écran :
  Copy/Past into the octave window.       

 A=[
+1.130754,-0.006751,+0.620392,+0.120624;
-0.006751,+0.621790,-0.226756,-0.493868;
+0.620392,-0.226756,+0.660265,-0.033834;
+0.120624,-0.493868,-0.033834,+0.740071]

 expm (A)


 ExpA
  +3.6510   -0.2543   +1.6509   +0.3460 
  -0.2543   +2.1564   -0.4867   -1.0272 
  +1.6509   -0.4867   +2.4419   +0.1334 
  +0.3460   -1.0272   +0.1334   +2.3652 

 Press return to continue. 


 Copy/Past into the octave window.       

 ExpA=[
+3.651013,-0.254340,+1.650932,+0.345959;
-0.254340,+2.156368,-0.486705,-1.027236;
+1.650932,-0.486705,+2.441852,+0.133397;
+0.345959,-1.027236,+0.133397,+2.365191]

 logm (ExpA)


 Log_ExpA = A
+1.130754 -0.006751 +0.620392 +0.120624 
-0.006751 +0.621790 -0.226756 -0.493868 
+0.620392 -0.226756 +0.660265 -0.033834 
+0.120624 -0.493868 -0.033834 +0.740071 

 A :
+1.130754 -0.006751 +0.620392 +0.120624 
-0.006751 +0.621790 -0.226756 -0.493868 
+0.620392 -0.226756 +0.660265 -0.033834 
+0.120624 -0.493868 -0.033834 +0.740071 

 Press return to continue.