Mathc matrices/c26g
Installer et compiler ces fichiers dans votre répertoire de travail.
cq6.c |
---|
/* ------------------------------------ */
/* Save as : cq6.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define RA R3
#define CA C3
#define CB C3
/* ------------------------------------ */
void fun(void)
{
double **A = r_q_mR(i_mR(RA,CA),99);
double **B = r_mR(i_mR(RA,CB),99.);
double **Ab = i_Abr_Ac_bc_mR(RA,CA,CB);
double **b[CB];
double **a[CA];
int c;
clrscrn();
printf(" A : Orthogonal");
p_mR(A,S9,P4,C6);
printf(" b[C0] b[C1] b[C2] :");
p_mR(B,S9,P1,C6);
printf(" Ab :");
c_A_b_Ab_mR(A,B,Ab);
p_mR(Ab,S9,P4,C6);
printf(" gj_TP_mR(Ab) : x[C0] x[C1] x[C2]");
gj_TP_mR(Ab);
p_mR(Ab,S9,P4,C6);
stop();
/* ------------------------------------ */
/* ------------------------------------ */
for(c=C0; c<CB; c++)
{
b[c] = i_mR(RA,C1);
c_c_mR(B,(c+C1),b[c],C1); }
for(c=C0; c<CA; c++)
{
a[c] = i_mR(RA,C1);
c_c_mR(A,(c+C1),a[c],C1); }
/* ------------------------------------ */
/* ------------------------------------ */
clrscrn();
for(c=C0; c<CA; c++)
{
printf(" a[%d] :",c);
pE_mR(a[c],S12,P4,C6); }
stop();
clrscrn();
for(c=C0; c<CB; c++)
{
printf(" b[%d] :",c);
p_mR(b[c],S12,P4,C6); }
stop();
clrscrn();
printf(" x[C0] :\n");
for(c=C0; c<CA; c++)
printf("%+15.7f <b[C0],a[%d]> / ||a[%d||**2\n",
dot_R(b[C0],a[c])/
dot_R(a[c],a[c]), c,c);
printf("\n x[C1] :\n");
for(c=C0; c<CA; c++)
printf("%+15.7f <b[C0],a[%d]> / ||a[%d||**2\n",
dot_R(b[C1],a[c])/
dot_R(a[c],a[c]), c,c);
printf("\n x[C2] :\n");
for(c=C0; c<CA; c++)
printf("%+15.7f <b[C0],a[%d]> / ||a[%d||**2\n",
dot_R(b[C2],a[c])/
dot_R(a[c],a[c]), c,c);
printf("\n gj_TP_mR(Ab) :\t\t\t x[C0] x[C1] x[C2]");
p_mR(Ab,S12,P7,C6);
/* ------------------------------------ */
/* ------------------------------------ */
for(c=C0; c<CA; c++)
f_mR(a[c]);
for(c=C0; c<CB; c++)
f_mR(b[c]);
/* ------------------------------------ */
/* ------------------------------------ */
f_mR(Ab);
f_mR(B);
f_mR(A);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun();
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Résoudre un système d'équation quand A est une matrice orthogonale : Ici B est composé de trois vecteurs.
Exemple de sortie écran :
--------------------------------
A : Orthogonal
+34.0000 -52.5770 +31.0235
-62.0000 -117.0067 -2.8444
+72.0000 -75.9277 -17.0993
b[C0] b[C1] b[C2] :
+58.0 -40.0 +39.0
-49.0 -42.0 -74.0
-26.0 -3.0 -5.0
Ab :
+34.0000 -52.5770 +31.0235 +58.0000 -40.0000 +39.0000
-62.0000 -117.0067 -2.8444 -49.0000 -42.0000 -74.0000
+72.0000 -75.9277 -17.0993 -26.0000 -3.0000 -5.0000
gj_TP_mR(Ab) : x[C0] x[C1] x[C2]
+1.0000 +0.0000 -0.0000 +0.3081 +0.1009 +0.5454
+0.0000 +1.0000 +0.0000 +0.2096 +0.3261 +0.3145
+0.0000 +0.0000 +1.0000 +1.8871 -0.8474 +1.1924
Press return to continue.
--------------------------------
a[0] :
+3.4000e+01
-6.2000e+01
+7.2000e+01
a[1] :
-5.2577e+01
-1.1701e+02
-7.5928e+01
a[2] :
+3.1023e+01
-2.8444e+00
-1.7099e+01
Press return to continue.
--------------------------------
b[0] :
+58.0000
-49.0000
-26.0000
b[1] :
-40.0000
-42.0000
-3.0000
b[2] :
+39.0000
-74.0000
-5.0000
Press return to continue.
--------------------------------
x[C0] :
+0.3081304 <b[C0],a[0]> / ||a[0||**2
+0.2096309 <b[C0],a[1]> / ||a[1||**2
+1.8871285 <b[C0],a[2]> / ||a[2||**2
x[C1] :
+0.1009427 <b[C0],a[0]> / ||a[0||**2
+0.3260652 <b[C0],a[1]> / ||a[1||**2
-0.8473746 <b[C0],a[2]> / ||a[2||**2
x[C2] :
+0.5453653 <b[C0],a[0]> / ||a[0||**2
+0.3144759 <b[C0],a[1]> / ||a[1||**2
+1.1923792 <b[C0],a[2]> / ||a[2||**2
gj_TP_mR(Ab) : x[C0] x[C1] x[C2]
+1.0000000 +0.0000000 -0.0000000 +0.3081304 +0.1009427 +0.5453653
+0.0000000 +1.0000000 +0.0000000 +0.2096309 +0.3260652 +0.3144759
+0.0000000 +0.0000000 +1.0000000 +1.8871285 -0.8473746 +1.1923792
Press return to continue
Press X to stop