Mathc complexes/a257
Apparence
Installer et compiler ces fichiers dans votre répertoire de travail.
c05d.c |
---|
/* ------------------------------------ */
/* Save as : c05d.c */
/* ------------------------------------ */
#include "w_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
#define RB R5
#define CB C3
/* ------------------------------------ */
/* ------------------------------------ */
int main(void)
{
double b[RB*(CB*C2)]={
+0.072961373391,-0.506437768240, +1.534334763948,-0.444206008584, +1.663090128755,+0.015021459227,
-1.373390557940,-0.231759656652, -1.263948497854,-0.491416309013, -1.628755364807,-0.959227467811,
+1.000000000000,+0.000000000000, +0.000000000000,+0.000000000000, +0.000000000000,-0.000000000000,
+0.000000000000,+0.000000000000, +1.000000000000,+0.000000000000, +0.000000000000,+0.000000000000,
-0.000000000000,-0.000000000000, -0.000000000000,-0.000000000000, +1.000000000000,-0.000000000000
};
double x[RB*(C1*C2)]={
-1,-3,
2,-4,
-3,-5,
-1,-2,
-2,-3
};
double **B = ca_A_mZ(b,i_mZ(RB,CB));
double **BT = i_mZ(CB,RB);
double **BTB = i_mZ(CB,CB); // BT*B
double **invBTB = i_mZ(CB,CB); // inv(BT*B)
double **invBTB_BT = i_mZ(CB,RB); // inv(BT*B)*BT
double **B_invBTB_BT = i_mZ(RB,RB); // B_inv(BT*B)*BT
double **Id = eye_mZ(i_mZ(RB,RB));
double **V = i_mZ(RB,RB); // V = Id - (B_inv(BT*B)*BT)
double **X = ca_A_mZ(x,i_mZ(RB,C1));
double **VX = i_mZ(RB,C1);
clrscrn();
printf(" B is a basis for the orthogonal complement of A : \n\n"
" Find a transformation matrix for \n"
" a projection onto R%d : \n\n"
" Proj(x) = [Id-(B*inv(BT*B)*BT)] * x \n\n",RB);
printf(" B :");
p_mZ(B,S5,P4,S5,P4,C7);
stop();
clrscrn();
printf(" BT :");
p_mZ(ctranspose_mZ(B,BT),S5,P4,S5,P4,C7);
printf(" BTB :");
p_mZ(mul_mZ(BT,B,BTB),S5,P4,S5,P4,C7);
printf(" inv(BT*B) :");
printf(" inv(BT*B) :");
p_mZ(invgj_mZ(BTB,invBTB),S5,P4,S5,P4,C7);
printf(" inv(BT*B)*BT :");
p_mZ(mul_mZ(invBTB,BT,invBTB_BT),S5,P4,S5,P4,C7);
printf(" B*inv(BT*B)*BT :");
p_mZ(mul_mZ(B,invBTB_BT,B_invBTB_BT),S5,P4,S5,P4,C7);
printf(" V = Id - (B*inv(BT*B)*BT) :");
p_mZ(sub_mZ(Id,B_invBTB_BT,V),S5,P4,S5,P4,C7);
stop();
clrscrn();
printf(" V is transformation matrix for \n"
" a projection onto a subspace R%d :\n\n",RB);
p_mZ(V,S5,P4,S5,P4,C7);
printf(" X :");
p_mZ(X,S5,P1,S5,P1,C7);
printf(" Proj(x) = [Id-(B*inv(BT*B)*BT)] * x \n\n");
printf(" Proj(x) = V * x :");
p_mZ(mul_mZ(V,X,VX),S5,P4,S5,P4,C2);
stop();
f_mZ(B);
f_mZ(BT);
f_mZ(BTB); // BT*B
f_mZ(invBTB); // inv(BT*B)
f_mZ(invBTB_BT); // inv(BT*B)*BT
f_mZ(V); // B*inv(BT*B)*BT
f_mZ(X);
f_mZ(VX);
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Trouver une projection sur un sous-espace vectoriel par une application linéaire :
- B est une base pour le complément orthogonal de A. Trouver une matrice V qui projette un vecteur x sur R4.
Proj(x) = V * x V = Id - (B * inv(BT*B) * BT) .
Exemple de sortie écran :
------------------------------------
B is a basis for the orthogonal complement of A :
Find a transformation matrix for
a projection onto R5 :
Proj(x) = [Id-(B*inv(BT*B)*BT)] * x
B :
+0.0730-0.5064i +1.5343-0.4442i +1.6631+0.0150i
-1.3734-0.2318i -1.2639-0.4914i -1.6288-0.9592i
+1.0000+0.0000i +0.0000+0.0000i +0.0000-0.0000i
+0.0000+0.0000i +1.0000+0.0000i +0.0000+0.0000i
-0.0000-0.0000i -0.0000-0.0000i +1.0000-0.0000i
Press return to continue.
------------------------------------
BT :
+0.0730+0.5064i -1.3734+0.2318i +1.0000-0.0000i +0.0000-0.0000i -0.0000+0.0000i
+1.5343+0.4442i -1.2639+0.4914i +0.0000-0.0000i +1.0000-0.0000i -0.0000+0.0000i
+1.6631-0.0150i -1.6288+0.9592i +0.0000+0.0000i +0.0000-0.0000i +1.0000+0.0000i
BTB :
+3.2017+0.0000i +2.1867+1.1266i +2.5730+1.7833i
+2.1867-1.1266i +5.3906+0.0000i +5.0751+1.1738i
+2.5730-1.7833i +5.0751-1.1738i +7.3391+0.0000i
inv(BT*B) : inv(BT*B) :
+0.5547+0.0000i -0.0400-0.0999i -0.1828-0.0593i
-0.0400+0.0999i +0.6115-0.0000i -0.3845-0.1231i
-0.1828+0.0593i -0.3845+0.1231i +0.5003-0.0000i
inv(BT*B)*BT :
-0.2814+0.0140i -0.3076+0.1564i +0.5547+0.0000i -0.0400-0.0999i -0.1828-0.0593i
+0.2433+0.0597i +0.0034-0.0144i -0.0400+0.0999i +0.6115-0.0000i -0.3845-0.1231i
+0.1441-0.0777i -0.1521+0.0116i -0.1828+0.0593i -0.3845+0.1231i +0.5003-0.0000i
B*inv(BT*B)*BT :
+0.6272+0.0000i -0.1976+0.1606i -0.2814-0.0140i +0.2433-0.0597i +0.1441+0.0777i
-0.1976-0.1606i +0.7063+0.0000i -0.3076-0.1564i +0.0034+0.0144i -0.1521-0.0116i
-0.2814+0.0140i -0.3076+0.1564i +0.5547+0.0000i -0.0400-0.0999i -0.1828-0.0593i
+0.2433+0.0597i +0.0034-0.0144i -0.0400+0.0999i +0.6115-0.0000i -0.3845-0.1231i
+0.1441-0.0777i -0.1521+0.0116i -0.1828+0.0593i -0.3845+0.1231i +0.5003-0.0000i
V = Id - (B*inv(BT*B)*BT) :
+0.3728-0.0000i +0.1976-0.1606i +0.2814+0.0140i -0.2433+0.0597i -0.1441-0.0777i
+0.1976+0.1606i +0.2937-0.0000i +0.3076+0.1564i -0.0034-0.0144i +0.1521+0.0116i
+0.2814-0.0140i +0.3076-0.1564i +0.4453-0.0000i +0.0400+0.0999i +0.1828+0.0593i
-0.2433-0.0597i -0.0034+0.0144i +0.0400-0.0999i +0.3885+0.0000i +0.3845+0.1231i
-0.1441+0.0777i +0.1521-0.0116i +0.1828-0.0593i +0.3845-0.1231i +0.4997+0.0000i
Press return to continue.
------------------------------------
V is transformation matrix for
a projection onto a subspace R5 :
+0.3728-0.0000i +0.1976-0.1606i +0.2814+0.0140i -0.2433+0.0597i -0.1441-0.0777i
+0.1976+0.1606i +0.2937-0.0000i +0.3076+0.1564i -0.0034-0.0144i +0.1521+0.0116i
+0.2814-0.0140i +0.3076-0.1564i +0.4453-0.0000i +0.0400+0.0999i +0.1828+0.0593i
-0.2433-0.0597i -0.0034+0.0144i +0.0400-0.0999i +0.3885+0.0000i +0.3845+0.1231i
-0.1441+0.0777i +0.1521-0.0116i +0.1828-0.0593i +0.3845-0.1231i +0.4997+0.0000i
X :
-1.0 -3.0i
+2.0 -4.0i
-3.0 -5.0i
-1.0 -2.0i
-2.0 -3.0i
Proj(x) = [Id-(B*inv(BT*B)*BT)] * x
Proj(x) = V * x :
-0.9768-2.6649i
+0.4362-4.3941i
-1.6976-5.4468i
-1.2929-1.2455i
-1.8398-3.1581i
Press return to continue.