Mathc matrices/c12an6
Installer et compiler ces fichiers dans votre répertoire de travail.
c00a.c |
---|
/* ------------------------------------ */
/* Save as : c00a.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define RB R3
#define CB C4
/* ------------------------------------ */
int main(void)
{
double b[RB*CB]={
+8.00,-1.00,+5.00,+8.00,
-2.00,+5.00,-9.00,+2.00,
+1.00,+1.00,-8.00,-7.00
};
double **B = ca_A_mR(b, i_mR(RB,CB));
double **U = i_mR(RB,RB);
double **UT = i_mR(RB,RB);
double **UTU = i_mR(RB,RB);
double **V = i_mR(CB,CB);
double **VT = i_mR(CB,CB);
double **VVT = i_mR(CB,CB);
svd_U_Cn_mR(B,U);
svd_V_Cn_mR(B,V);
clrscrn();
printf(" Copy/Past into the octave windows \n\n\n");
p_Octave_mR(B,"B",P2);
printf(" [U, S, V] =svd (B,10)\n\n"
" U*U'\n"
" V*V'\n\n");
printf(" U :");
smul_c1_mR(-1.,C1,U);
smul_c1_mR(-1.,C2,U);
p_mR(U, S5,P5,C10);
printf(" V:");
smul_c1_mR(-1.,C1,V);
smul_c1_mR(-1.,C2,V);
smul_c1_mR(-1.,C4,V);
p_mR(V, S5,P5,C10);
stop();
clrscrn();
printf(" UT U :");
transpose_mR(U,UT);
mul_mR(UT,U,UTU);
p_mR(UTU ,S10,P3,C10);
printf(" U UT :");
transpose_mR(U,UT);
mul_mR(U,UT,UTU);
p_mR(UTU ,S10,P3,C10);
printf(" V VT :");
transpose_mR(V,VT);
mul_mR(V,VT,VVT);
p_mR(VVT ,S10,P3,C10);
printf(" VT V :");
transpose_mR(V,VT);
mul_mR(VT,V,VVT);
p_mR(VVT ,S10,P3,C10);
stop();
f_mR(B);
f_mR(U);
f_mR(UT);
f_mR(UTU);
f_mR(V);
f_mR(VT);
f_mR(VVT);
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Cet version fonctionne quand le nombre de colonnes est strictement supérieur au nombre de lignes..
svd_U_Cn_mR(B,U); svd_V_Cn_mR(B,V);
C'est la fonction "smul_c1_mR(-1.,C1,V);" qui me permet de corriger les signes d'une colonne.
Exemple de sortie écran :
Copy/Past into the octave windows
B=[
+8.00,-1.00,+5.00,+8.00;
-2.00,+5.00,-9.00,+2.00;
+1.00,+1.00,-8.00,-7.00]
[U, S, V] =svd (B,10)
U*U'
V*V'
U :
-0.67160 -0.56757 +0.47626
+0.45704 -0.82328 -0.33663
+0.58316 -0.00841 +0.81232
V:
-0.35017 -0.32418 +0.86431 -0.15893
+0.21733 -0.39733 -0.21986 -0.86403
-0.74511 +0.51816 -0.17750 -0.38053
-0.52436 -0.68450 -0.41609 +0.28876
Press return to continue.
UT U :
+1.000 -0.000 +0.000
-0.000 +1.000 -0.000
+0.000 -0.000 +1.000
U UT :
+1.000 -0.000 +0.000
-0.000 +1.000 +0.000
+0.000 +0.000 +1.000
V VT :
+1.000 +0.000 -0.000 +0.000
+0.000 +1.000 +0.000 +0.000
-0.000 +0.000 +1.000 +0.000
+0.000 +0.000 +0.000 +1.000
VT V :
+1.000 +0.000 +0.000 +0.000
+0.000 +1.000 -0.000 +0.000
+0.000 -0.000 +1.000 +0.000
+0.000 +0.000 +0.000 +1.000
Press return to continue.