Aller au contenu

Mathc matrices/a37

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
/* ------------------------------------ */
void fun(void)
{
double **A        = rPsymmetric_mR( i_mR(RCA,RCA),99);
double **SqrtA    =                 i_mR(RCA,RCA);

double **EVector  =                 i_mR(RCA,RCA);
double **EVectorT =                 i_mR(RCA,RCA);

double **EValue   =                 i_mR(RCA,RCA);
double **f_EValue =                 i_mR(RCA,RCA);

double **T1       =                 i_mR(RCA,RCA);
  
  clrscrn();
  printf(" A:");
  p_mR(A, S7,P0, C8); 
  
  eigs_V_mR(A,EVector); 
  transpose_mR(EVector,EVectorT);
      
/* EValue: EVectorT A EVector */
  mul_mR(EVectorT,A,T1);
  mul_mR(T1,EVector,EValue);     
  
  printf(" sqrt(A) = EVector sqrt(EValue) EVectorT\n");
  f_eigs_mR(sqrt,EValue,f_EValue);     
 
     mul_mR(EVector,f_EValue,T1);
     mul_mR(T1,EVectorT,SqrtA);
       p_mR(SqrtA,S10,P4,C8);    
  
  printf(" A = sqrt(A) sqrt(A)");  
  mul_mR(SqrtA,SqrtA,A);
  p_mR(A, S7,P0, C8);   
   
  f_mR(A);
  f_mR(SqrtA);
    
  f_mR(EVector);
  f_mR(EVectorT);
  
  f_mR(EValue);
  f_mR(f_EValue);    
     
  f_mR(T1);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

do
{
  fun();

} while(stop_w());

  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
 sqrt(A) = EVector sqrt(EValue) EVectorT
Exemple de sortie écran :
 A:
  +8103      +4     -20     -70 
     +4   +2442     -58     -41 
    -20     -58   +8658     +57 
    -70     -41     +57   +3552 

 sqrt(A) = EVector sqrt(EValue) EVectorT

  +90.0154    +0.0271    -0.1082    -0.4675 
   +0.0271   +49.4135    -0.4061    -0.3746 
   -0.1082    -0.4061   +93.0467    +0.3721 
   -0.4675    -0.3746    +0.3721   +59.5945 

 A = sqrt(A) sqrt(A)
  +8103      +4     -20     -70 
     +4   +2442     -58     -41 
    -20     -58   +8658     +57 
    -70     -41     +57   +3552 


 Press   return to continue
 Press X return to stop