IPLogRelativeFunctional.hh (2161B)
1 // Copyright (C) 2013, 2014, 2015 David Maxwell and Constantine Khroulev 2 // 3 // This file is part of PISM. 4 // 5 // PISM is free software; you can redistribute it and/or modify it under the 6 // terms of the GNU General Public License as published by the Free Software 7 // Foundation; either version 3 of the License, or (at your option) any later 8 // version. 9 // 10 // PISM is distributed in the hope that it will be useful, but WITHOUT ANY 11 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 12 // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 13 // details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with PISM; if not, write to the Free Software 17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 19 #ifndef IPLOGRELATIVEFUNCTIONAL_HH_97I6BWHG 20 #define IPLOGRELATIVEFUNCTIONAL_HH_97I6BWHG 21 22 #include "IPFunctional.hh" 23 24 namespace pism { 25 namespace inverse { 26 27 //! Implements a functional for log-relative errors. 28 /*! Specifically, given a reference function \f$u_{obs}=[U_i]\f$, 29 \f[ 30 J(x) = c_N \sum_i \log\left(1+W_i\frac{|X_i|^2}{|U_{i}|^2+\epsilon^2}\right) 31 \f] 32 where \f$\epsilon={\tt inv_ssa_velocity_eps}\f$ and \f$w\f$ is an optionally 33 provided weight function. The normalization constant \f$c_N\f$ is determined 34 implicitly by normalize(). 35 */ 36 class IPLogRelativeFunctional : public IPFunctional<IceModelVec2V> { 37 public: 38 IPLogRelativeFunctional(IceGrid::ConstPtr grid, IceModelVec2V &u_observed, double eps, 39 IceModelVec2S *weights=NULL) : 40 IPFunctional<IceModelVec2V>(grid), m_u_observed(u_observed), m_weights(weights), m_normalization(1.), m_eps(eps) {}; 41 virtual ~IPLogRelativeFunctional() {}; 42 43 virtual void normalize(double scale); 44 45 virtual void valueAt(IceModelVec2V &x, double *OUTPUT); 46 virtual void gradientAt(IceModelVec2V &x, IceModelVec2V &gradient); 47 48 protected: 49 IceModelVec2V &m_u_observed; 50 IceModelVec2S *m_weights; 51 double m_normalization; 52 double m_eps; 53 }; 54 55 56 } // end of namespace inverse 57 } // end of namespace pism 58 59 #endif /* end of include guard: IPLOGRELATIVEFUNCTIONAL_HH_97I6BWHG */