Aller au contenu

Mathc matrices/c26e

Un livre de Wikilivres.


Application


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

cq4.c
/* ------------------------------------ */
/*  Save as :   cq4.c                   */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define   RA R3
#define   CA C3
#define   CB C3
/* ------------------------------------ */
void fun(void)
{
double **A  = r_Q_mR(i_mR(RA,CA),99);
double **B  =   r_mR(i_mR(RA,CB),99.);
double **Ab = i_Abr_Ac_bc_mR(RA,CA,CB);

double **b[CB];
double **a[CA];

int c;

  clrscrn();
  printf(" A : Orthonormal");
  p_mR(A,S9,P4,C6);

  printf("  b[C0]     b[C1]     b[C2]  :");
  p_mR(B,S9,P1,C6);
 
  printf(" Ab :");
  c_A_b_Ab_mR(A,B,Ab);
  p_mR(Ab,S9,P4,C6);

  printf("  gj_TP_mR(Ab) :                x[C0]     x[C1]     x[C2]");
  gj_TP_mR(Ab);
  p_mR(Ab,S9,P4,C6);
  stop();
  
/* ------------------------------------ */
/* ------------------------------------ */
  for(c=C0; c<CB; c++)
     {
      b[c] = i_mR(RA,C1);      
      c_c_mR(B,(c+C1),b[c],C1); }  
      
  for(c=C0; c<CA; c++)
     {
      a[c] = i_mR(RA,C1);      
      c_c_mR(A,(c+C1),a[c],C1); }  
/* ------------------------------------ */
/* ------------------------------------ */ 

  clrscrn();      
  for(c=C0; c<CA; c++)
     {
      printf(" a[%d] :",c);      
      pE_mR(a[c],S12,P4,C6); }        
  stop();
  
  clrscrn(); 
  for(c=C0; c<CB; c++)
     {
      printf(" b[%d] :",c);      
      p_mR(b[c],S12,P4,C6); }  
  stop();
 
  clrscrn();       
  printf(" x[C0] :\n");        
  for(c=C0; c<CA; c++)   
      printf("%+15.7f   <b[C0],a[%d]>\n",dot_R(b[C0],a[c]), c);       
      
  printf("\n x[C1] :\n");        
  for(c=C0; c<CA; c++)   
      printf("%+15.7f   <b[C1],a[%d]>\n",dot_R(b[C1],a[c]), c); 

  printf("\n x[C2] :\n");        
  for(c=C0; c<CA; c++)   
      printf("%+15.7f   <b[C2],a[%d]>\n",dot_R(b[C2],a[c]), c);        
 
  printf("\n  gj_TP_mR(Ab) :\t\t\t x[C0]        x[C1]        x[C2]");
  p_mR(Ab,S12,P7,C6); 

  
/* ------------------------------------ */
/* ------------------------------------ */       
  for(c=C0; c<CA; c++)  
       f_mR(a[c]); 
      
  for(c=C0; c<CB; c++)  
       f_mR(b[c]); 
/* ------------------------------------ */
/* ------------------------------------ */ 

  f_mR(Ab);
  f_mR(B);
  f_mR(A);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));
do
{
  fun();


} while(stop_w());

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


Résoudre un système d'équation quand A est une matrice orthonormale :  

Ici B est composé de trois vecteurs. 



Exemple de sortie écran :
 --------------------------------
 A : Orthonormal
  +0.4206   -0.8146   +0.3993 
  +0.8698   +0.4872   +0.0779 
  -0.2581   +0.3146   +0.9135 

  b[C0]     b[C1]     b[C2]  :
    +86.0      +5.0     +85.0 
    -64.0     -81.0     -48.0 
    +31.0     -24.0     -96.0 

 Ab :
  +0.4206   -0.8146   +0.3993  +86.0000   +5.0000  +85.0000 
  +0.8698   +0.4872   +0.0779  -64.0000  -81.0000  -48.0000 
  -0.2581   +0.3146   +0.9135  +31.0000  -24.0000  -96.0000 

  gj_TP_mR(Ab) :                x[C0]     x[C1]     x[C2]
  +1.0000   +0.0000   +0.0000  -27.4987  -62.1564  +18.7721 
  +0.0000   +1.0000   +0.0000  -91.4910  -51.0885 -122.8308 
  +0.0000   +0.0000   +1.0000  +57.6734  -26.2401  -57.4909 

 Press return to continue. 


 --------------------------------
 a[0] :
 +4.2056e-01 
 +8.6979e-01 
 -2.5807e-01 

 a[1] :
 -8.1465e-01 
 +4.8723e-01 
 +3.1457e-01 

 a[2] :
 +3.9935e-01 
 +7.7942e-02 
 +9.1348e-01 

 Press return to continue. 


 --------------------------------
 b[0] :
    +86.0000 
    -64.0000 
    +31.0000 

 b[1] :
     +5.0000 
    -81.0000 
    -24.0000 

 b[2] :
    +85.0000 
    -48.0000 
    -96.0000 

 Press return to continue. 

 --------------------------------
 x[C0] :
    -27.4986985   <b[C0],a[0]>
    -91.4909652   <b[C0],a[1]>
    +57.6734328   <b[C0],a[2]>

 x[C1] :
    -62.1564257   <b[C1],a[0]>
    -51.0885041   <b[C1],a[1]>
    -26.2401124   <b[C1],a[2]>

 x[C2] :
    +18.7721390   <b[C2],a[0]>
   -122.8307878   <b[C2],a[1]>
    -57.4909067   <b[C2],a[2]>

  gj_TP_mR(Ab) :			             x[C0]        x[C1]        x[C2]
  +1.0000000   +0.0000000   +0.0000000  -27.4986985  -62.1564257  +18.7721390 
  +0.0000000   +1.0000000   +0.0000000  -91.4909652  -51.0885041 -122.8307878 
  +0.0000000   +0.0000000   +1.0000000  +57.6734328  -26.2401124  -57.4909067 


 Press return to continue
 Press X      to stop