Aller au contenu

Mathc complexes/00f

Un livre de Wikilivres.


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_cosh2A_mZ(
double **EigsValue,
double **EigsValue_cosh2A
)
{
int  r;
int  c;

nb_Z cosh2A;

  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)
          {
           cosh2A = cosh_Z(i_Z(2.*EigsValue[r][c],2.*EigsValue[r][c+C1]));
           
           EigsValue_cosh2A[r][c   ] = cosh2A.r;
           EigsValue_cosh2A[r][c+C1] = cosh2A.i;
          }
              
 return(EigsValue_cosh2A);
}
/* ------------------------------------ */
/* ------------------------------------ */
double **EigsValue_coshAP2_pls_sinhAP2_mZ(
double **EigsValue,
double **EigsValue_coshAP2_pls_sinhAP2
)
{
int  r;
int  c;

nb_Z coshAP2_pls_sinhAP2;

nb_Z cosh;
nb_Z coshP2;

nb_Z sinh;
nb_Z sinhP2;

  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)
          {
           cosh   = cosh_Z(i_Z(EigsValue[r][c],EigsValue[r][c+C1]));
           coshP2 = mul_Z(cosh,cosh);			  
			  
           sinh   = sinh_Z(i_Z(EigsValue[r][c],EigsValue[r][c+C1]));
           sinhP2 = mul_Z(sinh,sinh);
           
           coshAP2_pls_sinhAP2 = add_Z(coshP2,sinhP2);
           
           EigsValue_coshAP2_pls_sinhAP2[r][c   ] = coshAP2_pls_sinhAP2.r;
           EigsValue_coshAP2_pls_sinhAP2[r][c+C1] = coshAP2_pls_sinhAP2.i;
          }
              
 return(EigsValue_coshAP2_pls_sinhAP2);
}
/* ------------------------------------ */
/* ------------------------------------ */
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_cosh2a              =       i_mZ(RCA,RCA);
double **EigsValue_coshAP2_pls_sinhAP2 =       i_mZ(RCA,RCA);

double **cosh2a                        =       i_mZ(RCA,RCA);
double **coshAP2_pls_sinhAP2           =       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(" cosh(2*A)        :");
  EigsValue_cosh2A_mZ(EigsValue,EigsValue_cosh2a);
   
  mul_mZ(V,EigsValue_cosh2a,T);
  mul_mZ(T,invV,cosh2a); 
  pE_mZ(cosh2a, S12,P4, S8,P4, C3);

  printf(" cosh(A)**2+sinh(A)**2 :");
  EigsValue_coshAP2_pls_sinhAP2_mZ(EigsValue,EigsValue_coshAP2_pls_sinhAP2);
   
  mul_mZ(V,EigsValue_coshAP2_pls_sinhAP2,T);
  mul_mZ(T,invV,coshAP2_pls_sinhAP2); 
  pE_mZ(coshAP2_pls_sinhAP2, S12,P4, S8,P4, C3);  
  
  f_mZ(A);
  
  f_mZ(V);  
  f_mZ(invV);  
  f_mZ(T);  
  
  f_mZ(EigsValue);
  
  f_mZ(EigsValue_cosh2a);   
  f_mZ(cosh2a); 
  
  f_mZ(EigsValue_coshAP2_pls_sinhAP2);   
  f_mZ(coshAP2_pls_sinhAP2);     
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

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

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


Exemple de sortie écran :
 A :
  -0.0059 -0.0806i   -0.0845 -0.0087i   +0.0988 +0.0522i 
  +0.0166 +0.0501i   -0.0057 -0.0405i   -0.0141 -0.0687i 
  +0.0448 +0.0881i   +0.0199 +0.0717i   +0.0152 +0.0594i 

 V :
 -7.6849e-01 -2.4265e-02i  +5.0021e-01 -2.6049e-01i  -5.4710e-01 -7.9835e-02i 
 +4.9947e-01 -3.3796e-01i  -1.3753e-01 -1.8362e-01i  -2.3073e-02 +6.4354e-01i 
 +2.1246e-01 +3.9836e-18i  +7.9329e-01 +0.0000e+00i  +5.2880e-01 +2.8288e-19i 

 inv(V) ... Some time the matrix is not invertible :
 -6.6537e-01 +3.0261e-01i  +3.6129e-01 +7.6021e-01i  +2.0685e-01 -1.9388e-01i 
 +4.6338e-01 +1.7900e-01i  +1.1979e-01 +3.2640e-01i  +8.5483e-01 +1.2360e-01i 
 -4.2781e-01 -3.9011e-01i  -3.2487e-01 -7.9508e-01i  +5.2557e-01 -1.0753e-01i 

 EigsValue = invV * A * V
 +2.4051e-02 -1.2748e-01i  +0.0000e+00 +0.0000e+00i  +0.0000e+00 +0.0000e+00i 
 +0.0000e+00 +0.0000e+00i  +8.5524e-02 +8.3205e-02i  +0.0000e+00 +0.0000e+00i 
 +0.0000e+00 +0.0000e+00i  +0.0000e+00 +0.0000e+00i  -1.0597e-01 -1.7422e-02i 

 Press return to continue. 


 cosh(2*A)        :
 +9.8486e-01+1.5303e-02i  -3.6974e-03+3.6820e-02i  +5.1147e-03+8.6467e-03i 
 +2.2548e-02-1.3790e-02i  +1.0042e+00-1.2473e-02i  +4.0493e-04+9.8262e-03i 
 -2.0382e-03+4.0611e-03i  -8.3846e-03-1.3595e-02i  +1.0023e+00+2.0944e-02i 

 cosh(A)**2+sinh(A)**2 :
 +9.8486e-01+1.5303e-02i  -3.6974e-03+3.6820e-02i  +5.1147e-03+8.6467e-03i 
 +2.2548e-02-1.3790e-02i  +1.0042e+00-1.2473e-02i  +4.0493e-04+9.8262e-03i 
 -2.0382e-03+4.0611e-03i  -8.3846e-03-1.3595e-02i  +1.0023e+00+2.0944e-02i 


 Press   return to continue
 Press X return to stop