CouenneRootQ.hpp

Go to the documentation of this file.
00001 /* $Id: CouenneRootQ.hpp 490 2011-01-14 16:07:12Z pbelotti $
00002  *
00003  * Name:    rootQ.hpp
00004  * Author:  Pietro Belotti
00005  * Purpose: find roots of polynomial Q^k(x) (see Liberti and Pantelides, 2003)
00006  *
00007  * (C) Carnegie-Mellon University, 2006-10.
00008  * This file is licensed under the Eclipse Public License (EPL)
00009  */
00010 
00011 #ifndef CouenneRootQ_hpp
00012 #define CouenneRootQ_hpp
00013 
00014 #include "CouenneTypes.hpp"
00015 #include <map>
00016 
00017 namespace Couenne
00018 {
00019 
00022 CouNumber rootQ (int k);
00023 
00024 
00027 
00028 class Qroot {
00029 
00030  protected:
00031 
00033 
00034   static std::map <int, CouNumber> Qmap;
00035 
00036  public:
00037 
00040   Qroot  () {}
00041 
00043   ~Qroot () {}
00044 
00047 
00048   inline CouNumber operator () (int k) {
00049 
00050     std::map <int, CouNumber>:: iterator pos;
00051     CouNumber root;
00052 
00053     k /= 2; // becomes true index
00054 
00055     if ((pos = Qmap.find (k)) == Qmap.end()) {
00056 
00057       std::pair <int, CouNumber> newpair;
00058 
00059       newpair.first  = k;
00060       newpair.second = (root = rootQ (k));
00061  
00062       Qmap.insert (newpair);
00063     }
00064     else 
00065       root = pos -> second;
00066 
00067     return root;
00068   }
00069 };
00070 
00071 }
00072 
00073 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Jan 2015 for Couenne by  doxygen 1.6.1