Mathc matrices/c12fn2
Installer et compiler ces fichiers dans votre répertoire de travail.
c00a.c |
---|
/* ------------------------------------ */
/* Save as : c00a.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define FACTOR_E +1.E-5
/* ------------------------------------ */
void fun(int r,int c)
{
double **B = r_mR(i_mR(c,r),99999.);
double **Pinv = i_mR(r,c);
double **PinvB = i_mR(r,r);
clrscrn();
printf(" Copy/Past into the octave windows \n\n\n");
p_Octave_mR(B,"B",P2);
printf("pinv(B)\n\n\n");
stop();
clrscrn();
printf(" Pinv = V * invS_T * U_T ");
Pinv_Rn_mR(B,Pinv,FACTOR_E);
pE_mR(Pinv,S12,P4,C10);
printf(" Ide = PseudoInverse * B ");
mul_mR(Pinv,B,PinvB);
p_mR(PinvB,S10,P6,C10);
f_mR(B);
f_mR(Pinv);
f_mR(PinvB);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
int i;
do
{
i = rp_I(R3)+R1;
fun(i,i+R2);
} 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 :
B=[
-55182.00,-42065.00,+21863.00;
+93423.00,-15249.00,-97375.00;
-82113.00,-91931.00,+80957.00;
+60029.00,+77130.00,+46348.00;
+85963.00,-98747.00,+81371.00]
pinv(B)
Press return to continue.
Pinv = V * invS_T * U_T
-1.7120e-06 +2.5425e-06 -2.0277e-06 +2.4399e-06 +4.1301e-06
-1.4199e-06 -2.9615e-06 -2.5084e-06 +4.4886e-06 -3.2235e-06
-2.5776e-07 -4.4579e-06 +1.5018e-06 +4.5382e-06 +2.9448e-06
Ide = PseudoInverse * B
+1.000000 -0.000000 +0.000000
+0.000000 +1.000000 +0.000000
-0.000000 +0.000000 +1.000000
Press return to continue
Press X return to stop