Aller au contenu

Mathc complexes/08k

Un livre de Wikilivres.


Application

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

c00g.c
/* ------------------------------------ */
/*  Save as :   c00g.c                  */
/* ------------------------------------ */
#include "w_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
#define   V    R2
/* ------------------------------------ */
#define   RAb  R2
#define   CA   C6
#define   Cb   C1
/* ------------------------------------ */
# define FREEV C4
/* ------------------------------------ */
/* ------------------------------------ */
#define  UARRAY FREEV
#define  VARRAY V
/* ------------------------------------ */
/* ------------------------------------ */
int main(void)
{
double ab[RAb*(CA+C1)*C2]={
 -18,7, -549,5, -119,3, -715,7, -233,4, -640,6,  0,0, /*  V[0]|0*/
+152,8,  -42,4, -910,2, -730,5, +359,2, -799,3,  0,0  /*  V[1]|0*/  
};

double **Ab      = ca_A_mZ(ab, i_Abr_Ac_bc_mZ(RAb, CA, Cb));
double **Ab_free =             i_Abr_Ac_bc_mZ(CA,  CA, Cb + FREEV);
double **b_free  =                       i_mZ(CA,      Cb + FREEV); 

double **A       =    c_Ab_A_mZ(Ab,      i_mZ(RAb,     CA));  
double **At      = ctranspose_mZ(A,      i_mZ(CA,      RAb));  
/* ------------------------------------ */
double **u [UARRAY];
double **vt[VARRAY];
/* ------------------------------------ */
int c,r;

/*  Compute the free variables (b_free) */
      gj_PP_mZ(Ab);                
  put_zeroR_mZ(Ab,Ab_free);           
  put_freeV_mZ(Ab_free); 
         gj_mZ(Ab_free); 
     c_Ab_b_mZ(Ab_free,b_free);    

  clrscrn();
  printf(" Compute the orthogonal vectors to V :\n\n\n");
  for(c=C0; c<VARRAY; c++)
     {
      vt[c] = i_mZ(CA,C1);     
      c_c_mZ(At,(c+C1),vt[c],C1);
      
      printf(" v^t[%d]:",c);      
      p_mZ(vt[c], S10,P4, S10,P4, C1);       
     }  
  stop();

  clrscrn();
  for(c=C0; c<UARRAY; c++)
     {
      u[c] = i_mZ(CA,C1);      
      c_c_mZ(b_free,(c+C2), u[c],C1); 
      
	  printf(" u[%d] :",c);      
      p_mZ(u[c], S10,P4, S10,P4, C1);                   
     }  
   printf(" The free vectors of the system"
          " are the orthogonal vectors to V :\n\n\n");        
  stop();

  clrscrn();
  printf(" \n\n\n"
         " You can verify if"
         " the free vectors of the system\n"
         " are orthogonal to V :   \n\n"
         "          <u,v> = v^t u          \n\n");

  for(c=C0; c<VARRAY; c++) 
  
    for(r=C0;  r<UARRAY; r++) 
      {
         printf(" v^t[%d] u[%d] = ",c,r); 
         p_Z(dot_Z(vt[c],u[r]), S4,P5, S5,P5);
         printf("\n");
	   }
              
  printf("\n\n\n");
  stop();
  
  f_mZ(Ab);
  f_mZ(Ab_free);
  f_mZ(b_free);
  f_mZ(A);  
  f_mZ(At);

/* --- Free the memory of the Arrays -- */
  for(c=C0; c<UARRAY; c++)
  
       f_mZ( u[c]);        
      
  for(c=C0; c<VARRAY; c++)
  
       f_mZ(vt[c]);      

  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Dans cet exemple, il y a deux lignes. La bibliothèque ne fonctionne pas avec les systèmes à une seule ligne. Si le produit scalaire de deux vecteurs est nul, cela signifie qu'ils sont orthogonaux.
Exemple de sortie écran :
 Compute the orthogonal vectors to V :


 v^t[0]:
  -18.0000   -7.0000i 
 -549.0000   -5.0000i 
 -119.0000   -3.0000i 
 -715.0000   -7.0000i 
 -233.0000   -4.0000i 
 -640.0000   -6.0000i 

 v^t[1]:
 +152.0000   -8.0000i 
  -42.0000   -4.0000i 
 -910.0000   -2.0000i 
 -730.0000   -5.0000i 
 +359.0000   -2.0000i 
 -799.0000   -3.0000i 

 Press return to continue. 


 u[0] :
   +5.8618   -0.2872i 
   -0.4061   +0.0859i 
   +1.0000   +0.0000i 
   +0.0000   -0.0000i 
   +0.0000   +0.0000i 
   +0.0000   +0.0000i 

 u[1] :
   +4.3942   -0.2089i 
   -1.4443   +0.0625i 
   +0.0000   +0.0000i 
   +1.0000   -0.0000i 
   +0.0000   +0.0000i 
   +0.0000   +0.0000i 

 u[2] :
   -2.4519   +0.1164i 
   -0.3452   -0.0309i 
   +0.0000   -0.0000i 
   -0.0000   +0.0000i 
   +1.0000   +0.0000i 
   +0.0000   +0.0000i 

 u[3] :
   +4.8809   -0.2229i 
   -1.3236   +0.0684i 
   -0.0000   +0.0000i 
   +0.0000   +0.0000i 
   +0.0000   +0.0000i 
   +1.0000   +0.0000i 

 The free vectors of the system are the orthogonal vectors to V :


 Press return to continue. 


 You can verify if the free vectors of the system
 are orthogonal to V :   

          <u,v> = v^t u          

 v^t[0] u[0] = +0.00000+0.00000i 
 v^t[0] u[1] = +0.00000-0.00000i 
 v^t[0] u[2] = -0.00000-0.00000i 
 v^t[0] u[3] = -0.00000+0.00000i 
 v^t[1] u[0] = -0.00000-0.00000i 
 v^t[1] u[1] = +0.00000+0.00000i 
 v^t[1] u[2] = -0.00000-0.00000i 
 v^t[1] u[3] = -0.00000-0.00000i 



 Press return to continue.