Mathc matrices/029
Apparence
Installer et compiler ces fichiers dans votre répertoire de travail.
c00a.c |
---|
/* ------------------------------------ */
/* Save as : c00a.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define RB R3
/* ------------------------------------ */
int main(void)
{
double b[RB*RB]={
-2.00,+5.00,+9.00,
+6.00,+8.00,+7.00,
+8.00,-9.00,+6.00
};
double **B = ca_A_mR(b, i_mR(RB,RB));
double **B_T = transpose_mR(B, i_mR(RB,RB));
double **U = i_mR(RB,RB);
double **U_T = i_mR(RB,RB);
double **V = i_mR(RB,RB);
double **V_T = i_mR(RB,RB);
double **S = i_mR(RB,RB);
double **T = i_mR(RB,RB);
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\n");
stop();
clrscrn();
svd_U_Rn_mR(B_T,U);
svd_V_Rn_mR(B_T,V);
printf(" U :");
smul_c1_mR(-1.,C1,U);
smul_c1_mR(-1.,C2,U);
p_mR(U, S8,P5,C10);
printf(" V:");
smul_c1_mR(-1.,C1,V);
smul_c1_mR(-1.,C3,V);
p_mR(V, S8,P5,C10);
printf(" S : U_T * B * V");
transpose_mR(U,U_T);
mul_mR(U_T,B,T);
mul_mR(T,V,S);
p_mR(S, S10,P4,C6);
stop();
clrscrn();
printf(" B :");
p_mR(B, S10,P3,C10);
printf(" B = U * S * V_T ");
transpose_mR(V,V_T);
mul_mR(U,S,T);
mul_mR(T,V_T,B);
p_mR(B, S10,P3,C10);
stop();
f_mR(B_T);
f_mR(B);
f_mR(U);
f_mR(U_T);
f_mR(V);
f_mR(V_T);
f_mR(S);
f_mR(T);
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Cet version fonctionne quand le nombre de lignes est supérieur ou égal au nombre de colonnes..
svd_U_Rn_mR(B_T,U); svd_V_Rn_mR(B_T,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=[
-2.00,+5.00,+9.00;
+6.00,+8.00,+7.00;
+8.00,-9.00,+6.00]
[U, S, V] =svd (B,10)
Press return to continue.
U :
-0.59762 +0.22719 +0.76892
-0.77059 +0.10212 -0.62909
-0.22145 -0.96848 +0.11404
V:
-0.34686 -0.56452 -0.74900
-0.47759 +0.79360 -0.37697
-0.80722 -0.22696 +0.54488
S : U_T * B * V
+14.9915 +0.0000 -0.0000
-0.0000 +13.4441 -0.0000
+0.0000 -0.0000 +5.8745
Press return to continue.
B :
-2.000 +5.000 +9.000
+6.000 +8.000 +7.000
+8.000 -9.000 +6.000
B = U * S * V_T
-2.000 +5.000 +9.000
+6.000 +8.000 +7.000
+8.000 -9.000 +6.000
Press return to continue.