• Main Page
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

mapquad.h

Go to the documentation of this file.
00001 /// @addtogroup unifexp
00002 /// @{
00003 
00004 /////////////////////////////////////////////////////////////////////////////
00005 ///
00006 /// @file mapquad.h
00007 ///
00008 /// This file contains the definition of the quadratic map f(x)=x^2-a
00009 /// without using interval arithmetic for non-rigorous computations.
00010 ///
00011 /// @author Pawel Pilarczyk
00012 ///
00013 /////////////////////////////////////////////////////////////////////////////
00014 
00015 // Copyright (C) 2007 by Pawel Pilarczyk.
00016 //
00017 // This file is part of my research program package.  This is free software;
00018 // you can redistribute it and/or modify it under the terms of the GNU
00019 // General Public License as published by the Free Software Foundation;
00020 // either version 2 of the License, or (at your option) any later version.
00021 //
00022 // This software is distributed in the hope that it will be useful,
00023 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00024 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00025 // GNU General Public License for more details.
00026 //
00027 // You should have received a copy of the GNU General Public License along
00028 // with this software; see the file "license.txt".  If not, write to the
00029 // Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00030 // MA 02111-1307, USA.
00031 
00032 // Started on March 8, 2007. Last revision: May 1, 2007.
00033 
00034 #ifndef _mapquadr_h_
00035 #define _mapquadr_h_
00036 
00037 #include <string>
00038 #include <iostream>
00039 #include "maptype.h"
00040 #include "chomp/system/textfile.h" // for debugging only
00041 
00042 
00043 namespace unifexp {
00044 
00045 // --------------------------------------------------
00046 // --------------- the quadratic map ----------------
00047 // --------------------------------------------------
00048 
00049 /// This class defines the quadratic map f(x)=x^2-a
00050 /// without using interval arithmetic.
00051 /// It is suitable for non-rigorous computations.
00052 /// See the class "mapQuadrIntv" for a rigorous version which does use
00053 /// interval arithmetic.
00054 /// Valid values of the parameter are between 1+ and 2 (optimal value: 2).
00055 template <class numType>
00056 class mapQuadr: public mapType<numType>
00057 {
00058 public:
00059         /// The constructor.
00060         mapQuadr ();
00061 
00062         /// Returns the name of the object.
00063         std::string name () const;
00064 
00065         /// Returns the number of critical points.
00066         int countCritical () const;
00067 
00068         /// Returns the subsequent critical points.
00069         numType criticalPoint (int n) const;
00070 
00071         /// Returns the left bound of the domain of the map.
00072         numType leftBound () const;
00073 
00074         /// Returns the right bound of the domain of the map.
00075         numType rightBound () const;
00076 
00077         /// Computes an enclosure of the image of the given interval.
00078         void image (const numType &x1, const numType &x2,
00079                 numType &y1, numType &y2) const;
00080 
00081         /// Computes the minimal log of the derivative over those points
00082         /// in the interval [x1,x2] whose images may fall into [y1,y2]
00083         numType minLogDerivative (const numType &x1, const numType &x2,
00084                 const numType &y1, const numType &y2) const;
00085 
00086 }; /* mapQuadr */
00087 
00088 // --------------------------------------------------
00089 
00090 template <class numType>
00091 inline mapQuadr<numType>::mapQuadr ()
00092 {
00093         return;
00094 } /* mapQuadr::mapQuadr */
00095 
00096 template <class numType>
00097 inline std::string mapQuadr<numType>::name () const
00098 {
00099         return std::string ("quadratic");
00100 } /* mapQuadr::name */
00101 
00102 template <class numType>
00103 inline int mapQuadr<numType>::countCritical () const
00104 {
00105         return 1;
00106 } /* mapQuadr::countCritical */
00107 
00108 template <class numType>
00109 inline numType mapQuadr<numType>::criticalPoint (int n) const
00110 {
00111         return 0.0;
00112 } /* mapQuadr::criticalPoint */
00113 
00114 template <class numType>
00115 inline numType mapQuadr<numType>::leftBound () const
00116 {
00117         return -2;
00118 //      return -this -> paramMax;
00119 } /* mapQuadr::leftBound */
00120 
00121 template <class numType>
00122 inline numType mapQuadr<numType>::rightBound () const
00123 {
00124         return 2;
00125 //      return this -> paramMax * this -> paramMax - this -> paramMin;
00126 } /* mapQuadr::rightBound */
00127 
00128 template <class numType>
00129 inline void mapQuadr<numType>::image (const numType &x1, const numType &x2,
00130         numType &y1, numType &y2) const
00131 {
00132         if (x2 < x1)
00133                 throw "Image computation: Wrong interval for 'x'.";
00134         if (x1 > 0)
00135         {
00136                 y1 = x1 * x1 - this -> paramMax;
00137                 y2 = x2 * x2 - this -> paramMin;
00138         }
00139         else if (x2 < 0)
00140         {
00141                 y1 = x2 * x2 - this -> paramMax;
00142                 y2 = x1 * x1 - this -> paramMin;
00143         }
00144         else
00145         {
00146                 y2 = ((-x1 < x2) ? (x2 * x2) : (x1 * x1)) - this -> paramMin;
00147                 y1 = -this -> paramMax;
00148         }
00149         return;
00150 } /* mapQuadr::image */
00151 
00152 template <class numType>
00153 inline numType mapQuadr<numType>::minLogDerivative (const numType &x1,
00154         const numType &x2, const numType &y1, const numType &y2) const
00155 {
00156         // make sure the input data is correct
00157         if (x2 < x1)
00158                 throw "MinLogDerivative: Wrong interval for 'x'.";
00159         if (y2 < y1)
00160                 throw "MinLogDerivative: Wrong interval for 'y'.";
00161 
00162         // compute the positive preimage of the interval [y1,y2],
00163         // intersect the computed preimage with the interval [x1,x2],
00164         // and return the log of the derivative at the minimal endpoint
00165         const numType sum1 = y1 + this -> paramMin;
00166         numType left = (0 < sum1) ? sqrt (sum1) : 0;
00167         if (0 < x1)
00168         {
00169                 return log (2 * ((left > x1) ? left : x1));
00170         }
00171         else if (x2 < 0)
00172         {
00173                 return log (2 * ((left > -x2) ? left : -x2));
00174         }
00175         else
00176         {
00177                 chomp::homology::sbug << "x1 = " << x1 << ", x2 = " << x2 << "\n";
00178                 throw "Log* of interval containing zero.";
00179                 return 0;
00180         }
00181 } /* mapQuadr::minLogDerivative */
00182 
00183 
00184 } // namespace unifexp
00185 
00186 #endif // _mapquadr_h_
00187 
00188 /// @}
00189 

Generated on Sun Feb 3 2013 12:40:31 for The Uniform Expansion Software by  doxygen 1.7.2