BWAPI
|
00001 // Copyright (c) 2008 Max-Planck-Institute Saarbruecken (Germany) 00002 // 00003 // This file is part of CGAL (www.cgal.org); you can redistribute it and/or 00004 // modify it under the terms of the GNU Lesser General Public License as 00005 // published by the Free Software Foundation; version 2.1 of the License. 00006 // See the file LICENSE.LGPL distributed with CGAL. 00007 // 00008 // Licensees holding a valid commercial license may use this file in 00009 // accordance with the commercial license agreement provided with the software. 00010 // 00011 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00012 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00013 // 00014 // $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.5-branch/Polynomial/include/CGAL/Polynomial/Cached_extended_euclidean_algorithm.h $ 00015 // $Id: Cached_extended_euclidean_algorithm.h 47300 2008-12-09 10:48:07Z hemmer $ 00016 // 00017 // 00018 // Author(s) : Michael Hemmer <mhemmer@uni-mainz.de> 00019 // 00020 // ============================================================================ 00021 00022 #ifndef CGAL_POLYNOMIAL_CACHED_EXTENDED_EUCLIDEAN_ALGORITHM_H 00023 #define CGAL_POLYNOMIAL_CACHED_EXTENDED_EUCLIDEAN_ALGORITHM_H 00024 00025 #include <CGAL/basic.h> 00026 #include <CGAL/Cache.h> 00027 #include <CGAL/extended_euclidean_algorithm.h> 00028 00029 CGAL_BEGIN_NAMESPACE 00030 namespace CGALi{ 00031 00032 template <class UFD, int i = 0 > 00033 struct Cached_extended_euclidean_algorithm{ 00034 00035 struct Extended_euclidean_algorithm{ 00036 typedef std::pair<UFD,UFD> result_type; 00037 typedef std::pair<UFD,UFD> first_argument_type; 00038 result_type operator()(const first_argument_type& pq){ 00039 result_type result; 00040 CGAL::extended_euclidean_algorithm( 00041 pq.first, pq.second, result.first, result.second); 00042 return result; 00043 } 00044 }; 00045 00046 typedef std::pair<UFD,UFD> PAIR; 00047 typedef Extended_euclidean_algorithm FUNC; 00048 typedef CGAL::Cache<PAIR,PAIR,FUNC> CACHE; 00049 00050 static CACHE cache; 00051 00052 void operator()(const UFD& p, const UFD& q, UFD& s, UFD& t){ 00053 PAIR pq(p,q); 00054 PAIR result = cache(pq); 00055 s = result.first; 00056 t = result.second; 00057 } 00058 }; 00059 00060 template <class UFD, int i> 00061 typename Cached_extended_euclidean_algorithm<UFD,i>::CACHE 00062 Cached_extended_euclidean_algorithm<UFD,i>::cache; 00063 00064 00065 } // namespace CGALi 00066 CGAL_END_NAMESPACE 00067 00068 #endif//CGAL_POLYNOMIAL_CACHED_EXTENDED_EUCLIDEAN_ALGORITHM_H