Mathc matrices/c12an5
Installer et compiler ces fichiers dans votre répertoire de travail.
c00a.c |
---|
/* ------------------------------------ */
/* Save as : c00a.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define RB R5
#define CB C2
/* ------------------------------------ */
int main(void)
{
double b[RB*CB]={
-1.00,-5.00,
-1.00,+6.00,
-2.00,+8.00,
+3.00,+1.00,
+4.00,-5.00
};
double **B = ca_A_mR(b, i_mR(RB,CB));
double **BT = transpose_mR(B, i_mR(CB,RB));
double **U = i_mR(RB,CB);
double **UT = i_mR(CB,RB);
double **UUT = i_mR(RB,RB);
double **UTU = i_mR(CB,CB);
double **V = i_mR(CB,CB);
double **VT = i_mR(CB,CB);
double **VVT = i_mR(CB,CB);
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, S5,P5,C10);
printf(" 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 :");
mul_mR(U,UT,UUT);
p_mR(UUT ,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(UUT);
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=[
-1.00,-5.00;
-1.00,+6.00;
-2.00,+8.00;
+3.00,+1.00;
+4.00,-5.00]
[U, S, V] =svd (B,10)
U*U'
V*V'
U :
+0.36211 +0.47752
-0.47888 -0.11985
-0.65194 -0.02248
-0.01598 -0.67227
+0.46289 -0.55242
V:
+0.25493 -0.96696
-0.96696 -0.25493
Press return to continue.
UT U :
+1.000 -0.000
-0.000 +1.000
U UT :
+0.359 -0.231 -0.247 -0.327 -0.096
-0.231 +0.244 +0.315 +0.088 -0.155
-0.247 +0.315 +0.426 +0.026 -0.289
-0.327 +0.088 +0.026 +0.452 +0.364
-0.096 -0.155 -0.289 +0.364 +0.519
V VT :
+1.000 -0.000
-0.000 +1.000
VT V :
+1.000 -0.000
-0.000 +1.000
Press return to continue.