Mathc matrices/c16d
Installer et compiler ces fichiers dans votre répertoire de travail.
c00a.c |
---|
/* ------------------------------------ */
/* Save as : c00a.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int r,int c)
{
double **B = r_mR( i_mR(r,c),9.);
double **B_T = transpose_mR(B, i_mR(c,r));
double **S = i_mR(c,C1);
double **U = i_mR(r,c);
double **V = i_mR(c,c);
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);
svds_mR(B,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(B_T);
f_mR(B);
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+R2,i);
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Cet version fonctionne quand il y a plus de lignes que 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,+9.00,-5.00,-3.00;
-4.00,+3.00,+6.00,+4.00;
+3.00,-7.00,-2.00,-3.00;
-4.00,+4.00,+2.00,+1.00;
+9.00,-7.00,-1.00,+4.00;
-3.00,+6.00,-8.00,-1.00]
[U, S, V] =svd (B,10)
Press return to continue.
U :
-0.45413 -0.46173 -0.37278 -0.60330
-0.17344 +0.60856 -0.28546 +0.12686
+0.37316 -0.28014 +0.52367 -0.06669
-0.27456 +0.26854 -0.03139 +0.08296
+0.59584 -0.22024 -0.71016 +0.21210
-0.44048 -0.46622 -0.00070 +0.75075
S :
+18.03134
+13.07418
+6.67939
+4.16202
V:
-0.50697 -0.41257 +0.58743 -0.47717
+0.83919 -0.04210 +0.45449 -0.29569
-0.15875 +0.84192 +0.03642 -0.51444
-0.11638 +0.34523 +0.66861 +0.64826
Press return to continue