Mathc matrices/c09a03
Apparence
Installer et compiler ces fichiers dans votre répertoire de travail.
inv03.c |
---|
/* ------------------------------------ */
/* Save as : inv03.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
/* ------------------------------------ */
double **XX_invgj_pivot_mR(
double **Ab
)
{
double pivot = 1.;
int r= R1;
while( pivot &&
(r<Ab[R_SIZE ][C0])
)
{
pivot = pivotbestAId_mR(Ab,r);
if(pivot>ERROR_E)
zero_under_pivot_gj1Ab_mR(Ab,r);
r++;
}
while( (r>R1) )
{
r--;
zero_below_pivot_gj1Ab_mR(Ab,r);
}
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);
XX_invgj_pivot_mR(AID);
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 étudier la fonction invgj_pivot_mR();. Comme cette fonction existe dans la bibliothèque, nous allons l'appeler XX_invgj_pivot_mR(); Exemple de sortie écran :
------------------------------------
Copy/Past into the octave window.
format short e
A=[
-81,-13,+40;
+70,+64,+78;
+64,+76,+54]
inv(A)
-1.0590e-02 +1.6030e-02 -1.5310e-02
+5.1920e-03 -2.9704e-02 +3.9060e-02
+5.2434e-03 +2.2807e-02 -1.8309e-02
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