|
GlobiPack Package Browser (Single Doxygen Collection) Version of the Day
|
00001 /* 00002 // @HEADER 00003 // *********************************************************************** 00004 // 00005 // GlobiPack: Collection of Scalar 1D globalizaton utilities 00006 // Copyright (2009) Sandia Corporation 00007 // 00008 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00009 // license for use of this work by or on behalf of the U.S. Government. 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 Roscoe A. Bartlett (rabartl@sandia.gov) 00026 // 00027 // *********************************************************************** 00028 // @HEADER 00029 */ 00030 00031 #ifndef GLOBIPACK_MERIT_FUNC_1D_BASE_HPP 00032 #define GLOBIPACK_MERIT_FUNC_1D_BASE_HPP 00033 00034 00035 #include "GlobiPack_Types.hpp" 00036 #include "Teuchos_Describable.hpp" 00037 00038 00039 namespace GlobiPack { 00040 00041 00048 template<typename Scalar> 00049 class MeritFunc1DBase : virtual public Teuchos::Describable 00050 { 00051 public: 00052 00054 virtual bool supportsDerivEvals() const = 0; 00055 00074 virtual void eval( const Scalar &alpha, const Ptr<Scalar> &phi, 00075 const Ptr<Scalar> &Dphi ) const = 0; 00076 00077 }; 00078 00079 00084 template<typename Scalar> 00085 typename ScalarTraits<Scalar>::magnitudeType 00086 computeValue(const MeritFunc1DBase<Scalar> &phi, const Scalar &alpha) 00087 { 00088 Scalar phi_val = ScalarTraits<Scalar>::zero(); 00089 phi.eval(alpha, Teuchos::outArg(phi_val), Teuchos::null); 00090 return phi_val; 00091 } 00092 00093 00098 template<typename Scalar> 00099 PointEval1D<Scalar> 00100 computePoint(const MeritFunc1DBase<Scalar> &phi, const Scalar &alpha, 00101 const bool compute_phi = true, const bool compute_Dphi = false) 00102 { 00103 using Teuchos::null; 00104 using Teuchos::outArg; 00105 PointEval1D<Scalar> p; 00106 p.alpha = alpha; 00107 phi.eval( alpha, compute_phi ? outArg(p.phi) : null , 00108 compute_Dphi ? outArg(p.Dphi) : null ); 00109 return p; 00110 } 00111 00112 00113 } // namespace GlobiPack 00114 00115 00116 #endif // GLOBIPACK_MERIT_FUNC_1D_BASE_HPP
1.7.4