Mathc complexes/a246
Apparence
Installer et compiler ces fichiers dans votre répertoire de travail.
c03a.c |
---|
/* ------------------------------------ */
/* Save as : c03a.c */
/* ------------------------------------ */
#include "w_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
#define RA R3
#define CA C2
/* ------------------------------------ */
/* ------------------------------------ */
int main(void)
{
double a[RA*(CA*C2)]={
-2,-3, -4,-2,
1, 0, -3,-5,
0, 1, -6,-4,
};
double x[RA*(C1*C2)]={
-1,-3,
2,-4,
-3,-5,
};
double **A = ca_A_mZ(a, i_mZ(RA,CA));
double **AT = i_mZ(CA,RA);
double **ATA = i_mZ(CA,CA); // AT*A
double **invATA = i_mZ(CA,CA); // inv(AT*A)
double **invATA_AT = i_mZ(CA,RA); // inv(AT*A)*AT
double **V = i_mZ(RA,RA); // inv(AT*A)*AT
double **X = ca_A_mZ(x, i_mZ(RA,C1));
double **VX = i_mZ(RA,C1);
clrscrn();
printf(" A is subspace of R%d \n\n"
" Find a transformation matrix for \n"
" a projection onto R%d : \n\n"
" Proj(x) = A * inv(AT*A) * AT * x \n\n",RA,RA);
printf(" A :");
p_mZ(A,S5,P1,S5,P1,C7);
stop();
clrscrn();
printf(" AT :");
p_mZ(ctranspose_mZ(A,AT),S5,P1,S5,P1,C7);
printf(" ATA :");
p_mZ(mul_mZ(AT,A,ATA),S5,P1,S5,P1,C7);
printf(" inv(AT*A) :");
p_mZ(invgj_mZ(ATA,invATA),S5,P4,S5,P4,C7);
printf(" inv(AT*A)*AT :");
p_mZ(mul_mZ(invATA,AT,invATA_AT),S5,P4,S5,P4,C7);
printf(" V = A*inv(AT*A)*AT :");
p_mZ(mul_mZ(A,invATA_AT,V),S5,P4,S5,P4,C7);
stop();
clrscrn();
printf(" V is transformation matrix for \n"
" a projection onto a subspace R%d :\n\n",RA);
p_mZ(V,S5,P4,S5,P4,C7);
printf(" X :");
p_mZ(X,S5,P1,S5,P1,C7);
printf(" Proj(x) = A * inv(AT*A) * AT * x \n\n");
printf(" Proj(x) = V * x :");
p_mZ(mul_mZ(V,X,VX),S5,P4,S5,P4,C7);
stop();
f_mZ(A);
f_mZ(AT);
f_mZ(ATA); // AT*A
f_mZ(invATA); // inv(AT*A)
f_mZ(invATA_AT); // inv(AT*A)*AT
f_mZ(V); // A*inv(AT*A)*AT
f_mZ(X);
f_mZ(VX);
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Trouver une projection sur un sous-espace vectoriel par une application linéaire :
- A est un sous espace de R3. Trouver une matrice V qui projette un vecteur x sur R3.
Proj(x) = V * x V = A * inv(AT*A) * AT
Exemple de sortie écran :
------------------------------------
A is subspace of R3
Find a transformation matrix for
a projection onto R3 :
Proj(x) = A * inv(AT*A) * AT * x
A :
-2.0 -3.0i -4.0 -2.0i
+1.0 +0.0i -3.0 -5.0i
+0.0 +1.0i -6.0 -4.0i
Press return to continue.
------------------------------------
AT :
-2.0 +3.0i +1.0 -0.0i +0.0 -1.0i
-4.0 +2.0i -3.0 +5.0i -6.0 +4.0i
ATA :
+15.0 +0.0i +7.0 -7.0i
+7.0 +7.0i +106.0 +0.0i
inv(AT*A) :
+0.0710+0.0000i -0.0047+0.0047i
-0.0047-0.0047i +0.0101+0.0000i
inv(AT*A)*AT :
-0.1327+0.1850i +0.0617-0.0375i +0.0094-0.1180i
-0.0168+0.0154i -0.0349+0.0456i -0.0650+0.0449i
V = A*inv(AT*A)*AT :
+0.9182+0.0000i -0.0054-0.2225i -0.0228+0.1582i
-0.0054+0.2225i +0.3941+0.0000i +0.4290+0.0724i
-0.0228-0.1582i +0.4290-0.0724i +0.6877-0.0000i
Press return to continue.
------------------------------------
V is transformation matrix for
a projection onto a subspace R3 :
+0.9182+0.0000i -0.0054-0.2225i -0.0228+0.1582i
-0.0054+0.2225i +0.3941+0.0000i +0.4290+0.0724i
-0.0228-0.1582i +0.4290-0.0724i +0.6877-0.0000i
X :
-1.0 -3.0i
+2.0 -4.0i
-3.0 -5.0i
Proj(x) = A * inv(AT*A) * AT * x
Proj(x) = V * x :
-0.9598-3.5389i
+0.5362-4.1448i
-1.9464-5.0724i
Press return to continue.