Mathc matrices/c12b4
Application
Installer ce fichier dans votre répertoire de travail.
/* Save as : ccn3.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+C3);
} while(stop_w());
 return 0;
/* ------------------------------------ */
 Les trois dernières colonnes de V ne correspondent pas à celles données par octave.

Exemple de sortie écran :
 Copy/Past into the octave windows 
 A=[
+8.00,+2.00,-1.00,+8.00,-7.00,+8.00,+2.00;
-5.00,-5.00,-7.00,+6.00,-9.00,-9.00,+8.00;
-9.00,+2.00,-5.00,-5.00,-7.00,+8.00,+6.00;
-7.00,+8.00,+2.00,+8.00,-5.00,-3.00,+8.00]
 [U, S, V] =svd (A,10)
 Press return to continue. 
 ------------------------------------ 
 U :
+0.15236 +0.85847 -0.41399 -0.26160 
+0.68789 -0.41853 -0.28672 -0.51907 
+0.40914 +0.28869 +0.85060 -0.16041 
+0.57982 +0.06724 -0.15127 +0.79775 
 S :
+23.44620 
+15.98080 
+15.19912 
+11.74207 
 V:
+0.42487 +0.36866 +0.55758 -0.30982 -0.20204 +0.44117 +0.35129 
-0.09904 +0.30818 -0.07215 +0.69266 +0.00000 +0.00000 +0.62441 
+0.24966 +0.04770 +0.14044 +0.53591 -0.57263 +0.28786 -0.56534 
-0.33861 +0.21595 +0.69053 +0.16835 +0.44040 -0.44698 -0.28543 
+0.55534 -0.28782 -0.01846 +0.30974 +0.61929 -0.00000 -0.00000 
+0.14665 +0.79735 -0.42945 -0.09349 +0.23194 -0.13574 -0.29263 
-0.55025 +0.03997 -0.05077 +0.06334 +0.00000 +0.71014 +0.00000 
 Press return to continue
 Press X to stop

Mathc matrices/c12b5
Application
Installer ce fichier dans votre répertoire de travail.
/* Save as : ccn3a.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,C10);
 printf(" S = U_T * A * V :");
 p_mR(S_2,S10,P5,C10);

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+C3);
} 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=[
+2.00,+2.00,+2.00,+6.00,+4.00,+6.00,+4.00;
+2.00,-3.00,-9.00,+8.00,-3.00,-9.00,-9.00;
-7.00,-9.00,-3.00,-1.00,-3.00,+6.00,+2.00;
+8.00,-9.00,-1.00,+8.00,+2.00,-3.00,-7.00]
 [U, S, V] =svd (A,10)
 Press return to continue. 
 ------------------------------------ 
 U :
-0.12841 -0.26184 +0.68591 +0.66669 
+0.75678 +0.10231 -0.34789 +0.54386 
-0.10281 +0.95947 +0.23641 +0.11379 
+0.63263 -0.01961 +0.59381 -0.49678 
 S :
+22.64855 
+13.75998 
+12.43346 
+7.00822 
 V:
+0.31073 +0.52269 +0.30334 -0.33527 -0.46718 -0.54520 +0.05036 
-0.32212 +0.67510 -0.40669 +0.44928 -0.12869 -0.08575 -0.25869 
-0.32638 +0.31274 +0.25735 -0.48599 +0.00000 +0.63283 +0.00000 
+0.46130 +0.13582 +0.47021 +0.60829 -0.00520 +0.38370 +0.12133 
-0.05344 +0.31046 +0.34308 -0.04277 +0.80808 +0.00000 -0.00000 
-0.44578 -0.24156 +0.55363 +0.18243 -0.33490 -0.38433 -0.56622 
-0.52801 -0.00640 +0.17620 +0.21076 +0.00000 +0.00000 +0.77150 
 Press return to continue. 
 ------------------------------------ 
 S :
+22.64855 
+13.75998 
+12.43346 
+7.00822 
 U_T * A * V :
 +22.64855 -0.00000 -0.00000 +0.00000 +0.00000 +0.00000 +0.00000 
 -0.00000 -13.75998 -0.00000 +0.00000 +0.00000 +0.00000 -0.00000 
 +0.00000 -0.00000 +12.43346 +0.00000 -0.00000 -0.00000 +0.00000 
 +0.00000 +0.00000 -0.00000 +7.00822 +0.00000 -0.00000 +0.00000 
 Press return to continue
 Press X to stop

Mathc matrices/c12b6
Bibliothèque
Installer ce fichier dans votre répertoire de travail.
/* Save as : vrm.h */
/* ------------------------------------ */
/* positive and negative numbers */
double **r_mR(
double **A,
int n
int r;
int c;
 for (r=R1; r<A[R_SIZE][C0]; r++)
 for (c=C1; c<A[C_SIZE][C0]; c++)
 A[r][c] = r_I(n);
 return(A);
/* ------------------------------------ */
/* positive numbers */
double **rp_mR(
double **A,
int n
int r;
int c;
 for (r=R1; r<A[R_SIZE][C0]; r++)
 for (c=C1; c<A[C_SIZE][C0]; c++)
 A[r][c] = rp_I(n);
 return(A);
/* ------------------------------------ */
/* floating point */
double **rE_mR(
double **A,
int n,
double e
int r;
int c;
 for (r=R1; r<A[R_SIZE][C0]; r++)
 for (c=C1; c<A[C_SIZE][C0]; c++)
 A[r][c] = r_E(n,e);
 return(A);
/* ------------------------------------ */
double **r_Q_mR(
double **Q,
int n
double **T = r_mR( i_mR(Q[R_SIZE][C0]-C1,
 Q[C_SIZE][C0]-C1),n);
 orth_uv_mR(T,Q,YES);
 f_mR(T);
 return(Q); 
/* ------------------------------------ */
double **r_q_mR(
double **Q,
int n
double **T = r_mR( i_mR(Q[R_SIZE][C0]-C1,
 Q[C_SIZE][C0]-C1),n);
 orth_uv_mR(T,Q,NO);
 f_mR(T);
 return(Q); 
/* ------------------------------------ */
 Déclaration des fichiers h.

Mathc matrices/c12an3
Application
Installer et compiler ces fichiers dans votre répertoire de travail.
/* ------------------------------------ */
/* Save as : cgn0e.c */
/* ------------------------------------ */
void fun(int r,int c)
double **B = r_mR(i_mR(c,r),9.);
double **B_T = transpose_mR(B,i_mR(r,c));
double **U_TB = i_mR(r,r); /* rc cr */
double **U = i_mR(c,r);
double **V = i_mR(r,r);
double **V_T = i_mR(r,r);
double **S = i_mR(r,r);
double **U_T = i_mR(r,c);
double **US = i_mR(c,r); /* cr rr */
double **B_2 = i_mR(c,r); /* cr rr rr */
 clrscrn(); 
 svd_U_Rn_uv_mR(B_T,U); 
 svd_V_Rn_uv_mR(B_T,V); 
 /* S = U_T * B * V */
 transpose_mR(U,U_T);
 mul_mR(U_T,B,U_TB);
 mul_mR(U_TB,V,S);
 /* B = U * S * V_T */
 transpose_mR(V,V_T);
 mul_mR(U,S,US);
 mul_mR(US,V_T,B_2);
 printf(" B :");
 p_mR(B ,S10,P3,C10); 
 printf(" B = U * S * V_T ");
 p_mR(B_2,S10,P3,C10); 
 f_mR(B);
 f_mR(B_T); 
 f_mR(U); 
 f_mR(V);
 f_mR(S);
 f_mR(US);
 f_mR(V_T);
 f_mR(U_T);
 f_mR(U_TB);
 f_mR(B_2);
/* ------------------------------------ */
int main(void)
time_t t;
 srand(time(&t));
int i;
do
 i = rp_I(R3)+R3;
 fun(i,i+R0);
} while(stop_w());
 return 0;
/* ------------------------------------ */

Exemple de sortie écran :
 B :
 +2.000 +8.000 -3.000 +6.000 
 -7.000 +4.000 -3.000 -9.000 
 -9.000 +6.000 -3.000 -1.000 
 +4.000 -7.000 -1.000 -3.000 
 B = U * S * V_T 
 +2.000 +8.000 -3.000 +6.000 
 -7.000 +4.000 -3.000 -9.000 
 -9.000 +6.000 -3.000 -1.000 
 +4.000 -7.000 -1.000 -3.000 
 Press return to continue
 Press X to stop