Mathc matrices/c25e
Installer et compiler ces fichiers dans votre répertoire de travail.
c02b.c |
---|
/* ------------------------------------ */
/* Save as : c02b.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
#define RCB RC3
/* ------------------------------------ */
/* ------------------------------------ */
void fun(void)
{
double tx[RCB*C1]={
-7,
-6,
+8
};
double tB[RCB*RCB]={
+0.4819, +0.4615, +0.7448,
+0.6196, -0.7806, +0.0828,
+0.6196, +0.4216, -0.6621
};
double **B = ca_A_mR(tB,i_mR(RCB,RCB));
double **invB = inv_mR(B, i_mR(RCB,RCB));
double **b[RCB];
double **x = ca_A_mR(tx,i_mR(RCB,C1));
double **x_b = i_mR(RCB,C1) ;
int c;
/* ------------------------------------ */
/* ------------------------------------ */
for(c=C0; c<csize_R(B); c++)
{
b[c] = i_mR(RCB,C1);
c_c_mR(B,(c+C1),b[c],C1); }
/* ------------------------------------ */
/* ------------------------------------ */
clrscrn();
printf(" B is the change of basis matrix for the basis \"B\" \n\n"
" B : orthonormal matrix");
p_mR(B,S10,P4,C7);
printf("invB : invB == B_T");
p_mR(invB,S10,P4,C7);
stop();
/* ------------------------------------ */
/* ------------------------------------ */
clrscrn();
printf(" x :");
p_mR(x,S10,P4,C6);
printf(" Compute x in the B basis :\n\n"
" x_b = invB * x :");
p_mR(mul_mR(invB,x,x_b),S10,P4,C7);
stop();
/* ------------------------------------ */
/* ------------------------------------ */
clrscrn();
printf(" x :");
p_mR(x,S10,P4,C6);
printf(" b[0] b[1] ... b[n]\n");
p_mR(B,S10,P4,C7);
printf(" Compute x in the B basis : \n\n"
" x_b : x_b = <b[i],x>\n");
for(c=C0; c<csize_R(B); c++)
printf("%+10.4f <b[%d],x>\n",dot_R(b[c],x),c);
printf("\n\n");
stop();
/* ------------------------------------ */
/* ------------------------------------ */
clrscrn();
printf(" Compute x in the B basis : \n\n"
" x_b : x_b = invB * x");
p_mR(x_b,S10,P4,C6);
printf(" x_b : x_b = <b[i],x>\n");
for(c=C0; c<csize_R(B); c++)
printf("%+10.4f <b[%d],x>\n",dot_R(b[c],x),c);
printf("\n\n");
/* ------------------------------------ */
/* ------------------------------------ */
for(c=C0; c<csize_R(B); c++)
f_mR(b[c]);
f_mR(x);
f_mR(B);
f_mR(invB);
}
/* ------------------------------------ */
int main(void)
{
fun();
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Présentation deux deux algorithmes pour calculer la valeur de x en base b x_b = invB * x x_b = <b[i],x>
Exemple de sortie écran :
--------------------------------
B is the change of basis matrix for the basis "B"
B : orthonormal matrix
+0.4819 +0.4615 +0.7448
+0.6196 -0.7806 +0.0828
+0.6196 +0.4216 -0.6621
invB : invB == B_T
+0.4819 +0.6195 +0.6196
+0.4615 -0.7805 +0.4216
+0.7449 +0.0828 -0.6621
Press return to continue.
--------------------------------
x :
-7.0000
-6.0000
+8.0000
Compute x in the B basis :
x_b = invB * x :
-2.1340
+4.8250
-11.0074
Press return to continue.
--------------------------------
x :
-7.0000
-6.0000
+8.0000
b[0] b[1] ... b[n]
+0.4819 +0.4615 +0.7448
+0.6196 -0.7806 +0.0828
+0.6196 +0.4216 -0.6621
Compute x in the B basis :
x_b : x_b = <b[i],x>
-2.1341 <b[0],x>
+4.8259 <b[1],x>
-11.0072 <b[2],x>
Press return to continue.
--------------------------------
Compute x in the B basis :
x_b : x_b = invB * x
-2.1340
+4.8250
-11.0074
x_b : x_b = <b[i],x>
-2.1341 <b[0],x>
+4.8259 <b[1],x>
-11.0072 <b[2],x>