Changeset 3330 in Sophya for trunk/Cosmo/SimLSS/geneutils.cc
- Timestamp:
- Oct 1, 2007, 7:10:50 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cosmo/SimLSS/geneutils.cc
r3329 r3330 55 55 //------------------------------------------------------------------- 56 56 // Classe d'inversion d'une fonction STRICTEMENT MONOTONE CROISSANTE 57 // - Le vecteur y a "Nin" elements y_i tels que "y_i = f(x_i)" 58 // - On a x(i) < x(i+1) et y(i) < y(i+1) 59 // - La classe renvoie ymin=y(0) , ymax=y(Nin -1) 60 // et le vecteur x = f^-1(y) de "Nout" elements 61 // Les y_i sont regulierement espaces et ymin et ymax 62 // La re-interpolation inverse est faite par lineaire 57 // 58 // - On part de deux vecteurs x,y de "Nin" elements tels que "y_i = f[x_i]" 59 // ou la fonction "f" est strictement monotone croissante: 60 // x(i) < x(i+1) et y(i) < y(i+1) 61 // - Le but de la classe est de remplir un vecteur X de "Nout" elements 62 // tels que: X_j = f^-1[Y_j] avec j=[0,Nout[ 63 // avec les Y_j regulierement espaces entre ymin=y(0) , ymax=y(Nin -1) 64 // cad: X_j = f^-1[ ymin+j*(ymax-ymin)/(Nout-1) ] 65 // - La construction du vecteur X est realisee 66 // par interpolation lineaire (ComputeLinear) ou parabolique (ComputeParab) 63 67 InverseFunc::InverseFunc(vector<double>& x,vector<double>& y) 64 68 : _ymin(0.) , _ymax(0.) , _x(x) , _y(y) … … 92 96 } 93 97 94 int InverseFunc::ComputeLinear(long n ,vector<double>& xfcty)98 int InverseFunc::ComputeLinear(long nout,vector<double>& xfcty) 95 99 // Compute table "xfcty" by linear interpolation of "x" versus "y" 96 // on "n " points from "ymin" to "ymax":97 // xfcty[i] = interpolation of function "x" for "ymin+i*(ymax-ymin)/(n -1.)"98 { 99 if(n <3) return -1;100 101 xfcty.resize(n );100 // on "nout" points from "ymin" to "ymax": 101 // xfcty[i] = interpolation of function "x" for "ymin+i*(ymax-ymin)/(nout-1)" 102 { 103 if(nout<3) return -1; 104 105 xfcty.resize(nout); 102 106 103 107 long i1,i2; 104 108 double x; 105 for(int_4 i=0;i<n ;i++) {106 double y = _ymin + i*(_ymax-_ymin)/(n -1.);109 for(int_4 i=0;i<nout;i++) { 110 double y = _ymin + i*(_ymax-_ymin)/(nout-1.); 107 111 find_in_y(y,i1,i2); 108 112 double dy = _y[i2]-_y[i1]; … … 118 122 } 119 123 120 int InverseFunc::ComputeParab(long n ,vector<double>& xfcty)121 { 122 if(n <3) return -1;123 124 xfcty.resize(n );124 int InverseFunc::ComputeParab(long nout,vector<double>& xfcty) 125 { 126 if(nout<3) return -1; 127 128 xfcty.resize(nout); 125 129 126 130 long i1,i2,i3; 127 131 double x; 128 for(int_4 i=0;i<n ;i++) {129 double y = _ymin + i*(_ymax-_ymin)/(n -1.);132 for(int_4 i=0;i<nout;i++) { 133 double y = _ymin + i*(_ymax-_ymin)/(nout-1.); 130 134 find_in_y(y,i1,i2); 131 135 // On cherche le 3ieme point selon la position de y / au 2 premiers
Note:
See TracChangeset
for help on using the changeset viewer.