Mathc matrices/c12fn
Apparence
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-4
/* ------------------------------------ */
void fun(int r,int c)
{
double **B = r_mR(i_mR(c,r),9999.);
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+R0);
} 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=[
-5864.00,+2923.00,+9310.00;
-8082.00,+2697.00,+435.00;
+2940.00,+3339.00,-7444.00]
pinv(B)
Press return to continue.
Pinv = V * invS_T * U_T
+5.8041e-05 -1.4247e-04 +6.4264e-05
+1.5875e-04 -4.3890e-05 +1.9597e-04
+9.4128e-05 -7.5954e-05 -2.1051e-05
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