Mathc matrices/c12a6
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 **BT = transpose_mR(B, i_mR(RB,RB));
double **U = i_mR(RB,RB);
double **UT = i_mR(RB,RB);
double **UTU = i_mR(RB,RB);
double **V = i_mR(RB,RB);
double **VT = i_mR(RB,RB);
double **VVT = i_mR(RB,RB);
svd_U_Rn_mR(BT,U);
svd_V_Rn_mR(BT,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 :");
p_mR(U, S8,P5,C10);
printf(" V:");
p_mR(V, S8,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 :");
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 :");
mul_mR(VT,V,VVT);
p_mR(VVT ,S10,P3,C10);
stop();
f_mR(B);
f_mR(BT);
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 lignes est supérieur ou égal au nombre de colonnes..
svd_U_Rn_mR(B_T,U); svd_V_Rn_mR(B_T,V);
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)
U*U'
V*V'
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
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 +1.000 -0.000
+0.000 -0.000 +1.000
VT V :
+1.000 +0.000 +0.000
+0.000 +1.000 -0.000
+0.000 -0.000 +1.000
Press return to continue.