Mathc complexes/a239
Installer et compiler ces fichiers dans votre répertoire de travail.
c02a.c |
---|
/* ------------------------------------ */
/* Save as : c02a.c */
/* ------------------------------------ */
#include "w_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
#define RCB RC3
/* ------------------------------------ */
/* ------------------------------------ */
void fun(void)
{
double **B = r_Q_mZ( i_mZ(RCB,RCB), 9);
double **invB = inv_mZ(B,i_mZ(RCB,RCB));
double **b[RCB];
double **x = r_mZ(i_mZ(RCB,C1),9.);
double **x_b = i_mZ(RCB,C1) ;
int c;
/* ------------------------------------ */
/* ------------------------------------ */
for(c=C0; c<csize_Z(B); c++)
{
b[c] = i_mZ(RCB,C1);
c_c_mZ(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_mZ(B,S10,P4,S5,P4,C7);
printf("invB : invB == B_T");
p_mZ(invB,S10,P4,S5,P4,C7);
stop();
/* ------------------------------------ */
/* ------------------------------------ */
clrscrn();
printf(" x :");
p_mZ(x,S10,P4,S5,P4,C6);
printf(" Compute x in the B basis :\n\n"
" x_b = invB * x :");
p_mZ(mul_mZ(invB,x,x_b),S10,P4,S5,P4,C7);
stop();
/* ------------------------------------ */
/* ------------------------------------ */
clrscrn();
printf(" x :");
p_mZ(x,S10,P4,S5,P4,C6);
printf(" b[0] b[1] b[2]\n");
p_mZ(B,S10,P4,S5,P4,C7);
printf(" Compute x in the B basis : \n\n"
" x_b : x_b = <b[i],x>\n");
for(c=C0; c<csize_Z(B); c++)
{
p_Z(dot_Z(b[c],x),S10,P4,S5,P4);
printf(" <b[%d],x>\n",c); }
printf("\n\n");
stop();
/* ------------------------------------ */
/* ------------------------------------ */
clrscrn();
printf(" Compute x in the B basis : \n\n"
" x_b : x_b = invB * x");
p_mZ(x_b,S10,P4,S5,P4,C6);
printf(" x_b : x_b = <b[i],x>\n");
for(c=C0; c<csize_Z(B); c++)
{
p_Z(dot_Z(b[c],x),S10,P4,S5,P4);
printf(" <b[%d],x>\n",c); }
printf("\n\n");
/* ------------------------------------ */
/* ------------------------------------ */
for(c=C0; c<csize_Z(B); c++)
f_mZ(b[c]);
f_mZ(x);
f_mZ(B);
f_mZ(invB);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun();
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Exemple de sortie écran :
------------------------------------
B is the change of basis matrix for the basis "B"
B : orthonormal matrix
+0.1672 +0.0836i +0.6660 +0.4055i -0.5575 +0.2149i
+0.6690 +0.2509i -0.3319 -0.3917i -0.4701 -0.0704i
-0.5854 -0.3345i -0.1027 -0.3434i -0.6376 -0.1023i
invB : invB == B_T
+0.1672 -0.0836i +0.6690 -0.2509i -0.5854 +0.3345i
+0.6660 -0.4055i -0.3319 +0.3917i -0.1027 +0.3434i
-0.5575 -0.2149i -0.4701 +0.0704i -0.6376 +0.1023i
Press return to continue.
------------------------------------
x :
-4.0000 +8.0000i
+3.0000 +9.0000i
-6.0000 -3.0000i
Compute x in the B basis :
x_b = invB * x :
+8.7805 +6.6899i
-2.2948 +3.3862i
+6.0380 -6.3211i
Press return to continue.
------------------------------------
x :
-4.0000 +8.0000i
+3.0000 +9.0000i
-6.0000 -3.0000i
b[1] b[2] ... b[n]
+0.1672 +0.0836i +0.6660 +0.4055i -0.5575 +0.2149i
+0.6690 +0.2509i -0.3319 -0.3917i -0.4701 -0.0704i
-0.5854 -0.3345i -0.1027 -0.3434i -0.6376 -0.1023i
Compute x in the B basis :
x_b : x_b = <b[i],x>
+8.7805 -6.6899i <b[0],x>
-2.2948 -3.3862i <b[1],x>
+6.0380 +6.3211i <b[2],x>
Press return to continue.
------------------------------------
Compute x in the B basis :
x_b : x_b = invB * x
+8.7805 +6.6899i
-2.2948 +3.3862i
+6.0380 -6.3211i
x_b : x_b = <b[i],x>
+8.7805 -6.6899i <b[0],x>
-2.2948 -3.3862i <b[1],x>
+6.0380 +6.3211i <b[2],x>
Press return to continue
Press X return to stop