rootQ.hpp

Go to the documentation of this file.
00001 /* $Id: rootQ.hpp 154 2009-06-16 18:52:53Z 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. 
00008  * This file is licensed under the Common Public License (CPL)
00009  */
00010 
00011 #include "CouenneTypes.hpp"
00012 #include <map>
00013 
00016 CouNumber rootQ (int k);
00017 
00018 
00021 
00022 class Qroot {
00023 
00024  protected:
00025 
00027 
00028   static std::map <int, CouNumber> Qmap;
00029 
00030  public:
00031 
00034   Qroot  () {}
00035 
00037   ~Qroot () {}
00038 
00041 
00042   inline CouNumber operator () (int k) {
00043 
00044     std::map <int, CouNumber>:: iterator pos;
00045     CouNumber root;
00046 
00047     k /= 2; // becomes true index
00048 
00049     if ((pos = Qmap.find (k)) == Qmap.end()) {
00050 
00051       std::pair <int, CouNumber> newpair;
00052 
00053       newpair.first  = k;
00054       newpair.second = (root = rootQ (k));
00055  
00056       Qmap.insert (newpair);
00057     }
00058     else 
00059       root = pos -> second;
00060 
00061     return root;
00062   }
00063 };

Generated on Sun Feb 14 03:02:12 2010 for Couenne by  doxygen 1.4.7