Mathc matrices/Fichiers c : pow r

Un livre de Wikilivres.


Application

Installer et compiler ce fichier dans votre répertoire de travail.

pow.c
/* ------------------------------------ */
/*  Save as :   pow.c                   */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int rc)
{
int    n;
double **A   = r_mR(i_mR(rc,rc),9);
double **A_n =      i_mR(rc,rc);

  for(n=0; n<8; n++)
      {
       clrscrn();
       
       printf(" A : ");
       p_mR(A,S4,P0,C6);
       
       printf(" A^%d :",n);
       p_mR(pow_mR(n,A,A_n),
            S3+n,             /* Try 3 without  */
            P0,
            C6);
       stop();
       }

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

  srand(time(&t));
  
   do{ 
        fun(rp_I(R4));
        clrscrn();
        
     }while(stop_w());
        
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */

Exemple de sortie écran :

 A : 
  -9   +6   -7   +6 
  -3   -3   +6   -9 
  -3   +2   -3   -7 
  +8   -9   +2   -5 

 A^0 :
 +1  +0  +0  +0 
 +0  +1  +0  +0 
 +0  +0  +1  +0 
 +0  +0  +0  +1 

 Press return to continue. 


 A : 
  -9   +6   -7   +6 
  -3   -3   +6   -9 
  -3   +2   -3   -7 
  +8   -9   +2   -5 

 A^1 :
  -9   +6   -7   +6 
  -3   -3   +6   -9 
  -3   +2   -3   -7 
  +8   -9   +2   -5 

 Press return to continue.

 
 A : 
  -9   +6   -7   +6 
  -3   -3   +6   -9 
  -3   +2   -3   -7 
  +8   -9   +2   -5 

 A^2 :
 +132  -140  +132   -89 
  -54   +84   -33   +12 
  -26   +33   +28   +20 
  -91  +124  -126  +140 

 Press return to continue. 


 A : 
  -9   +6   -7   +6 
  -3   -3   +6   -9 
  -3   +2   -3   -7 
  +8   -9   +2   -5 

 A^3 :
 -1876  +2277  -2338  +1573 
  +429   -750  +1005   -909 
  +211   -379   +336   -749 
 +1945  -2430  +2039  -1480 

 Press return to continue. 
 
 ...

A : 
  -9   +6   -7   +6 
  -3   -3   +6   -9 
  -3   +2   -3   -7 
  +8   -9   +2   -5 

 A^7 :
-108884022 +137692401 -141414766  +86929797 
 +39451317  -50284272  +52697229  -33238845 
 +29258499  -37414771  +38287014  -25429477 
+112451177 -142090866 +144256547  -88914410 

 Press return to continue.

Si on n'utilise pas la variable n pour augmenter la taille des colonnes de la matrice, elle n'est plus dessinée correctement.

Exemple de sortie écran sans +n :

A : 
  -5   -1   -3   +4 
  -7   -9   -9   -5 
  -1   -1   -7   -3 
  -9   +2   -1   -3 

 A^0 :
 +1  +0  +0  +0 
 +0  +1  +0  +0 
 +0  +0  +1  +0 
 +0  +0  +0  +1 

 Press return to continue. 


A : 
  -5   -1   -3   +4 
  -7   -9   -9   -5 
  -1   -1   -7   -3 
  -9   +2   -1   -3 

 A^1 :
 -5  -1  -3  +4 
 -7  -9  -9  -5 
 -1  -1  -7  -3 
 -9  +2  -1  -3 

 Press return to continue. 
A : 
  -5   -1   -3   +4 
  -7   -9   -9   -5 
  -1   -1   -7   -3 
  -9   +2   -1   -3 

 A^2 :
 -1 +25 +41 -18 
+152 +87 +170 +59 
+46 +11 +64 +31 
+59 -14 +19 -34 

 Press return to continue. 

 A : 
  -5   -1   -3   +4 
  -7   -9   -9   -5 
  -1   -1   -7   -3 
  -9   +2   -1   -3 

 A^3 :
-49 -301 -491 -198 
-2070 -987 -2488 -514 
-650 -147 -716 -156 
+90 -20 -150 +351 

 Press return to continue. 
A : 
  -5   -1   -3   +4 
  -7   -9   -9   -5 
  -1   -1   -7   -3 
  -9   +2   -1   -3 

 A^7 :
-10047645 -5229733 -14523095 -2209812 
-47844647 -24555505 -67344305 -14370713 
-10653001 -5528045 -15212291 -3541975 
-2196029 -17398 -1128661 +27777 

 Press return to continue.