Aller au contenu

Mathc matrices/c11in

Un livre de Wikilivres.



Fonctions matricielles ex : cos(A)


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


c00c.c
/* ------------------------------------ */
/*  Save as :  c00c.c                   */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define   RCA        RC5
/* ------------------------------------ */
/* ------------------------------------ */
double f(
double x)
{  
        return(sin(2*x));
}
char  feq[] =  "sin(2*x)";
/* ------------------------------------ */
double g(
double x)
{  
        return(2*sin(x)*cos(x));
}
char  geq[] =  "2*sin(x)*cos(x)";
/* ------------------------------------ */
/* ------------------------------------ */
void fun(void)
{
double **A             = rsymmetric_mR(i_mR(RCA,RCA),999.);
double **sin2_A        =               i_mR(RCA,RCA);
double **sincos_A      =               i_mR(RCA,RCA);

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

double **EigsValue     =               i_mR(RCA,RCA);
double **sin2_EigsValue   =            i_mR(RCA,RCA);
double **sincos_EigsValue =            i_mR(RCA,RCA);

double **T1            =               i_mR(RCA,RCA);
  
  clrscrn();
  printf(" A :");
  p_mR(A,S10,P4,C6); 

  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(" sin(2*A)");
  f_eigs_mR(f,EigsValue,sin2_EigsValue); 
     mul_mR(EigsVector,sin2_EigsValue,T1);
     mul_mR(T1,T_EigsVector,sin2_A); 
       p_mR(sin2_A,S10,P4,C6); 

  printf(" 2*sin(A)*cos(A)");
  f_eigs_mR(g,EigsValue,sincos_EigsValue);
     mul_mR(EigsVector,sincos_EigsValue,T1);
     mul_mR(T1,T_EigsVector,sincos_A);
       p_mR(sincos_A,S10,P4,C6); 
            
  f_mR(A);
  f_mR(sin2_A);
  f_mR(sincos_A);
    
  f_mR(EigsVector);
  f_mR(T_EigsVector);
  
  f_mR(EigsValue);
  f_mR(sincos_EigsValue);    
  f_mR(sin2_EigsValue);    
      
  f_mR(T1);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

do
{
  fun();

} while(stop_w());

  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
            sin(2*A) = 2*sin(A)*cos(A)

Exemple de sortie écran :
 ------------------------------------ 
 A :
 -837.0000  +508.0000  -635.0000  -761.0000  +184.0000 
 +508.0000  -908.0000  -152.0000  -462.0000  -482.0000 
 -635.0000  -152.0000  +915.0000  -486.0000   -54.0000 
 -761.0000  -462.0000  -486.0000  +592.0000  -891.0000 
 +184.0000  -482.0000   -54.0000  -891.0000  +382.0000 

 sin(2*A)
   +0.2141    -0.7051    +0.2825    -0.1258    -0.1456 
   -0.7051    -0.0769    -0.1429    -0.2307    +0.0922 
   +0.2825    -0.1429    -0.6451    -0.2377    +0.0939 
   -0.1258    -0.2307    -0.2377    -0.0360    -0.4657 
   -0.1456    +0.0922    +0.0939    -0.4657    -0.2337 

 2*sin(A)*cos(A)
   +0.2141    -0.7051    +0.2825    -0.1258    -0.1456 
   -0.7051    -0.0769    -0.1429    -0.2307    +0.0922 
   +0.2825    -0.1429    -0.6451    -0.2377    +0.0939 
   -0.1258    -0.2307    -0.2377    -0.0360    -0.4657 
   -0.1456    +0.0922    +0.0939    -0.4657    -0.2337 


 Press return to continue
 Press X      to stop