Mathc complexes/c092b
Installer et compiler ces fichiers dans votre répertoire de travail.
c00a.c |
---|
/* ------------------------------------ */
/* Save as : c00a.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,C3),9999.);
double **X = i_mZ(r,C3);
do
{
r_mZ(A,9999.);
printf(".");
}while(!det_Z(A).r);
clrscrn();
printf(" \n");
printf(" Linear systems with common coefficient matrix.\n\n");
printf(" Ax1=b1 \n");
printf(" Ax2=b2 \n");
printf(" ... \n");
printf(" Axn=bn \n\n");
printf(" We can write these equalities in this maner. \n\n");
printf(" A|x1|x2|...|xn| = b1|b2|...|bn| \n\n");
printf(" or simply : \n\n");
printf(" AX = B \n\n");
printf(" where B = b1|b2|...|bn \n\n");
printf(" and X = x1|x2|...|xn \n\n");
stop();
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");
stop();
clrscrn();
printf(" A :");
p_mZ(A, S6,P0, S6,P0, C6);
printf(" b1 b2 ... bn :");
p_mZ(B, S6,P0, S6,P0, C6);
stop();
clrscrn();
printf(" invgj_mZ(A,Inv) :");
pE_mZ(invgj_mZ(A,Inv), S6,P4, S6,P4, C3);
stop();
clrscrn();
printf(" X = invgj_mZ(A,Inv) * B :\n");
printf(" x1 x2 ... xn :");
p_mZ(mul_mZ(Inv,B,X), S6,P4, S6,P4, C6);
stop();
clrscrn();
printf(" b1 b2 ... bn :");
p_mZ(B, S6,P0, S6,P0, C6);
printf(" Ax1 Ax2 ... Axn :");
p_mZ(mul_mZ(A,X,B), S6,P0, S6,P0, C6);
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(R4)+R1);
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Exemple de sortie écran :
------------------------------------
Linear systems with common coefficient matrix.
Ax1=b1
Ax2=b2
...
Axn=bn
We can write these equalities in this maner.
A|x1|x2|...|xn| = b1|b2|...|bn|
or simply :
AX = B
where B = b1|b2|...|bn
and X = x1|x2|...|xn
Press return to continue.
------------------------------------
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.
Press return to continue.
------------------------------------
A :
+7062 -457i +404 +452i +166+5366i
-9677-9655i +2816-9683i -2553-2409i
+272+3942i +2796+4868i +3814-5081i
b1 b2 ... bn :
-1389+8804i -4597+8290i +2286-8829i
+8046+2278i -3747+1106i -6083-3275i
+850-6925i -4611-4871i -4477 +112i
Press return to continue.
------------------------------------
invgj_mZ(A,Inv) :
+1.737e-05-1.592e-04i -8.611e-05-5.143e-05i -3.902e-05-1.583e-04i
+2.026e-04+2.088e-04i +1.713e-04+5.745e-05i +2.018e-04+1.213e-04i
+1.836e-04-1.737e-04i +4.494e-05-1.083e-04i +1.806e-04-5.427e-05i
Press return to continue.
------------------------------------
X = invgj_mZ(A,Inv) * B :
x1 x2 ... xn :
-0.328-0.100i +1.028+1.893i -0.818+0.782i
+0.139+1.052i -3.707-0.848i +0.536-2.743i
+1.660-0.208i -0.549+2.147i -2.544-1.243i
Press return to continue.
------------------------------------
b1 b2 ... bn :
-1389+8804i -4597+8290i +2286-8829i
+8046+2278i -3747+1106i -6083-3275i
+850-6925i -4611-4871i -4477 +112i
Ax1 Ax2 ... Axn :
-1389+8804i -4597+8290i +2286-8829i
+8046+2278i -3747+1106i -6083-3275i
+850-6925i -4611-4871i -4477 +112i
Press return to continue
Press X to stop