Mathc matrices/c09a08
Installer et compiler ces fichiers dans votre répertoire de travail.
inv08.c |
---|
/* ------------------------------------ */
/* Save as : inv08.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
double **xx_sort_c_mR(
double **Ab
)
{
double **T = i_RC_mR(Ab[R_SIZE][C0],Ab[C_SIZE][C0]);
int c;
for(c=C1; c<Ab[C_SIZE][C0]; c++)
c_c_withR0_mR( Ab, c,
T, Ab[R0][c]);
c_withR0_mR(T,Ab);
f_mR(T);
return(Ab);
}
/* ------------------------------------ */
/* ------------------------------------ */
double **XX_invgj_mR(
double **A,
double **invA
)
{
double **ID = i_RC_mR(A[R_SIZE][C0],A[C_SIZE][C0]);
double **AID;
int r = A[R_SIZE][C0];
r--;
AID = i_Abr_Ac_bc_mR(r,r,r);
eye_mR(ID);
c_A_b_Ab_mR(A,ID,AID);
invgj_pivot_mR(AID);
xx_sort_c_mR(AID);
sort_r_mR(AID);
c_Inv_A_mR(AID,invA);
f_mR(AID);
f_mR(ID);
return(invA);
}
/* ------------------------------------ */
/* ------------------------------------ */
void fun(int r)
{
double **A = r_mR( i_mR(r,r), 99.);
double **Inv = i_mR(r,r);
double **AInv = i_mR(r,r);
clrscrn();
XX_invgj_mR(A,Inv);
printf(" Copy/Past into the octave window.\n\n");
printf("format short e\n");
p_Octave_mR(A,"A",P0);
printf(" inv(A)");
pE_mR(Inv,S12,P4,C6);
printf(" A * inv(A)");
mul_mR(A,Inv,AInv);
p_mR(AInv,S12,P4,C6);
f_mR(AInv);
f_mR(Inv);
f_mR(A);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun(rp_I(C2)+C2);
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Nous allons voir une nouvelle fonction, sort_c_mR(); que nous appellerons xx_sort_c_mR(); Exemple de sortie écran :
------------------------------------
Copy/Past into the octave window.
format short e
A=[
-73,+14,-97;
+38,+78,-87;
-43,+94,-39]
inv(A)
-5.2751e-03 +8.8042e-03 -6.5199e-03
-5.3645e-03 +1.3599e-03 +1.0309e-02
-7.1136e-03 -6.4296e-03 +6.3946e-03
A * inv(A)
+1.0000 +0.0000 +0.0000
+0.0000 +1.0000 +0.0000
-0.0000 +0.0000 +1.0000
Press return to continue
Press X to stop