Aller au contenu

Mathc matrices/c11fn

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
/* ------------------------------------ */
/* ------------------------------------ */
double f(
double x)
{  
        return((x)*(x)*(x)*(x));
}
char  feq[] =  "(x)*(x)*(x)*(x)";
/* ------------------------------------ */
/* ------------------------------------ */
void fun(void)
{
double **A             = rsymmetric_mR(i_mR(RCA,RCA),99.);
double **A_p4          =               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\n");
  p_Octave_mR(A,"A",P0);
  printf("  A*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**4 : EigsVector * EigsValue**4 * T_EigsVector");
  f_eigs_mR(f,EigsValue,f_EigsValue);     
     mul_mR(EigsVector,f_EigsValue,T1);
     mul_mR(T1,T_EigsVector,A_p4);  
      pE_mR(A_p4,S10,P4,C6);     
  
  printf(" A**4");  
  pow_mR(4,A,T1);  
  pE_mR(T1,S10,P4,C6);   
   
  f_mR(A);
  f_mR(A_p4);
    
  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**4 = V EValue**4 T_V


Exemple de sortie écran :
/* ------------------------------------ */
 Copy/Past into the octave windows 

 A=[
-781,+206,-165,+270;
+206,+150,+962,-865;
-165,+962,-81,+738;
+270,-865,+738,+850]

  A*A*A*A

 Press return to continue. 



 A**4 : EigsVector * EigsValue**4 * T_EigsVector
+1.2094e+12 -1.6001e+12 +1.6212e+12 -9.1411e+11 
-1.6001e+12 +3.6726e+12 -2.2160e+12 -4.6210e+10 
+1.6212e+12 -2.2160e+12 +3.0157e+12 -1.2021e+12 
-9.1411e+11 -4.6210e+10 -1.2021e+12 +4.5455e+12 

 A**4
+1.2094e+12 -1.6001e+12 +1.6212e+12 -9.1411e+11 
-1.6001e+12 +3.6726e+12 -2.2160e+12 -4.6210e+10 
+1.6212e+12 -2.2160e+12 +3.0157e+12 -1.2021e+12 
-9.1411e+11 -4.6210e+10 -1.2021e+12 +4.5455e+12 


 Press return to continue
 Press X      to stop