Aller au contenu

Mathc matrices/c23r

Un livre de Wikilivres.


Application


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


c00a.c
/* ------------------------------------ */
/*  Save as :   c00a.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define RA       R4
#define CA       C6
#define Cb       C1
/* ------------------------------------ */
#define CbFREE   Cb+C3                
/* ------------------------------------ */
#define Cx       C3
#define Cy       C4
/* ------------------------------------ */
int main(void)
{
double ab[RA*(CA+Cb)]={
    +1,      3,     -2,      0,    +2,    +0,    0,
    +2,      6,     -5,     -2,    +4,    -3,    0,
     0,      0,     +5,     10,     0,    15,    0, 
     2,      6,      0,      8,     4,    18,    0,  
};

double **Ab =   ca_A_mR(ab, i_Abr_Ac_bc_mR(RA,CA,Cb));
double **A  = c_Ab_A_mR(Ab,           i_mR(RA,CA));
double **b  = c_Ab_b_mR(Ab,           i_mR(RA,Cb));

double **Ab_free =          i_Abr_Ac_bc_mR(CA,CA,CbFREE);
double **b_free  =                    i_mR(CA,CbFREE); 

double **cx        = i_mR(CA,C1);
double **cy        = i_mR(CA,C1);
double **cxplscy   = i_mR(CA,C1);
double **A_cxplscy = i_mR(RA,C1) ;

int r;

  clrscrn();
  printf(" Verify if the sum of two columns of b_free\n"
         " is orthogonal to A :\n\n");
  printf(" A :");
  p_mR(A,S6,P1,C10);
  printf(" b :");
  p_mR(b,S6,P1,C10);
  printf(" Ab :");
  p_mR(Ab,S6,P1,C10);
  stop();

  gj_PP_mR(Ab,NO);  
  
  put_zeroR_mR(Ab,Ab_free);   
  put_freeV_mR(Ab_free);
  
  r = rsize_R(Ab_free);
  while(r>R1)    
        zero_below_pivot_gj1Ab_mR(Ab_free,r--);
        
  clrscrn();
  c_Ab_b_mR(Ab_free,b_free);
  printf(" b_free :"); 
  p_mR(b_free,S10,P3,C7);
  c_c_mR(b_free,Cx,cx,C1);
  c_c_mR(b_free,Cy,cy,C1);
  printf(" C%d + C%d :",Cx,Cy);  
  p_mR(add_mR(cx,cy,cxplscy),S10,P3,C7);
  printf(" A * (C%d+C%d) :",Cx,Cy);   
  p_mR(mul_mR(A,cxplscy,A_cxplscy),S10,P3,C7);
  stop();	
  
  f_mR(Ab);
  f_mR(A);   
  f_mR(b);
 
  f_mR(Ab_free);
  f_mR(b_free);

  f_mR(cx); 
  f_mR(cy);
  f_mR(cxplscy);
  f_mR(A_cxplscy);

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


On peut sélectionner les colonnes de travail dans le code ci-dessous.

#define Cx     C3
#define Cy     C4


Exemple de sortie écran :
 Verify if the sum of two columns of b_free
 is orthogonal to A :

 A :
  +1.0   +3.0   -2.0   +0.0   +2.0   +0.0 
  +2.0   +6.0   -5.0   -2.0   +4.0   -3.0 
  +0.0   +0.0   +5.0  +10.0   +0.0  +15.0 
  +2.0   +6.0   +0.0   +8.0   +4.0  +18.0 

 b :
  +0.0 
  +0.0 
  +0.0 
  +0.0 

 Ab :
  +1.0   +3.0   -2.0   +0.0   +2.0   +0.0   +0.0 
  +2.0   +6.0   -5.0   -2.0   +4.0   -3.0   +0.0 
  +0.0   +0.0   +5.0  +10.0   +0.0  +15.0   +0.0 
  +2.0   +6.0   +0.0   +8.0   +4.0  +18.0   +0.0 

 Press return to continue. 


 b_free :
    +0.000     -3.000     -4.000     -2.000 
    +0.000     +1.000     +0.000     +0.000 
    +0.000     +0.000     -2.000     +0.000 
    +0.000     +0.000     +1.000     +0.000 
    +0.000     +0.000     +0.000     +1.000 
    +0.000     +0.000     +0.000     +0.000 

 C3 + C4 :
    -6.000 
    +0.000 
    -2.000 
    +1.000 
    +1.000 
    +0.000 

 A * (C3+C4) :
    +0.000 
    +0.000 
    +0.000 
    +0.000 

 Press return to continue.