Mathc complexes/c083a
Apparence
Installer et compiler ces fichiers dans votre répertoire de travail.
c01a.c |
---|
/* ------------------------------------ */
/* Save as : c01a.c */
/* ------------------------------------ */
#include "w_a.h"
/* ------------------------------------ */
void fun(int r)
{
double **A = i_mZ(r,r);
double **Inv = i_mZ(r,r);
double **B = r_mZ(i_mZ(r,C1),9.);
double **X = i_mZ(r,C1);
double **T = i_mZ(r,C1);
do
{
r_mZ(A,9.);
printf(".");
}while(!det_Z(A).r);
clrscrn();
printf(" We want to find X such as, \n\n");
printf(" AX = B \n\n");
printf(" If A is a square matrix and, \n\n");
printf(" If A has an inverse matrix, \n\n");
printf(" you can find X by this method\n\n");
printf(" X = inv(A) B \n\n\n");
printf(" To verify the result you can \n\n");
printf(" multiply the matrix A by X. \n\n");
printf(" You must refind B. \n\n");
getchar();
clrscrn();
printf(" A :\n");
p_mZ(A, S5,P0, S4,P0, C6);
printf(" B :\n");
p_mZ(B, S5,P0, S4,P0, C6);
getchar();
clrscrn();
printf(" inv(A) :\n");
pE_mZ(inv_mZ(A,Inv), S1,P3, S1,P4, C3);
printf(" X = inv(A) * B :\n");
p_mZ(mul_mZ(Inv,B,X), S9,P5, S9,P5, C3);
getchar();
clrscrn();
printf(" B :\n");
p_mZ(B, S5,P0, S4,P0, C6);
printf(" AX :\n");
p_mZ(mul_mZ(A,X,T), S5,P0, S4,P0, C6);
f_mZ(T);
f_mZ(X);
f_mZ(B);
f_mZ(Inv);
f_mZ(A);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun(rp_I(RC3)+RC1);
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Nous résolvons un système d'équations, et nous vérifions les calculs. Exemple de sortie écran :
.
We want to find X such as,
AX = B
If A is a square matrix and,
If A has an inverse matrix,
you can find X by this method
X = inv(A) B
To verify the result you can
multiply the matrix A by X.
You must refind B.
--------------------------------------
A :
+6 +2i -1 +8i -1 -9i
+4 +4i +2 -9i -5 +8i
-3 -5i +2 +4i -1 -9i
B :
-1 +6i
-1 -9i
-1 +6i
--------------------------------------
inv(A) :
+5.529e-02-2.6581e-02i +6.721e-02-2.4622e-03i +1.211e-03+6.8008e-02i
-6.161e-02-3.2869e-02i +2.925e-03+1.5333e-01i -3.511e-02+1.6004e-01i
-5.940e-02+2.5681e-02i -1.115e-02+9.0028e-02i -2.009e-02+1.5043e-01i
X = inv(A) * B :
-0.39443 -0.30480i
+0.71072 -0.88711i
-0.15578 -0.64277i
-------------------------------------- Ax = B ?
B :
-1 +6i
-1 -9i
-1 +6i
AX :
-1 +6i
-1 -9i
-1 +6i
Press return to continue
Press X to stop