Aller au contenu

Mathc matrices/c11en

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
/* ------------------------------------ */
/* ------------------------------------ */
double f(
double x)
{  
        return((x)*(x)*(x));
}
char  feq[] =  "(x)*(x)*(x)";
/* ------------------------------------ */
/* ------------------------------------ */
void fun(void)
{
double **A             = rsymmetric_mR(i_mR(RCA,RCA),999.);
double **A_p3          =               i_mR(RCA,RCA);

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

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

double **T1            =               i_mR(RCA,RCA);
  
  clrscrn();
  printf(" Copy/Past into the octave windows \n");
  p_Octave_mR(A,"A",P0);
  printf("  A*A*A\n\n");
  stop();
  
  clrscrn();  
     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(" A**3 : EigsVector * EigsValue**3 * T_EigsVector\n");  
  f_eigs_mR(f,EigsValue,f_EigsValue);     
     mul_mR(EigsVector,f_EigsValue,T1);
     mul_mR(T1,T_EigsVector,A_p3); 
      pE_mR(A_p3,S10,P4,C6);     
  
  printf(" A**3");  
  pow_mR(3,A,T1);  
   pE_mR(T1,S10,P4,C6);   

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

  srand(time(&t));

do
{
  fun();

} while(stop_w());

  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
                       A**3 = V EValue**3 T_V

Exemple de sortie écran :
/* ------------------------------------ */
 Copy/Past into the octave windows 
 A=[
-999,+832,+542;
+832,-899,+736;
+542,+736,+964]

 A*A*A

 Press return to continue. 



 A**3 : EigsVector * EigsValue**3 * T_EigsVector

-2.6423e+09 +3.1484e+09 +7.7870e+08 
+3.1484e+09 -2.4507e+09 +1.3441e+09 
+7.7870e+08 +1.3441e+09 +2.3899e+09 

 A**3
-2.6423e+09 +3.1484e+09 +7.7870e+08 
+3.1484e+09 -2.4507e+09 +1.3441e+09 
+7.7870e+08 +1.3441e+09 +2.3899e+09 


 Press return to continue
 Press X      to stop