SundanceFunctorDomain.hpp
Go to the documentation of this file.
00001 /* @HEADER@ */
00002 // ************************************************************************
00003 // 
00004 //                              Sundance
00005 //                 Copyright (2005) Sandia Corporation
00006 // 
00007 // Copyright (year first published) Sandia Corporation.  Under the terms 
00008 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government 
00009 // retains certain rights in this software.
00010 // 
00011 // This library is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Lesser General Public License as
00013 // published by the Free Software Foundation; either version 2.1 of the
00014 // License, or (at your option) any later version.
00015 //  
00016 // This library is distributed in the hope that it will be useful, but
00017 // WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019 // Lesser General Public License for more details.
00020 //                                                                                 
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License along with this library; if not, write to the Free Software
00023 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00024 // USA                                                                                
00025 // Questions? Contact Kevin Long (krlong@sandia.gov), 
00026 // Sandia National Laboratories, Livermore, California, USA
00027 // 
00028 // ************************************************************************
00029 /* @HEADER@ */
00030 
00031 #ifndef SUNDANCE_FUNCTORDOMAIN_H
00032 #define SUNDANCE_FUNCTORDOMAIN_H
00033 
00034 #include "SundanceDefs.hpp"
00035 #include "Teuchos_StrUtils.hpp"
00036 
00037 namespace Sundance
00038 {
00039   using namespace Teuchos;
00040   using std::string;
00041 
00042   class FunctorDomain
00043   {
00044   public:
00045     FunctorDomain();
00046 
00047     virtual ~FunctorDomain(){;}
00048 
00049     virtual bool hasLowerBound() const {return false;}
00050 
00051     virtual double lowerBound() const ;
00052 
00053     virtual bool hasUpperBound() const {return false;}
00054 
00055     virtual double upperBound() const ;
00056 
00057     virtual bool hasExcludedPoint() const {return false;}
00058 
00059     virtual double excludedPoint() const ;
00060 
00061     virtual string description() const = 0 ;
00062   };
00063 
00064   class UnboundedDomain : public FunctorDomain
00065   {
00066   public:
00067     UnboundedDomain();
00068 
00069     string description() const {return "UnboundedDomain()";}
00070   };
00071 
00072 
00073   class PositiveDomain : public FunctorDomain
00074   {
00075   public:
00076     PositiveDomain();
00077 
00078     bool hasLowerBound() const {return true;}
00079     
00080     double lowerBound() const {return 0.0;}
00081     
00082     string description() const {return "PositiveDomain()";}
00083   };
00084 
00085   class StrictlyPositiveDomain : public FunctorDomain
00086   {
00087   public:
00088     StrictlyPositiveDomain();
00089 
00090     bool hasLowerBound() const {return true;}
00091     
00092     double lowerBound() const {return 0.0;}
00093     
00094     bool hasExcludedPoint() const {return true;}
00095     
00096     double excludedPoint() const {return 0.0;}
00097 
00098     string description() const {return "StrictlyPositiveDomain()";}
00099 
00100   };
00101 
00102 
00103   class BoundedDomain : public FunctorDomain
00104   {
00105   public:
00106     BoundedDomain(const double& lower, const double& upper);
00107 
00108     bool hasLowerBound() const {return true;}
00109     
00110     double lowerBound() const {return lower_;}
00111     
00112     bool hasUpperBound() const {return true;}
00113     
00114     double upperBound() const {return upper_;}
00115 
00116     string description() const {return "BoundedDomain("
00117   + Teuchos::toString(lowerBound()) + ", "
00118   + Teuchos::toString(upperBound()) + ")";}
00119 
00120   private:
00121     double lower_;
00122 
00123     double upper_;
00124   };
00125 
00126 
00127   class LowerBoundedDomain : public FunctorDomain
00128   {
00129   public:
00130     LowerBoundedDomain(const double& lower);
00131 
00132      bool hasLowerBound() const {return true;}
00133 
00134      double lowerBound() const {return lower_;}
00135 
00136     string description() const {return "LowerBoundedDomain("
00137   + Teuchos::toString(lowerBound()) + ")";}
00138 
00139 
00140 
00141   private:
00142     double lower_;
00143   };
00144 
00145 class NonzeroDomain : public FunctorDomain
00146   {
00147   public:
00148     NonzeroDomain();
00149 
00150     bool hasExcludedPoint() const {return true;}
00151     
00152     double excludedPoint() const {return 0.0;}
00153 
00154     string description() const {return "NonzeroDomain()";}
00155 
00156 
00157   };
00158 
00159   inline std::ostream& operator<<(std::ostream& os, const FunctorDomain& f)
00160   {
00161     os << f.description();
00162     return os;
00163   }
00164 }
00165 
00166 
00167 
00168 #endif

Site Contact