Fonctions matricielles dans C. Matrices Non symétriques conjugués


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


c00a.c
/* ------------------------------------ */
/*  Save as :   c00a.c                  */
/* ------------------------------------ */
#include "w_a.h"
/* ------------------------------------ */
#define FACTOR_E    +1.E-0         
#define RCA          RC3  
/* ------------------------------------ */
/* ------------------------------------ */
double **EigsValue_sinh2A_mZ(
double **EigsValue,
double **EigsValue_sinh2A
)
{
int  r;
int  c;
nb_Z sinh2A;

  for (   r=R1; r<EigsValue[R_SIZE][C0]; r++)
    for ( c=C1; c<EigsValue[C_SIZE][C0]; c+=C2)

        if(((r-R1)*C2)==c-C1)
          {
           sinh2A = sinh_Z(i_Z(2.*EigsValue[r][c],2.*EigsValue[r][c+C1]));
           
           EigsValue_sinh2A[r][c   ] = sinh2A.r;
           EigsValue_sinh2A[r][c+C1] = sinh2A.i;
          }
              
 return(EigsValue_sinh2A);
}
/* ------------------------------------ */
/* ------------------------------------ */
double **EigsValue_TwocoshAsinhA_mZ(
double **EigsValue,
double **EigsValue_TwocoshAsinhA
)
{
int  r;
int  c;

nb_Z cosha;
nb_Z sinha;

nb_Z TwocoshAsinhA;

  for (   r=R1; r<EigsValue[R_SIZE][C0]; r++)
    for ( c=C1; c<EigsValue[C_SIZE][C0]; c+=C2)

        if(((r-R1)*C2)==c-C1)
          {
           cosha = cosh_Z(i_Z( EigsValue[r][c], EigsValue[r][c+C1]));
           sinha = sinh_Z(i_Z( EigsValue[r][c], EigsValue[r][c+C1]));
             
           TwocoshAsinhA = smul_Z(2., mul_Z(cosha,sinha) ); 
           
           EigsValue_TwocoshAsinhA[r][c   ] = TwocoshAsinhA.r;
           EigsValue_TwocoshAsinhA[r][c+C1] = TwocoshAsinhA.i;     
          }
              
 return(EigsValue_TwocoshAsinhA);
}
/* ------------------------------------ */    
/* ------------------------------------ */
void fun(void)
{                               
double **A                    = rE_mZ(i_mZ(RCA,RCA),999,+1.E-4);

double **V                     =      i_mZ(RCA,RCA);
double **invV                  =      i_mZ(RCA,RCA);
double **T                     =      i_mZ(RCA,RCA);

double **EigsValue             =      i_mZ(RCA,RCA);
double **EigsValue_sinh2A       =      i_mZ(RCA,RCA);
double **EigsValue_TwocoshAsinhA =      i_mZ(RCA,RCA);

double **sinh2A                 =      i_mZ(RCA,RCA);
double **TwocoshAsinhA           =      i_mZ(RCA,RCA);

  clrscrn();
  printf(" A :");
  p_mZ(A, S9,P4, S8,P4, C3);

  printf(" V :");
  eigs_V_mZ(A,V,FACTOR_E);
  pE_mZ(V, S12,P4, S12,P4, C3);
  
  printf(" inv(V) ... Some time the matrix is not invertible :");
  inv_mZ(V,invV);
  pE_mZ(invV, S12,P4, S12,P4, C3);
  
  printf(" EigsValue = invV * A * V");
  mul_mZ(invV,A,T);
  mul_mZ(T,V,EigsValue); 
  pE_mZ(clean_eyes_mZ(EigsValue), S12,P4, S12,P4, C3);
  stop();

  clrscrn();  
  printf(" sinh(2*A)        :");
  EigsValue_sinh2A_mZ(EigsValue,EigsValue_sinh2A);
   
  mul_mZ(V,EigsValue_sinh2A,T);
  mul_mZ(T,invV,sinh2A); 
  pE_mZ(sinh2A, S12,P4, S8,P4, C3);

  printf(" 2 cosh(A)sinh(A) :");
  EigsValue_TwocoshAsinhA_mZ(EigsValue,EigsValue_TwocoshAsinhA);
   
  mul_mZ(V,EigsValue_TwocoshAsinhA,T);
  mul_mZ(T,invV,TwocoshAsinhA); 
  pE_mZ(TwocoshAsinhA, S12,P4, S8,P4, C3);  
  
  f_mZ(A);
  
  f_mZ(V);  
  f_mZ(invV);  
  f_mZ(T);  
  
  f_mZ(EigsValue);
  
  f_mZ(EigsValue_sinh2A);   
  f_mZ(sinh2A); 
  
  f_mZ(EigsValue_TwocoshAsinhA);   
  f_mZ(TwocoshAsinhA);     
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

do
{
    fun();
    
} while(stop_w());

  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */


Exemple de sortie écran :
 A :
  -0.0426 -0.0065i   +0.0133 -0.0466i   -0.0945 +0.0118i 
  +0.0257 -0.0071i   +0.0997 +0.0172i   +0.0524 +0.0889i 
  -0.0049 +0.0956i   +0.0667 -0.0343i   -0.0674 +0.0803i 

 V :
 +4.2383e-01 +3.8784e-01i  -1.0405e-01 -1.3772e-01i  -6.5858e-01 -5.1489e-01i 
 -9.3079e-02 -3.3335e-01i  +8.2921e-01 +3.4413e-01i  -1.9471e-01 -1.9185e-01i 
 +7.4173e-01 +0.0000e+00i  +4.0521e-01 +0.0000e+00i  +4.7586e-01 +0.0000e+00i 

 inv(V) ... Some time the matrix is not invertible :
 +4.1524e-01 -3.6884e-01i  -2.2199e-01 +1.5704e-01i  +8.1963e-01 -8.6427e-02i 
 -2.2224e-02 +1.0365e-01i  +8.1396e-01 -4.5602e-01i  +3.7398e-01 +2.6098e-01i 
 -6.2831e-01 +4.8666e-01i  -3.4709e-01 +1.4353e-01i  +5.0543e-01 -8.7516e-02i 

 EigsValue = invV * A * V
 -1.4397e-01 +1.0669e-01i  +0.0000e+00 +0.0000e+00i  +0.0000e+00 +0.0000e+00i 
 +0.0000e+00 +0.0000e+00i  +1.3197e-01 +4.3872e-02i  +0.0000e+00 +0.0000e+00i 
 +0.0000e+00 +0.0000e+00i  +0.0000e+00 +0.0000e+00i  +1.7019e-03 -5.9564e-02i 

 Press return to continue. 


 sinh(2*A)        :
 -8.4356e-02-1.0463e-02i  +2.6192e-02-9.4857e-02i  -1.8974e-01+2.6819e-02i 
 +5.1373e-02-1.5580e-02i  +2.0114e-01+3.7369e-02i  +1.0590e-01+1.7767e-01i 
 -7.2154e-03+1.9268e-01i  +1.3333e-01-6.8935e-02i  -1.3274e-01+1.6556e-01i 

 2 cosh(A)sinh(A) :
 -8.4356e-02-1.0463e-02i  +2.6192e-02-9.4857e-02i  -1.8974e-01+2.6819e-02i 
 +5.1373e-02-1.5580e-02i  +2.0114e-01+3.7369e-02i  +1.0590e-01+1.7767e-01i 
 -7.2154e-03+1.9268e-01i  +1.3333e-01-6.8935e-02i  -1.3274e-01+1.6556e-01i 


 Press   return to continue
 Press X return to stop