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

mapquadi.h

Go to the documentation of this file.
00001 /// @addtogroup unifexp
00002 /// @{
00003 
00004 /////////////////////////////////////////////////////////////////////////////
00005 ///
00006 /// @file mapquadi.h
00007 ///
00008 /// This file contains the definition of the quadratic map f(x)=x^2-a
00009 /// with the use of interval arithmetic for 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: February 3, 2013.
00033 
00034 #ifndef _mapquadi_h_
00035 #define _mapquadi_h_
00036 
00037 #include <string>
00038 #include <iostream>
00039 #include "maptype.h"
00040 #include "intvcapd.h"
00041 
00042 
00043 namespace unifexp {
00044 
00045 // --------------------------------------------------
00046 // --------------- the quadratic map ----------------
00047 // ------------ with interval arithmetic ------------
00048 // --------------------------------------------------
00049 
00050 /// This class defines the quadratic map with the use of interval arithmetic.
00051 /// It is suitable for doing rigorous computations.
00052 template <class numType>
00053 class mapQuadrIntv: public mapType<numType>
00054 {
00055 public:
00056         /// The constructor.
00057         mapQuadrIntv ();
00058 
00059         /// Returns the name of the object.
00060         std::string name () const;
00061 
00062         /// Returns the number of critical points.
00063         int countCritical () const;
00064 
00065         /// Returns the subsequent critical points.
00066         numType criticalPoint (int n) const;
00067 
00068         /// Returns the left bound of the domain of the map.
00069         numType leftBound () const;
00070 
00071         /// Returns the right bound of the domain of the map.
00072         numType rightBound () const;
00073 
00074         /// Computes an enclosure of the image of the given interval.
00075         void image (const numType &x1, const numType &x2,
00076                 numType &y1, numType &y2) const;
00077 
00078         /// Computes the minimal log of the derivative over those points
00079         /// in the interval [x1,x2] whose images may fall into [y1,y2]
00080         numType minLogDerivative (const numType &x1, const numType &x2,
00081                 const numType &y1, const numType &y2) const;
00082 
00083 }; /* mapQuadrIntv */
00084 
00085 // --------------------------------------------------
00086 
00087 template <class numType>
00088 mapQuadrIntv<numType>::mapQuadrIntv ()
00089 {
00090         return;
00091 } /* mapQuadrIntv::mapQuadrIntv */
00092 
00093 template <class numType>
00094 std::string mapQuadrIntv<numType>::name () const
00095 {
00096         return std::string ("quadratic-intv");
00097 } /* mapQuadrIntv::name */
00098 
00099 template <class numType>
00100 inline int mapQuadrIntv<numType>::countCritical () const
00101 {
00102         return 1;
00103 } /* mapQuadrIntv::countCritical */
00104 
00105 template <class numType>
00106 inline numType mapQuadrIntv<numType>::criticalPoint (int n) const
00107 {
00108         return 0.0;
00109 } /* mapQuadrIntv::criticalPoint */
00110 
00111 template <class numType>
00112 inline numType mapQuadrIntv<numType>::leftBound () const
00113 {
00114         return -2;
00115 //      return -this -> paramMax;
00116 } /* mapQuadrIntv::leftBound */
00117 
00118 template <class numType>
00119 inline numType mapQuadrIntv<numType>::rightBound () const
00120 {
00121         return 2;
00122 //      numType result = (power (IntervalType (this -> paramMax,
00123 //              this -> paramMax), 2) - this -> paramMin). rightBound ();
00124 //      resetRounding ();
00125 //      return result;
00126 } /* mapQuadrIntv::rightBound */
00127 
00128 template <class numType>
00129 void mapQuadrIntv<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         IntervalType img = power (IntervalType (x1, x2), 2) -
00135                 IntervalType (this -> paramMin, this -> paramMax);
00136         y1 = img. leftBound ();
00137         y2 = img. rightBound ();
00138         resetRounding ();
00139         return;
00140 } /* mapQuadrIntv::image */
00141 
00142 template <class numType>
00143 numType mapQuadrIntv<numType>::minLogDerivative (const numType &x1,
00144         const numType &x2, const numType &y1, const numType &y2) const
00145 {
00146         // make sure the input data is correct
00147         if (x2 < x1)
00148                 throw "MinLogDerivative: Wrong interval for 'x'.";
00149         if (y2 < y1)
00150                 throw "MinLogDerivative: Wrong interval for 'y'.";
00151 
00152         // compute the positive preimage of the interval [y1,y2],
00153         // intersect the computed preimage with the interval [x1,x2],
00154         // and return the log of the derivative at the minimal endpoint
00155         const numType sum1 = (IntervalType (y1, y1) + this -> paramMin).
00156                 leftBound ();
00157         const numType left1 = (0 < sum1) ?
00158                 (sqrt (IntervalType (sum1, sum1))). leftBound () : 0;
00159         numType result;
00160         if (0 < x1)
00161         {
00162                 const numType left = (left1 > x1) ? left1 : x1;
00163                 result = (log (2 * IntervalType (left, left))). leftBound ();
00164         }
00165         else if (x2 < 0)
00166         {
00167                 const numType left = (left1 > -x2) ? left1 : -x2;
00168                 result = (log (2 * IntervalType (left, left))). leftBound ();
00169         }
00170         else
00171         {
00172                 throw "Log of interval containing zero.";
00173                 result = 0;
00174         }
00175         resetRounding ();
00176         return result;
00177 } /* mapQuadrIntv::minLogDerivative */
00178 
00179 
00180 } // namespace unifexp
00181 
00182 #endif // _mapquadi_h_
00183 
00184 /// @}
00185 

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