#include #include #include #include #include "matxop.h" #include "nbmath.h" /* Fonctions de manipulation de matrices et de vecteurs */ /* Resolution de systemes lineaires */ /* R. Ansari Juillet 1993 */ /* LaSilla (Chili) */ #define MXXFLOAT 1.e36 /* Nouvelle-Fonction */ int IVecxVec(int *v1, int *v2, int n) /* Produit scalaire de deux vecteurs entiers */ /* Retour (int) = v1(n) . v2(n) */ { register int i,rc; register int *ip1, *ip2; ip1 = v1; ip2 = v2; rc = 0; /* for(i=0; i -MINPIVOT) ) /* Pivot trop petit */ { pivok = 0; for (k=i+1; k MINPIVOT) || (vt1 < -MINPIVOT) ) { fp2 = mx+k*n; for (j=i; j -MINDETER) ) return(0.0); if (det > MXXFLOAT) det = MXXFLOAT; if (det < -MXXFLOAT) det = -MXXFLOAT; for(i=n-1; i>=0; i--) { fp1 = mx+i*n; six = *(b+i); for (j=i+1; j -DMINPIVOT) ) /* Pivot trop petit */ { pivok = 0; for (k=i+1; k DMINPIVOT) || (vt1 < -DMINPIVOT) ) { fp2 = mx+k*n; for (j=i; j -DMINDETER) ) return(0.0); if (det > MXXFLOAT) det = MXXFLOAT; if (det < -MXXFLOAT) det = -MXXFLOAT; for(i=n-1; i>=0; i--) { fp1 = mx+i*n; six = *(b+i); for (j=i+1; j 0) { printf("GetRFitVect_Erreur: FFBusy= %d \n",FFBusy); return(NULL); } if ((nvar < 1) || (vsz < 1) ) { printf("GetRFitVect_Erreur: NVar,VSz= %d %d \n",nvar,vsz); return(NULL); } if ((nvar > FNVarMax) || (vsz > FVLenMax) || (FFBusy < 0)) { EndRFitLin(); if (nvar > FNVarMax) nvmx = nvar; else nvmx = FNVarMax; if (vsz > FVLenMax) vszmx = vsz; else vszmx = FVLenMax; if (InitRFitLin(nvmx, vszmx) != 0) return(NULL); } FFBusy = 1; return(FVeci); } /* Nouvelle-Fonction */ void FreeRFitVect() { FFBusy = 0; return; } /* Nouvelle-Fonction */ float RFitLin(int nd, int vsz, float *XVar) /* Effectue le fit de Xi2 pour nd inconnu, Taille vecteurs vsz */ /* Les vecteurs doivent etre remplis auparavant */ /* Retourne la valeur du Xi2 du fit, Negatif si Pb. */ { int i,j; register float *ip; register float *fp, *fp2; register double x; register float y; register float *ffmtx, *ffmtx2; float det, rc; if ((nd > FNVarMax) || (vsz > FVLenMax) ) {rc = -1000.0; goto Fin; } /* Fabrication matrice du syteme lineaire a resoudre */ ffmtx = (float *)FFMtx; ffmtx2 = (float *)FFMtx2; for(i=0; i FNVarMax) || (vsz > FVLenMax) ) {rc = -1000.0; goto Fin; } md = nd+1; /* Mise a zero de la matrice de sortie et creation matrice identite */ for(i=0; i= 0.) ? (float)sqrt(y) : -(float)sqrt(-y); XVar[i]= y =FFSort[i*md]; dp2 = FFMtx2+i*nd+i; x += (y * y * *dp2); x -= ( 2.0 * ( y * (double)*(fp+i) ) ); for (j=i+1; j 0) return(NULL); if ( (nvar < 1) || (vsz < 1) ) return(NULL); if ((nvar > DNVarMax) || (vsz > DVLenMax) || (DFBusy < 0)) { EndDFitLin(); if (nvar > DNVarMax) nvmx = nvar; else nvmx = DNVarMax; if (vsz > DVLenMax) vszmx = vsz; else vszmx = DVLenMax; InitDFitLin(nvmx, vszmx); } DFBusy = 1; return(DVeci); } /* Nouvelle-Fonction */ void FreeDFitVect() { DFBusy = 0; return; } /* Nouvelle-Fonction */ double DFitLin(int nd, int vsz, double *XVar) /* Effectue le fit de Xi2 pour nd inconnu, Taille vecteurs vsz */ /* Les vecteurs doivent etre remplis auparavant */ /* Retourne la valeur du Xi2 du fit, Negatif si Pb. */ { int i,j; register double *ip; register double *fp, *fp2; register double x,y; double det,rc; if ((nd > DNVarMax) || (vsz > DVLenMax) ) { rc = -1000.; goto Fin; } /* Impression de debug */ /* for(i=0; i