Aller au contenu

Mathc matrices/e1507

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"
/* ------------------------------------ */
/* ------------------------------------ */
double **xx_gj1_T_mR(
double **Ab
)
{
int r= R1;

    while(r<Ab[R_SIZE][C0])
       {
		printf(" Ab :");
        p_mR(Ab,S12,P4,C8);	
        	   
        if(fabs(pivotbest_gj1Ab_mR(Ab,r))>ERROR_E)  
        
		printf(" Ab : pivot[%d][[%d]  "
		       " The work of pivotbest_gj1Ab_mR(Ab,r);\n",r,r); 
        p_mR(Ab,S12,P4,C8);	
         
          zero_under_pivot_gj1Ab_mR(Ab,r);
          
        printf(" Ab : pivot[%d][[%d]  "
               " The work of  zero_under_pivot_gj1Ab_mR();\n",r,r); 
        p_mR(Ab,S12,P4,C8);	
        stop();
        clrscrn();       
           
        r++;
       } 
                
    //while(r>R1)
    
        //zero_below_pivot_gj1Ab_mR(Ab,--r);
        
return(Ab);
}
/* ------------------------------------ */
/* ------------------------------------ */
double **XX_gj_TP_mR(
double **Ab
)
{
   xx_gj1_T_mR(Ab); 
    
   sort_c_mR(Ab);  
   sort_r_mR(Ab);
  
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_TP_mR(Ab);
  printf("  gj_TP_mR(Ab) :\n");
  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=[
-793,-137,+960,-481,-715,+272;
+390,-825,-967,+38,-157,-11;
-357,-149,+350,+144,-249,+50;
+354,-671,-509,-907,-531,-901;
-819,+94,-37,-633,-11,-787]


 rref(Ab,.00000000001)

 Press return to continue. 



 Ab :
   -793.0000    -137.0000    +960.0000    -481.0000    -715.0000    +272.0000 
   +390.0000    -825.0000    -967.0000     +38.0000    -157.0000     -11.0000 
   -357.0000    -149.0000    +350.0000    +144.0000    -249.0000     +50.0000 
   +354.0000    -671.0000    -509.0000    -907.0000    -531.0000    -901.0000 
   -819.0000     +94.0000     -37.0000    -633.0000     -11.0000    -787.0000 

 Ab : The work of pivotbest_gj1Ab_mR(Ab,r);
   -967.0000    -825.0000    +390.0000     +38.0000    -157.0000     -11.0000 
   +960.0000    -137.0000    -793.0000    -481.0000    -715.0000    +272.0000 
   +350.0000    -149.0000    -357.0000    +144.0000    -249.0000     +50.0000 
   -509.0000    -671.0000    +354.0000    -907.0000    -531.0000    -901.0000 
    -37.0000     +94.0000    -819.0000    -633.0000     -11.0000    -787.0000 

 Ab : pivot[1][[1]
  The work of  zero_under_pivot_gj1Ab_mR();
     +1.0000      +0.8532      -0.4033      -0.0393      +0.1624      +0.0114 
     +0.0000    -956.0279    -405.8232    -443.2751    -870.8635    +261.0796 
     +0.0000    -447.6039    -215.8418    +157.7539    -305.8252     +46.0186 
     +0.0000    -236.7446    +148.7156    -927.0021    -448.3599    -895.2099 
     +0.0000    +125.5667    -833.9224    -634.4540      -4.9928    -786.5791 

 Press return to continue. 



 Ab :
     +1.0000      +0.8532      -0.4033      -0.0393      +0.1624      +0.0114 
     +0.0000    -956.0279    -405.8232    -443.2751    -870.8635    +261.0796 
     +0.0000    -447.6039    -215.8418    +157.7539    -305.8252     +46.0186 
     +0.0000    -236.7446    +148.7156    -927.0021    -448.3599    -895.2099 
     +0.0000    +125.5667    -833.9224    -634.4540      -4.9928    -786.5791 

 Ab : The work of pivotbest_gj1Ab_mR(Ab,r);
     +1.0000      +0.8532      -0.4033      -0.0393      +0.1624      +0.0114 
     +0.0000    -956.0279    -405.8232    -443.2751    -870.8635    +261.0796 
     +0.0000    -447.6039    -215.8418    +157.7539    -305.8252     +46.0186 
     +0.0000    -236.7446    +148.7156    -927.0021    -448.3599    -895.2099 
     +0.0000    +125.5667    -833.9224    -634.4540      -4.9928    -786.5791 

 Ab : pivot[2][[2]
  The work of  zero_under_pivot_gj1Ab_mR();
     +1.0000      +0.8532      -0.4033      -0.0393      +0.1624      +0.0114 
     -0.0000      +1.0000      +0.4245      +0.4637      +0.9109      -0.2731 
     +0.0000      -0.0000     -25.8389    +365.2914    +101.9055     -76.2166 
     +0.0000      -0.0000    +249.2110    -817.2323    -232.7049    -959.8620 
     +0.0000      +0.0000    -887.2241    -692.6747    -119.3738    -752.2884 

 Press return to continue. 



 Ab :
     +1.0000      +0.8532      -0.4033      -0.0393      +0.1624      +0.0114 
     -0.0000      +1.0000      +0.4245      +0.4637      +0.9109      -0.2731 
     +0.0000      -0.0000     -25.8389    +365.2914    +101.9055     -76.2166 
     +0.0000      -0.0000    +249.2110    -817.2323    -232.7049    -959.8620 
     +0.0000      +0.0000    -887.2241    -692.6747    -119.3738    -752.2884 

 Ab : The work of pivotbest_gj1Ab_mR(Ab,r);
     +1.0000      +0.8532      -0.4033      -0.0393      +0.1624      +0.0114 
     -0.0000      +1.0000      +0.4245      +0.4637      +0.9109      -0.2731 
     +0.0000      +0.0000    -887.2241    -692.6747    -119.3738    -752.2884 
     +0.0000      -0.0000    +249.2110    -817.2323    -232.7049    -959.8620 
     +0.0000      -0.0000     -25.8389    +365.2914    +101.9055     -76.2166 

 Ab : pivot[3][[3]
  The work of  zero_under_pivot_gj1Ab_mR();
     +1.0000      +0.8532      -0.4033      -0.0393      +0.1624      +0.0114 
     -0.0000      +1.0000      +0.4245      +0.4637      +0.9109      -0.2731 
     -0.0000      -0.0000      +1.0000      +0.7807      +0.1345      +0.8479 
     +0.0000      -0.0000      +0.0000   -1011.7966    -266.2356   -1171.1711 
     +0.0000      -0.0000      +0.0000    +385.4644    +105.3820     -54.3075 

 Press return to continue. 




 Ab :
     +1.0000      +0.8532      -0.4033      -0.0393      +0.1624      +0.0114 
     -0.0000      +1.0000      +0.4245      +0.4637      +0.9109      -0.2731 
     -0.0000      -0.0000      +1.0000      +0.7807      +0.1345      +0.8479 
     +0.0000      -0.0000      +0.0000   -1011.7966    -266.2356   -1171.1711 
     +0.0000      -0.0000      +0.0000    +385.4644    +105.3820     -54.3075 

 Ab : The work of pivotbest_gj1Ab_mR(Ab,r);
     +1.0000      +0.8532      -0.4033      -0.0393      +0.1624      +0.0114 
     -0.0000      +1.0000      +0.4245      +0.4637      +0.9109      -0.2731 
     -0.0000      -0.0000      +1.0000      +0.7807      +0.1345      +0.8479 
     +0.0000      -0.0000      +0.0000   -1011.7966    -266.2356   -1171.1711 
     +0.0000      -0.0000      +0.0000    +385.4644    +105.3820     -54.3075 

 Ab : pivot[4][[4]
  The work of  zero_under_pivot_gj1Ab_mR();
     +1.0000      +0.8532      -0.4033      -0.0393      +0.1624      +0.0114 
     -0.0000      +1.0000      +0.4245      +0.4637      +0.9109      -0.2731 
     -0.0000      -0.0000      +1.0000      +0.7807      +0.1345      +0.8479 
     -0.0000      +0.0000      -0.0000      +1.0000      +0.2631      +1.1575 
     +0.0000      -0.0000      +0.0000      +0.0000      +3.9542    -500.4888 

 Press return to continue. 



 Ab :
     +1.0000      +0.8532      -0.4033      -0.0393      +0.1624      +0.0114 
     -0.0000      +1.0000      +0.4245      +0.4637      +0.9109      -0.2731 
     -0.0000      -0.0000      +1.0000      +0.7807      +0.1345      +0.8479 
     -0.0000      +0.0000      -0.0000      +1.0000      +0.2631      +1.1575 
     +0.0000      -0.0000      +0.0000      +0.0000      +3.9542    -500.4888 

 Ab : The work of pivotbest_gj1Ab_mR(Ab,r);
     +1.0000      +0.8532      -0.4033      -0.0393      +0.1624      +0.0114 
     -0.0000      +1.0000      +0.4245      +0.4637      +0.9109      -0.2731 
     -0.0000      -0.0000      +1.0000      +0.7807      +0.1345      +0.8479 
     -0.0000      +0.0000      -0.0000      +1.0000      +0.2631      +1.1575 
     +0.0000      -0.0000      +0.0000      +0.0000      +3.9542    -500.4888 

 Ab : pivot[5][[5]
  The work of  zero_under_pivot_gj1Ab_mR();
     +1.0000      +0.8532      -0.4033      -0.0393      +0.1624      +0.0114 
     -0.0000      +1.0000      +0.4245      +0.4637      +0.9109      -0.2731 
     -0.0000      -0.0000      +1.0000      +0.7807      +0.1345      +0.8479 
     -0.0000      +0.0000      -0.0000      +1.0000      +0.2631      +1.1575 
     +0.0000      -0.0000      +0.0000      +0.0000      +1.0000    -126.5720 

 Press return to continue. 



  gj_TP_mR(Ab) :
  +1.00000   -0.00000   +0.00000   +0.00000   +0.00000   -9.02782 
  +0.00000   +1.00000   +0.00000   +0.00000   +0.00000 +102.87684 
  +0.00000   -0.00000   +1.00000   +0.00000   +0.00000  -69.49520 
  -0.00000   +0.00000   -0.00000   +1.00000   +0.00000  +34.46260 
  +0.00000   -0.00000   +0.00000   +0.00000   +1.00000 -126.57198 


 Press return to continue
 Press X      to stop