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:   c00a.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 **EVector    =                 i_mR(RCA,RCA);
double **EVectorT   =                 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, Exp_EValue);

/*  ExpA = EVector Exp_EValue EVectorT */         
      mul_mR(EVector,Exp_EValue,T);
      mul_mR(T,EVectorT,ExpA);  
        p_mR(ExpA, S11,P6, C6);
       
   f_mR(A);
   f_mR(EValue);   
       
   f_mR(Exp_EValue);
   f_mR(ExpA); 
      
   f_mR(EVector);
   f_mR(EVectorT);

   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.353880,+0.768653,-0.387856,+0.877190,+0.845749;
+0.768653,+1.598690,-0.260210,+0.698741,-0.502396;
-0.387856,-0.260210,+1.984934,-0.726449,-0.703080;
+0.877190,+0.698741,-0.726449,+1.824694,+0.248152;
+0.845749,-0.502396,-0.703080,+0.248152,+3.560136]

 expm (A)


 ExpA :
 +15.309251   +6.738864  -12.239002  +13.347924  +20.093327 
  +6.738864   +9.968287   -4.782213   +8.330819   -1.171490 
 -12.239002   -4.782213  +17.167652  -12.770771  -20.930261 
 +13.347924   +8.330819  -12.770771  +16.694582  +14.541423 
 +20.093327   -1.171490  -20.930261  +14.541423  +54.197513 


 Press   return to continue
 Press X return to stop