Mathc matrices/c25j
Installer et compiler ces fichiers dans votre répertoire de travail.
c05a.c |
---|
/* ------------------------------------ */
/* Save as : c05a.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
#define RCQ RC3
/* ------------------------------------ */
/* ------------------------------------ */
void fun(void)
{
double **u = r_mR(i_mR(RCQ,C1) ,9.);
double **v = r_mR(i_mR(RCQ,C1) ,9.);
double **Q = r_Q_mR(i_mR(RCQ,RCQ), 9);
double **Qu = mul_mR(Q,u,i_mR(RCQ,C1));
double **Qv = mul_mR(Q,v,i_mR(RCQ,C1));
clrscrn();
printf(" Cosine of the Angle Between Vectors U and V :\n\n");
printf(" u :");
p_mR(u,S3,P0,C6);
printf(" v :");
p_mR(v,S3,P0,C6);
printf(" <u,v> \n"
" cos(alpha) = ----------- = %+.4f \n"
" ||u|| ||v|| \n\n\n",
dot_R(u,v)
/
( norm_R(u) * norm_R(v) ));
stop();
clrscrn();
printf(" Q :");
p_mR(Q,S3,P4,C6);
stop();
clrscrn();
printf(" Cosine of the Angle Between Vectors U and V :\n\n");
printf(" Qu :");
p_mR(Qu,S3,P4,C6);
printf(" Qv :");
p_mR(Qv,S3,P4,C6);
printf(" <Qu,Qv> \n"
" cos(alpha) = ----------- = %+.4f \n"
" ||u|| ||v|| \n",
dot_R(Qu,Qv)
/
( norm_R(u) * norm_R(v) ));
stop();
clrscrn();
printf(" Cosine of the Angle Between Vectors U and V :\n\n");
printf(" <u,v> \n"
" cos(alpha) = ----------- = %+.4f \n"
" ||u|| ||v|| \n\n\n",
dot_R(u,v)
/
( norm_R(u) * norm_R(v) ));
printf(" <Qu,Qv> \n"
" cos(alpha) = ----------- = %+.4f \n"
" ||u|| ||v|| \n",
dot_R(Qu,Qv)
/
( norm_R(u) * norm_R(v) ));
f_mR(u);
f_mR(v);
f_mR(Qu);
f_mR(Qv);
f_mR(Q);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun();
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Vérifions que multiplier deux vecteurs par une matrice orthonormale ne change pas leurs angles :
Exemple de sortie écran :
--------------------------------
Cosine of the Angle Between Vectors U and V :
u :
-9
-5
-2
-6
+3
+2
v :
-4
+4
+4
+3
-6
-8
<u,v>
cos(alpha) = ----------- = -0.2785
||u|| ||v||
Press return to continue.
--------------------------------
Q :
+0.7526 -0.1921 +0.5607 -0.2189 -0.0255 +0.1837
-0.3763 +0.0961 +0.3184 -0.3585 +0.7090 +0.3415
-0.2822 +0.0338 +0.4022 +0.5563 -0.3333 +0.5805
+0.1881 +0.7165 +0.2848 +0.3980 +0.2593 -0.3802
-0.3763 +0.1725 +0.4706 -0.4767 -0.5056 -0.3525
-0.1881 -0.6400 +0.3464 +0.3584 +0.2504 -0.4938
Press return to continue.
--------------------------------
Cosine of the Angle Between Vectors U and V :
Qu :
-5.3294
+7.2304
-1.6101
-8.2160
+2.2212
+1.8138
Qv :
-3.5096
-4.8984
+1.8978
+5.9324
+8.5014
+3.1015
<Qu,Qv>
cos(alpha) = ----------- = -0.2785
||u|| ||v||
Press return to continue.
--------------------------------
Cosine of the Angle Between Vectors U and V :
<u,v>
cos(alpha) = ----------- = -0.2785
||u|| ||v||
<Qu,Qv>
cos(alpha) = ----------- = -0.2785
||u|| ||v||
Press return to continue
Press X to stop