1 //===================================================== 2 // File : size_log.hh 3 // Author : L. Plagne <laurent.plagne (at) edf.fr)> 4 // Copyright (C) EDF R&D, lun sep 30 14:23:17 CEST 2002 5 //===================================================== 6 // 7 // This program is free software; you can redistribute it and/or 8 // modify it under the terms of the GNU General Public License 9 // as published by the Free Software Foundation; either version 2 10 // of the License, or (at your option) any later version. 11 // 12 // This program is distributed in the hope that it will be useful, 13 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 // GNU General Public License for more details. 16 // You should have received a copy of the GNU General Public License 17 // along with this program; if not, write to the Free Software 18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 // 20 #ifndef SIZE_LOG 21 #define SIZE_LOG 22 23 #include "math.h" 24 // The Vector class must satisfy the following part of STL vector concept : 25 // resize() method 26 // [] operator for seting element 27 // the vector element are int compatible. 28 template<class Vector> 29 void size_log(const int nb_point, const int size_min, const int size_max, Vector & X) 30 { 31 X.resize(nb_point); 32 33 float ls_min=log(float(size_min)); 34 float ls_max=log(float(size_max)); 35 36 float ls=0.0; 37 38 float delta_ls=(ls_max-ls_min)/(float(nb_point-1)); 39 40 int size=0; 41 42 for (int i=0;i<nb_point;i++){ 43 44 ls = ls_min + float(i)*delta_ls ; 45 46 size=int(exp(ls)); 47 48 X[i]=size; 49 } 50 51 } 52 53 54 #endif 55