Aller au contenu

Mathc complexes/046

Un livre de Wikilivres.

Produits scalaires

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


c00a.c
/* ------------------------------------ */
/*  save as :   c00a.c                  */
/* ------------------------------------ */
#include "w_a.h"
/* ------------------------------------ */
#define   RA R3
#define   CA C2
/* ------------------------------------ */
/* ------------------------------------ */
int main(void)
{
double a[RA*(CA*C2)] ={  
 1,5, -1,5,
 3,5,  2,5, 
-2,5,  4,5};

double **A     = ca_A_mZ(a, i_mZ(RA,CA));
double **Q     =            i_mZ(RA,CA);
double **R     =            i_mZ(CA,CA);
double **invR  =            i_mZ(CA,CA);
double **Q_T   =            i_mZ(CA,RA);
double **Pinv  =            i_mZ(CA,RA);
double **PinvA =            i_mZ(CA,CA);

  clrscrn();
  printf(" A :");
  p_mZ(A,S5,P2,S5,P2,C7);

  QR_mZ(A,Q,R);    
  printf(" Q :");
  p_mZ(Q,S11,P5,S9,P5,C6);
  printf(" R :");
  p_mZ(R,S11,P5,S9,P5,C6);

  ctranspose_mZ(Q,Q_T);   
  printf(" Q_T :");
  pE_mZ(Q_T,S9,P5,S7,P5,C3);
  inv_mZ(R,invR); 
  printf(" invR :");
  pE_mZ(invR,S9,P5,S7,P5,C6);
  stop();
  
  clrscrn();
  printf(" Copy/Past into the octave window.\n\n");
  p_Octave_mZ(A,"A",P0, P0);
  printf(" format short e\n");
  printf(" pinv(A)\n\n");
    
  mul_mZ(invR,Q_T,Pinv);
  printf(" Pinv = invR * Q_T :");
  pE_mZ(Pinv,S5,P4,S5,P4,C7);  

   printf(" Ide = Pinv * A ");
   mul_mZ(Pinv,A,PinvA); 
     p_mZ(PinvA, S10,P4, S8,P4, C3);  
   stop();   
     
  f_mZ(A);
  f_mZ(Q);
  f_mZ(Q_T);
  f_mZ(R);
  f_mZ(invR);  
  f_mZ(Pinv); 
  f_mZ(PinvA); 
  
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */


Exemple de sortie écran :
 A :
+1.00+5.00i -1.00+5.00i 
+3.00+5.00i +2.00+5.00i 
-2.00+5.00i +4.00+5.00i 

 Q :
   +0.10600 +0.53000i    -0.44678 +0.18932i 
   +0.31800 +0.53000i    -0.21393 +0.24611i 
   -0.21200 +0.53000i    +0.80459 +0.10412i 

 R :
   +9.43398 +0.00000i    +7.63198 -1.59000i 
   +0.00000 +0.00000i    +5.93504 +0.00000i 

 Q_T :
+1.06000e-01-5.29999e-01i +3.17999e-01-5.29999e-01i -2.12000e-01-5.29999e-01i 
-4.46785e-01-1.89316e-01i -2.13927e-01-2.46110e-01i +8.04591e-01-1.04124e-01i 

 invR :
+1.06000e-01+0.00000e+00i -1.36307e-01+2.83973e-02i 
-0.00000e+00+0.00000e+00i +1.68491e-01+0.00000e+00i 

 Press return to continue. 


 Copy/Past into the octave window.

 A=[
+1+5*i,-1+5*i;
+3+5*i,+2+5*i;
-2+5*i,+4+5*i]

 format short e
 pinv(A)

 Pinv = invR * Q_T :
+7.7512e-02-4.3062e-02i +6.9856e-02-2.8708e-02i -1.2919e-01-1.9139e-02i 
-7.5279e-02-3.1898e-02i -3.6045e-02-4.1467e-02i +1.3557e-01-1.7544e-02i 

 Ide = Pinv * A 
   +1.0000 -0.0000i    +0.0000 -0.0000i 
   -0.0000 +0.0000i    +1.0000 +0.0000i 

 Press return to continue.