DinverCore/BestModels.h
Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 **  This file is part of DinverCore.
00004 **
00005 **  This file may be distributed and/or modified under the terms of the
00006 **  GNU General Public License version 2 or 3 as published by the Free
00007 **  Software Foundation and appearing in the file LICENSE.GPL included
00008 **  in the packaging of this file.
00009 **
00010 **  This file is distributed in the hope that it will be useful, but WITHOUT
00011 **  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 **  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
00013 **  more details.
00014 **
00015 **  You should have received a copy of the GNU General Public License
00016 **  along with this program. If not, see <http://www.gnu.org/licenses/>.
00017 **
00018 **  See http://www.geopsy.org for more information.
00019 **
00020 **  Created : 2009-05-06
00021 **  Authors:
00022 **    Marc Wathelet
00023 **    Marc Wathelet (LGIT, Grenoble, France)
00024 **
00025 ***************************************************************************/
00026 
00027 #ifndef BESTMODELS_H
00028 #define BESTMODELS_H
00029 
00030 #include "DinverCoreDLLExport.h"
00031 #include "ActiveModels.h"
00032 
00033 namespace DinverCore {
00034 
00035 class DINVERCORE_EXPORT BestModels : private IncreaseStorage
00036 {
00037 public:
00038   BestModels(ActiveModels * models);
00039   BestModels(const BestModels& o);
00040   ~BestModels();
00041 
00042   void print();
00043 
00044   void setModels(ActiveModels * models) {_models=models;}
00045   void setNr(int nr);
00046   void update();
00047   void add(int modelIndex);
00048   void setIndex(int bestIndex, int modelIndex) {_indexes[bestIndex]=modelIndex;}
00049   void remove(int modelIndex);
00050   void clear();
00051 
00052   void reserve(int n) {IncreaseStorage::reserve(n);}
00053   int count() const {return size();}
00054   int modelIndex(int bestIndex) const {return _indexes[ bestIndex ];}
00055   const double * misfit(int bestIndex) const {return _models->misfit(_indexes[bestIndex]);}
00056   const int * model(int bestIndex) const {return _models->model(_indexes[bestIndex]);}
00057 
00058   int * activeModelMap() const;
00059 private:
00060   virtual void reallocate();
00061   int indexOf(double m) const;
00062   int exactIndexOf(int modelIndex, double m, int approxIndex) const;
00063   inline void add();
00064 
00065   ActiveModels * _models;
00066   int * _indexes;
00067   int _nrMax, _nr2;
00068 };
00069 
00070 inline void BestModels::add()
00071 {
00072   IncreaseStorage::add();
00073   while(_nr2<size()) _nr2=_nr2 << 1;
00074 }
00075 
00076 } // namespace DinverCore
00077 
00078 #endif // BESTMODELS_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines