Mathc matrices/c12b9
Application
Installer ce fichier dans votre répertoire de travail.
/* Save as : ccn3f.c */
/* ------------------------------------ */
void fun(int r,int c)
double **A = r_mR(i_mR(r,c),9.);
double **U = i_mR(r,r);
double **V = i_mR(c,c);
double **U_T = i_mR(r,r);
double **U_TA = i_mR(r,c);
double **S = i_mR(r,c);
double **S_T = i_mR(c,r);
double **invS_T = i_mR(c,r); 
double **VS_T = i_mR(c,r); /* cc cr VS_T */
double **Pinv = i_mR(c,r); /* cc cr rr VS_TU_T */
double **Ide = i_mR(r,r); /* rc cc cr rr AVS_TU_T */
 clrscrn();
 printf(" Copy/Past into the octave windows \n\n\n");
 p_Octave_mR(A,"A",P2);
 printf("pinv(A)\n\n\n");
 stop();
 clrscrn(); 
 svd_U_Cn_uv_mR(A,U); 
 svd_V_Cn_uv_mR(A,V); 
 transpose_mR( U,U_T);
 /* S = U_T * B * V */ 
 mul_mR(U_T,A,U_TA);
 mul_mR(U_TA,V,S);
 transpose_mR(S,S_T);
 svd_inv_D_uv_mR(S_T,invS_T); 
/* PseudoInverse = V * invS_T * U_T */ 
 mul_mR(V,invS_T,VS_T);
 mul_mR(VS_T,U_T,Pinv);
 printf(" PseudoInverse = V * invS_T * U_T "); 
 pE_mR(Pinv,S10,P6,C10); 
 printf(" Ide = A * PseudoInverse ");
 mul_mR(A,Pinv,Ide); 
 p_mR(Ide,S10,P6,C10); 
 f_mR(A); 
 f_mR(U);
 f_mR(V); 
 f_mR(U_T); 
 f_mR(U_TA);
 f_mR(S); 
 f_mR(S_T);
 f_mR(invS_T);
 f_mR(VS_T);
 f_mR(Pinv); 
 f_mR(Ide); 
/* ------------------------------------ */
int main(void)
time_t t;
 srand(time(&t));
int i;
do
 i = rp_I(R3)+R1;
 fun(i,i+C3);
} while(stop_w());
 return 0;
/* ------------------------------------ */
 Dans cet exemple on vérifie que PseudoInverse = V * invS_T * U_T
 Exemple de sortie écran :
 Copy/Past into the octave windows 
 A=[
+6.00,+6.00,-7.00,+6.00,-1.00,+8.00;
-1.00,-5.00,+2.00,+2.00,-1.00,+6.00;
+8.00,+2.00,-9.00,-1.00,+8.00,+2.00]
pinv(A)
 Press return to continue. 
 PseudoInverse = V * invS_T * U_T 
+9.531179e-03 -6.537687e-04 +3.113016e-02 
+5.162158e-02 -9.532050e-02 -3.529172e-02 
-1.554124e-02 +1.629089e-02 -2.983236e-02 
+4.198733e-02 +8.578984e-03 -2.732446e-02 
-4.187504e-02 +2.320802e-02 +6.432776e-02 
+2.881197e-02 +8.270200e-02 +5.552163e-03 
 Ide = A * PseudoInverse 
 +1.000000 -0.000000 -0.000000 
 +0.000000 +1.000000 -0.000000 
 +0.000000 +0.000000 +1.000000 
 Press return to continue
 Press X to stop

Mathc matrices/c12b10
Application
Installer ce fichier dans votre répertoire de travail.
/* Save as : ccn4.c */
/* ------------------------------------ */
void fun(int r,int c)
double **A = r_mR(i_mR(r,c),9.);
double **A_T = i_mR(c,r);
double **S = i_mR(r,C1);
double **U = i_mR(r,r);
double **V = i_mR(c,c);
 clrscrn(); 
 printf(" Copy/Past into the octave windows \n\n\n");
 p_Octave_mR(A,"A",P2);
 printf(" [U, S, V] =svd (A,10)\n\n\n");
 stop();
 clrscrn(); 
 transpose_mR(A,A_T);
 svd_U_Cn_uv_mR(A,U); 
 svd_V_Cn_uv_mR(A,V); 
 svd_value_uv_mR(A_T,S);
 printf(" U :");
 p_mR(U,S5,P5,C10); 
 printf(" S :");
 p_mR(S,S5,P5,C10);
 printf(" V:");
 p_mR(V,S5,P5,C10); 
 f_mR(A);
 f_mR(A_T); 
 f_mR(S); 
 f_mR(U);
 f_mR(V); 
/* ------------------------------------ */
int main(void)
time_t t;
 srand(time(&t));
int i;
do
 i = rp_I(R3)+R1;
 fun(i,i+C4);
} while(stop_w());
 return 0;
/* ------------------------------------ */
Les quatre dernières colonnes de V ne correspondent pas à celles données par octave.

Exemple de sortie écran :
 Copy/Past into the octave windows 
 A=[
-5.00,+6.00,-3.00,-9.00,-3.00,-3.00,+8.00,-5.00;
+8.00,-5.00,-1.00,+2.00,-5.00,-9.00,-1.00,-1.00;
+8.00,-9.00,+2.00,+2.00,+4.00,-1.00,-7.00,-3.00;
+6.00,-5.00,-3.00,+6.00,-5.00,-1.00,+6.00,-9.00]
 [U, S, V] =svd (A,10)
 Press return to continue. 
 ------------------------------------
 U :
-0.51015 +0.59266 +0.30882 +0.54142 
+0.47129 +0.35875 +0.72091 -0.35983 
+0.60712 -0.21767 +0.09020 +0.75887 
+0.38606 +0.68752 -0.61383 -0.03869 
 S :
+22.26857 
+17.28637 
+9.46701 
+7.25727 
 V:
+0.60598 +0.13250 -0.13328 -0.03487 +0.63299 -0.20266 +0.72381 +0.08430 
-0.57533 +0.01641 -0.05342 +0.21892 +0.00000 +0.00000 +0.61875 +0.00000 
+0.05008 -0.26811 -0.03956 -0.05090 +0.00000 +0.00000 +0.00000 +0.92299 
+0.40705 -0.05361 +0.51127 +0.59345 -0.35738 +0.35185 -0.11970 -0.00337 
-0.01472 -0.45585 +0.11630 -0.46903 +0.00000 +0.67844 -0.00000 +0.00000 
-0.16635 -0.31681 +0.72790 -0.12319 +0.39498 -0.51555 +0.27773 -0.06937 
-0.29126 +0.58030 +0.27091 +0.11755 +0.39274 +0.33025 -0.04220 +0.36900 
-0.14444 -0.51235 -0.31571 +0.58916 +0.40168 +0.00000 -0.00000 -0.00000 
 Press return to continue
 Press X to stop

Mathc matrices/c12b11
Application
Installer ce fichier dans votre répertoire de travail.
/* Save as : ccn4a.c */
/* ------------------------------------ */
void fun(int r,int c)
double **A = r_mR(i_mR(r,c),9.);
double **A_T = i_mR(c,r);
double **S = i_mR(r,C1);
double **U = i_mR(r,r);
double **V = i_mR(c,c);
double **U_T = i_mR(r,r);
double **U_TA = i_mR(r,c); /* rr rc U_TA */
double **S_2 = i_mR(r,c); /* rr rc cc U_TAV */
 clrscrn(); 
 printf(" Copy/Past into the octave windows \n\n\n");
 p_Octave_mR(A,"A",P2);
 printf(" [U, S, V] =svd (A,10)\n\n\n");
 stop();
 clrscrn(); 
 transpose_mR(A,A_T);
 svd_U_Cn_uv_mR(A,U); 
 svd_V_Cn_uv_mR(A,V); 
 svd_value_uv_mR(A_T,S);
 printf(" U :");
 p_mR(U,S5,P5,C10); 
 printf(" S :");
 p_mR(S,S5,P5,C10);
 printf(" V:");
 p_mR(V,S5,P5,C10); 
 stop();
 clrscrn(); 
 transpose_mR( U,U_T);
/* S = U_T * A * V */
 mul_mR(U_T,A,U_TA);
 mul_mR(U_TA,V,S_2);
 printf(" S :");
 p_mR(S,S5,P5,C6);
 printf(" S = U_T * A * V :");
 p_mR(S_2,S10,P5,C6);

f_mR(A);
 f_mR(A_T);
 f_mR(S); 
 f_mR(S_2); 
 f_mR(U);
 f_mR(U_T);
 f_mR(U_TA); 
 f_mR(V); 
/* ------------------------------------ */
int main(void)
time_t t;
 srand(time(&t));
int i;
do
 i = rp_I(R3)+R1;
 fun(i,i+C4);
} while(stop_w());
 return 0;
/* ------------------------------------ */
 Si on ne tient pas compte des signes négatifs cela semble marcher correctement. Les valeurs singulières nulles sont présentes sous la forme de colonnes nulles (S = U_T * A * V :)

Exemple de sortie écran :
 Copy/Past into the octave windows 
 A=[
-3.00,-7.00,+2.00,-7.00,+6.00,-7.00,-5.00;
-5.00,+4.00,-3.00,-7.00,+4.00,-9.00,-3.00;
+2.00,+2.00,-3.00,-9.00,-3.00,+4.00,+6.00]
 [U, S, V] =svd (A,10)
 Press return to continue. 
 ------------------------------------ 
 U :
+0.73163 -0.12649 -0.66986 
+0.66794 +0.32945 +0.66732 
-0.13628 +0.93566 -0.32553 
 S :
+18.67544 
+12.87170 
+8.39923 
 V:
+0.31095 -0.04689 -0.23551 +0.00000 +0.00000 +0.00000 +0.88321 
+0.14577 -0.31655 +0.79856 -0.23909 +0.24120 +0.41109 +0.07647 
+0.00705 +0.31451 -0.28159 +0.00000 +0.00000 +0.89082 -0.00000 
+0.45892 +0.76460 +0.35092 +0.22431 -0.00944 -0.19050 +0.00765 
-0.40001 +0.17465 -0.04444 +0.00000 +0.83911 -0.00000 +0.00000 
+0.62531 -0.12920 -0.31181 -0.53929 +0.48748 +0.03394 -0.46263 
+0.34696 -0.40850 -0.07213 +0.77569 +0.00000 +0.00000 -0.00000 
 Press return to continue. 
 ------------------------------------ 
 S :
+18.67544 
+12.87170 
+8.39923 
 S = U_T * A * V :
 -18.67544 -0.00000 +0.00000 -0.00000 +0.00000 -0.00000 
 +0.00000 -12.87170 +0.00000 +0.00000 +0.00000 -0.00000 
 +0.00000 -0.00000 +8.39923 +0.00000 +0.00000 -0.00000 
 -0.00000 
 -0.00000 
 +0.00000 
 Press return to continue
 Press X to stop