Mathc matrices/c15c

Un livre de Wikilivres.
Aller à la navigation Aller à la recherche


Sommaire


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


Crystal Clear mimetype source c.png gj_r3.c
'
/* ------------------------------------ */
/*  Save as :   gj_r3.c                 */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int r)
{
double **A  = i_mR(r,r);
double **b  = i_mR(r,r);
double **Ab = i_Abr_Ac_bc_mR(r,r,r);
/*            i_Abr_Ac_bc_mR(R_Ab,C_A,C_b));  */

 do
  {
   r_mR(A,999.);
   printf(".");
  }while(!det_R(A));


  clrscrn();
  printf(" A :");
  p_mR(A,S8,P0,C4);

  printf("   b : ID :");
  eye_mR(b);
  p_mR(b,S8,P0,C4);
  stop();
  
  
  clrscrn();  
  printf(" Ab :");
  c_A_b_Ab_mR(A,b,Ab);
  p_mR(Ab,S8,P0,C4);
  stop();


  clrscrn();
  printf(" Copy/Past into the octave window.\n\n");
  p_Octave_mR(A,"A",P0);
  printf("format short e\n");
  printf(" inv(A)\n\n");
  printf("  gj_TP_mR(Ab) :");
  gj_TP_mR(Ab);
  pE_mR(Ab,S10,P5,C4);

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

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


} while(stop_w());

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


Nous utilisons la fonction gj_TP_mR(Ab); pour inverser une matrice.


Exemple de sortie écran :
 A :
    +628     +248     -309     -123 
    +608     -607      -23     -881 
    -845     +676     +750     +114 
    +470     -443     -231     +814 

   b : ID :
      +1       +0       +0       +0 
      +0       +1       +0       +0 
      +0       +0       +1       +0 
      +0       +0       +0       +1 

 Press return to continue. 



 Ab :
    +628     +248     -309     -123 
    +608     -607      -23     -881 
    -845     +676     +750     +114 
    +470     -443     -231     +814 

      +1       +0       +0       +0 
      +0       +1       +0       +0 
      +0       +0       +1       +0 
      +0       +0       +0       +1 

 Press return to continue. 



 Copy/Past into the octave window.

 A=[
+628,+248,-309,-123;
+608,-607,-23,-881;
-845,+676,+750,+114;
+470,-443,-231,+814]

format short e
 inv(A)

  gj_TP_mR(Ab) :
+1.00000e+00 -1.11022e-16 +0.00000e+00 +0.00000e+00 
+0.00000e+00 +1.00000e+00 +0.00000e+00 +0.00000e+00 
+0.00000e+00 -5.36351e-17 +1.00000e+00 +0.00000e+00 
+0.00000e+00 +3.44031e-17 +0.00000e+00 +1.00000e+00 

+1.27260e-03 +7.76061e-04 +8.30229e-04 +9.15963e-04 
+1.22644e-03 -4.58494e-04 +3.79117e-04 -3.64007e-04 
+3.24607e-04 +1.33603e-03 +1.88712e-03 +1.23076e-03 
+2.47802e-05 -3.18476e-04 +2.62488e-04 +8.50795e-04 


 Press return to continue
 Press X      to stop