Aller au contenu

Mathc matrices/e1607

Un livre de Wikilivres.


Étude du code


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


gj07.c
/* ------------------------------------ */
/*  Save as :   gj07.c                 */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
void xx_gj3_T_mR(
double **Ab,
int below
)
{
int r= R1;
int c= C1;

   while( (r<Ab[R_SIZE][C0]) &&
           (c<Ab[C_SIZE_A][C0]) )
       {
		printf(" Ab :");
        p_mR(Ab,S12,P4,C8);	
        
        if(pivotbest_gj3Ab_mR(Ab,r,c)>ERROR_E) 
        {
	      printf(" Ab : pivot[%d][[%d]" 
	             " The work of pivotbest_gj3Ab_mR_mR(Ab,r);",r,r);
          p_mR(Ab,S12,P4,C8);
          				
           zero_under_pivot_gj3Ab_mR(Ab,r,c);
           
         printf(" Ab : pivot[%d][[%d]"
                "  The work of  zero_under_pivot_gj1Ab_mR();",r,r); 
         p_mR(Ab,S12,P4,C8);	
         stop();
         clrscrn();
                      
         }  
        else r--;
        
        r++;
        c++;
       }

 r = Ab[R_SIZE][C0];
 
 if(below)
 
 while(r>R1)
  {
   r--;
   c=C1;
   
   while(fabs(Ab[r][c])<ERROR_E  &&  c<(Ab[C_SIZE_A][C0]-C1) ) c++;
         
   if(fabs(Ab[r][c])>ERROR_E)
   
      zero_below_pivot_gj3Ab_mR(Ab,r,c);
  }
}
/* ------------------------------------ */
double **XX_gj_PP_mR(
double **Ab,
int below
)
{
   xx_gj3_T_mR(Ab,below);
  
return(Ab);
}
/* ------------------------------------ */
/* ------------------------------------ */
void fun(int r)
{
double **A  = i_mR(r,r);
double **b  = i_mR(r,C1);
double **Ab = i_Abr_Ac_bc_mR(r,r,C1);
/*            i_Abr_Ac_bc_mR(R_Ab,C_A,C_b));  */

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

  r_mR(b,999.);
  c_A_b_Ab_mR(A,b,Ab);
  
  clrscrn();
  printf(" Copy/Past into the octave window.\n\n");
  p_Octave_mR(Ab,"Ab",P0);
  printf("\n rref(Ab,.00000000001)\n\n");
  stop();

  clrscrn();
  XX_gj_PP_mR(Ab,YES);
  printf("  gj_PP_mR(Ab,YES) :");
  p_mR(Ab,S10,P4,C7);
  
  
  f_mR(Ab);
  f_mR(b);
  f_mR(A);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

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


} while(stop_w());

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


On peut voir la sélection du meilleur pivot. Ensuite on met des zéros sous le pivot.


Exemple de sortie écran :
 ------------------------------------ 
 Copy/Past into the octave window.

 Ab=[
+982,+8,+504,-31,-533,+476;
-793,-131,+84,-387,-825,-517;
-393,-17,+350,+56,+994,-705;
+604,-821,+894,+724,+524,+890;
+108,-455,-217,-919,-343,-691]


 rref(Ab,.00000000001)

 Press return to continue. 



 Ab :
   +982.0000      +8.0000    +504.0000     -31.0000    -533.0000    +476.0000 
   -793.0000    -131.0000     +84.0000    -387.0000    -825.0000    -517.0000 
   -393.0000     -17.0000    +350.0000     +56.0000    +994.0000    -705.0000 
   +604.0000    -821.0000    +894.0000    +724.0000    +524.0000    +890.0000 
   +108.0000    -455.0000    -217.0000    -919.0000    -343.0000    -691.0000 

 Ab : The work of pivotbest_gj3Ab_mR_mR(Ab,r);
   +982.0000      +8.0000    +504.0000     -31.0000    -533.0000    +476.0000 
   -793.0000    -131.0000     +84.0000    -387.0000    -825.0000    -517.0000 
   -393.0000     -17.0000    +350.0000     +56.0000    +994.0000    -705.0000 
   +604.0000    -821.0000    +894.0000    +724.0000    +524.0000    +890.0000 
   +108.0000    -455.0000    -217.0000    -919.0000    -343.0000    -691.0000 

 Ab : pivot[1][[1]
  The work of  zero_under_pivot_gj1Ab_mR();
     +1.0000      +0.0081      +0.5132      -0.0316      -0.5428      +0.4847 
     -0.0000    -124.5397    +490.9980    -412.0336   -1255.4165    -132.6130 
     -0.0000     -13.7984    +551.7026     +43.5937    +780.6914    -514.5031 
     +0.0000    -825.9206    +584.0041    +743.0672    +851.8330    +597.2261 
     +0.0000    -455.8798    -272.4297    -915.5906    -284.3809    -743.3503 

 Press return to continue. 



 Ab :
     +1.0000      +0.0081      +0.5132      -0.0316      -0.5428      +0.4847 
     -0.0000    -124.5397    +490.9980    -412.0336   -1255.4165    -132.6130 
     -0.0000     -13.7984    +551.7026     +43.5937    +780.6914    -514.5031 
     +0.0000    -825.9206    +584.0041    +743.0672    +851.8330    +597.2261 
     +0.0000    -455.8798    -272.4297    -915.5906    -284.3809    -743.3503 

 Ab : The work of pivotbest_gj3Ab_mR_mR(Ab,r);
     +1.0000      +0.0081      +0.5132      -0.0316      -0.5428      +0.4847 
     +0.0000    -825.9206    +584.0041    +743.0672    +851.8330    +597.2261 
     -0.0000     -13.7984    +551.7026     +43.5937    +780.6914    -514.5031 
     -0.0000    -124.5397    +490.9980    -412.0336   -1255.4165    -132.6130 
     +0.0000    -455.8798    -272.4297    -915.5906    -284.3809    -743.3503 

 Ab : pivot[2][[2]
  The work of  zero_under_pivot_gj1Ab_mR();
     +1.0000      +0.0081      +0.5132      -0.0316      -0.5428      +0.4847 
     -0.0000      +1.0000      -0.7071      -0.8997      -1.0314      -0.7231 
     -0.0000      +0.0000    +541.9459     +31.1795    +766.4602    -524.4807 
     -0.0000      +0.0000    +402.9366    -524.0799   -1383.8635    -222.6681 
     -0.0000      +0.0000    -594.7800   -1325.7383    -754.5635   -1072.9986 

 Press return to continue. 



 Ab :
     +1.0000      +0.0081      +0.5132      -0.0316      -0.5428      +0.4847 
     -0.0000      +1.0000      -0.7071      -0.8997      -1.0314      -0.7231 
     -0.0000      +0.0000    +541.9459     +31.1795    +766.4602    -524.4807 
     -0.0000      +0.0000    +402.9366    -524.0799   -1383.8635    -222.6681 
     -0.0000      +0.0000    -594.7800   -1325.7383    -754.5635   -1072.9986 

 Ab : The work of pivotbest_gj3Ab_mR_mR(Ab,r);
     +1.0000      +0.0081      +0.5132      -0.0316      -0.5428      +0.4847 
     -0.0000      +1.0000      -0.7071      -0.8997      -1.0314      -0.7231 
     -0.0000      +0.0000    -594.7800   -1325.7383    -754.5635   -1072.9986 
     -0.0000      +0.0000    +402.9366    -524.0799   -1383.8635    -222.6681 
     -0.0000      +0.0000    +541.9459     +31.1795    +766.4602    -524.4807 

 Ab : pivot[3][[3]
  The work of  zero_under_pivot_gj1Ab_mR();
     +1.0000      +0.0081      +0.5132      -0.0316      -0.5428      +0.4847 
     -0.0000      +1.0000      -0.7071      -0.8997      -1.0314      -0.7231 
     +0.0000      -0.0000      +1.0000      +2.2290      +1.2686      +1.8040 
     -0.0000      +0.0000      +0.0000   -1422.2078   -1895.0462    -949.5763 
     -0.0000      +0.0000      +0.0000   -1176.7939     +78.9243   -1502.1653 

 Press return to continue. 




 Ab :
     +1.0000      +0.0081      +0.5132      -0.0316      -0.5428      +0.4847 
     -0.0000      +1.0000      -0.7071      -0.8997      -1.0314      -0.7231 
     +0.0000      -0.0000      +1.0000      +2.2290      +1.2686      +1.8040 
     -0.0000      +0.0000      +0.0000   -1422.2078   -1895.0462    -949.5763 
     -0.0000      +0.0000      +0.0000   -1176.7939     +78.9243   -1502.1653 

 Ab : The work of pivotbest_gj3Ab_mR_mR(Ab,r);
     +1.0000      +0.0081      +0.5132      -0.0316      -0.5428      +0.4847 
     -0.0000      +1.0000      -0.7071      -0.8997      -1.0314      -0.7231 
     +0.0000      -0.0000      +1.0000      +2.2290      +1.2686      +1.8040 
     -0.0000      +0.0000      +0.0000   -1422.2078   -1895.0462    -949.5763 
     -0.0000      +0.0000      +0.0000   -1176.7939     +78.9243   -1502.1653 

 Ab : pivot[4][[4]
  The work of  zero_under_pivot_gj1Ab_mR();
     +1.0000      +0.0081      +0.5132      -0.0316      -0.5428      +0.4847 
     -0.0000      +1.0000      -0.7071      -0.8997      -1.0314      -0.7231 
     +0.0000      -0.0000      +1.0000      +2.2290      +1.2686      +1.8040 
     +0.0000      -0.0000      -0.0000      +1.0000      +1.3325      +0.6677 
     +0.0000      +0.0000      +0.0000      +0.0000   +1646.9644    -716.4463 

 Press return to continue. 



 Ab :
     +1.0000      +0.0081      +0.5132      -0.0316      -0.5428      +0.4847 
     -0.0000      +1.0000      -0.7071      -0.8997      -1.0314      -0.7231 
     +0.0000      -0.0000      +1.0000      +2.2290      +1.2686      +1.8040 
     +0.0000      -0.0000      -0.0000      +1.0000      +1.3325      +0.6677 
     +0.0000      +0.0000      +0.0000      +0.0000   +1646.9644    -716.4463 

 Ab : The work of pivotbest_gj3Ab_mR_mR(Ab,r);
     +1.0000      +0.0081      +0.5132      -0.0316      -0.5428      +0.4847 
     -0.0000      +1.0000      -0.7071      -0.8997      -1.0314      -0.7231 
     +0.0000      -0.0000      +1.0000      +2.2290      +1.2686      +1.8040 
     +0.0000      -0.0000      -0.0000      +1.0000      +1.3325      +0.6677 
     +0.0000      +0.0000      +0.0000      +0.0000   +1646.9644    -716.4463 

 Ab : pivot[5][[5]
  The work of  zero_under_pivot_gj1Ab_mR();
     +1.0000      +0.0081      +0.5132      -0.0316      -0.5428      +0.4847 
     -0.0000      +1.0000      -0.7071      -0.8997      -1.0314      -0.7231 
     +0.0000      -0.0000      +1.0000      +2.2290      +1.2686      +1.8040 
     +0.0000      -0.0000      -0.0000      +1.0000      +1.3325      +0.6677 
     +0.0000      +0.0000      +0.0000      +0.0000      +1.0000      -0.4350 

 Press return to continue. 



  gj_PP_mR(Ab,YES) :
  +1.00000   +0.00000   +0.00000   +0.00000   +0.00000   +0.50861 
  -0.00000   +1.00000   +0.00000   +0.00000   +0.00000   -0.34960 
  -0.00000   +0.00000   +1.00000   +0.00000   +0.00000   -0.42431 
  +0.00000   -0.00000   -0.00000   +1.00000   +0.00000   +1.24731 
  +0.00000   +0.00000   +0.00000   +0.00000   +1.00000   -0.43501 


 Press return to continue
 Press X      to stop