Aller au contenu

Mathc matrices/a155

Un livre de Wikilivres.



Fonctions matricielles ex : cos(A)


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


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

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

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

/* EVector                     */    
      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);  

/* exp(EValue)                 */   
   f_eigs_mR(exp,EValue, Exp_EValue);

/* A = V * A_EValue * V_T */     
   mul_mR(V,Exp_EValue,T);
   mul_mR(T,V_T,ExpA); 
       
   printf(" ExpA :");
   p_mR(    ExpA, S11,P6, C6);
       
   f_mR(A);
   f_mR(EValue);   
       
   f_mR(Exp_EValue);
   f_mR(ExpA); 
      
   f_mR(V);
   f_mR(V_T);

   f_mR(T);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

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

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


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

 A=[
+1.655355,+1.350778,-0.342599,-0.341748,+0.429861;
+1.350778,+1.568408,-0.158844,-0.415816,+0.417686;
-0.342599,-0.158844,+1.175215,-0.436240,-0.573249;
-0.341748,-0.415816,-0.436240,+0.410208,-0.033060;
+0.429861,+0.417686,-0.573249,-0.033060,+0.607863]

 expm (A)


 ExpA :
 +12.926874  +11.175547   -3.185199   -2.628348   +4.187926 
 +11.175547  +12.073314   -2.637676   -2.732714   +3.935739 
  -3.185199   -2.637676   +4.511294   -0.509211   -2.312927 
  -2.628348   -2.732714   -0.509211   +2.261209   -0.584766 
  +4.187926   +3.935739   -2.312927   -0.584766   +3.354703 


 Press   return to continue
 Press X return to stop