Mathc matrices/c12ed4
Installer et compiler ces fichiers dans votre répertoire de travail.
cq9.c |
---|
/* ------------------------------------ */
/* Save as : cq9.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
#define RCV RC3
/* ------------------------------------ */
/* ------------------------------------ */
void fun(void)
{
double **V = r_q_mR( i_mR(RCV,RCV), 9);
double **v[RCV];
double **x = r_mR(i_mR(RCV,C1),9.);
int c;
/* ------------------------------------ */
/* ------------------------------------ */
for(c=C0; c<csize_R(V); c++)
{
v[c] = i_mR(RCV,C1);
c_c_mR(V,(c+C1),v[c],C1); }
/* ------------------------------------ */
/* ------------------------------------ */
clrscrn();
printf(" V : orthogonal matrix");
p_mR(V,S10,P4,C7);
printf(" x : in the standard basis");
p_mR(x,S10,P4,C6);
printf(" v[0] v[1] ... v[n]\n");
p_mR(V,S10,P4,C7);
stop();
clrscrn();
printf(" Compute x in the V basis : \n\n"
" x =\n");
for(c=C0; c<csize_R(V); c++)
printf(" + [<x,v[%d]> / ||v[%d]||**2] * v[%d] \n",c,c,c);
printf("\n\n");
printf(" x =");
for(c=C0; c<csize_R(V); c++)
printf(" %+.4f*v[%d]",dot_R(x,v[c]) / dot_R(v[c],v[c]),c);
printf("\n");
/* ------------------------------------ */
/* ------------------------------------ */
for(c=C0; c<csize_R(V); c++)
f_mR(v[c]);
/* ------------------------------------ */
/* ------------------------------------ */
f_mR(x);
f_mR(V);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun();
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Calculer x dans la base orthogonale V : x_V = [c0,c1,c2] avec x = c0*v[0] + c1*v[1] + c2*v[2]
Remarque : x = c0*v[0] + c1*v[1] + c2 v[2] <x,v[0]> / ||v[0]||**2] = <c0*v[0],v[0]> / ||v[0]||**2] + <c1*v[1],v[0]> / ||v[0]||**2] + <c2*v[2],v[0]> / ||v[0]||**2] <x,v[0]> / ||v[0]||**2] = c0 * <v[0],v[0]>/||v[0]||**2] + c1 * <v[1],v[0]>/||v[0]||**2] + c2 * <v[2],v[0]>/||v[0]||**2] <x,v[0]> / ||v[0]||**2] = c0 * 1 + c1 * 0 + c2 * 0 <x,v[0]> / ||v[0]||**2] = c0 <x,v[1]> = ...
Exemple de sortie écran :
--------------------------------
V : orthogonal matrix
-5.0000 +4.5455 +0.6268
+7.0000 +0.0364 +1.1090
-6.0000 -3.7455 +0.7715
x : in the standard basis
+5.0000
+2.0000
+2.0000
v[0] v[1] ... v[n]
-5.0000 +4.5455 +0.6268
+7.0000 +0.0364 +1.1090
-6.0000 -3.7455 +0.7715
Press return to continue.
--------------------------------
Compute x in the V basis :
x =
+ [<x,v[0]> / ||v[0]||**2] * v[0]
+ [<x,v[1]> / ||v[1]||**2] * v[1]
+ [<x,v[2]> / ||v[2]||**2] * v[2]
x = -0.2091*v[0] +0.4413*v[1] +3.1087*v[2]
Press return to continue
Press X to stop