Loading [MathJax]/extensions/tex2jax.js
PISM, A Parallel Ice Sheet Model 2.2.2-d6b3a29ca committed by Constantine Khrulev on 2025-03-28
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
IPMeanSquareFunctional.hh
Go to the documentation of this file.
1// Copyright (C) 2012, 2013, 2014, 2015, 2020, 2022, 2024 David Maxwell
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 IPMEANSQUAREFUNCTIONAL_HH_DZ18EO5C
20#define IPMEANSQUAREFUNCTIONAL_HH_DZ18EO5C
21
22#include "pism/inverse/functional/IPFunctional.hh"
23#include "pism/util/array/Scalar.hh"
24#include "pism/util/array/Vector.hh"
25
26namespace pism {
27namespace inverse {
28
29//! Implements a functional corresponding to a (possibly weighted) sum of squares of components of an array::Scalar.
30/*! If the vector has components \f$x_i\f$ the functional is
31 \f[
32 J(x) = c_N \sum_{i} w_i x_i^2
33 \f]
34 where \f$[w_i]\f$ is a vector of weights and \f$c_N\f$ is a normalization constant. The value
35 of the normalization constant is set implicitly by a call to normalize().
36*/
38public:
39 /*!
40 * @param[in] grid the computational grid
41 * @param[in] weights Vector of weights (NULL implies all weights are 1)
42 */
43 IPMeanSquareFunctional2S(std::shared_ptr<const Grid> grid,
44 array::Scalar *weights=NULL)
45 : IPInnerProductFunctional<array::Scalar>(grid),
46 m_weights(weights),
47 m_normalization(1.) {};
49
50 virtual void normalize(double scale);
51
52 virtual void valueAt(array::Scalar &x, double *OUTPUT);
53 virtual void dot(array::Scalar &a, array::Scalar &b, double *OUTPUT);
54 virtual void gradientAt(array::Scalar &x, array::Scalar &gradient);
55
56protected:
59
60private:
63};
64
65
66//! Implements a functional corresponding to a (possibly weighted) sum of squares of components of an array::Scalar.
67/*! If the vector has component vectors \f$x_i\f$ the functional is
68 \f[
69 J(x) = c_N \sum_{i} w_i |x_i|^2
70 \f]
71 where \f$[w_i]\f$ is a vector of weights and \f$c_N\f$ is a normalization constant. The value
72 of the normalization constant is set implicitly by a call to normalize().
73*/
75public:
76 IPMeanSquareFunctional2V(std::shared_ptr<const Grid> grid, array::Scalar *weights=NULL) :
77 IPInnerProductFunctional<array::Vector>(grid), m_weights(weights), m_normalization(1.) {};
79
80 virtual void normalize(double scale);
81
82 virtual void valueAt(array::Vector &x, double *OUTPUT);
83 virtual void dot(array::Vector &a, array::Vector &b, double *OUTPUT);
84 virtual void gradientAt(array::Vector &x, array::Vector &gradient);
85
86protected:
89
90private:
93};
94
95
96} // end of namespace inverse
97} // end of namespace pism
98
99#endif /* end of include guard: IPMEANSQUAREFUNCTIONAL_HH_DZ18EO5C */
Abstract base class for IPFunctionals arising from an inner product.
virtual void normalize(double scale)
Implicitly set the normalization constant for the functional.
virtual void dot(array::Scalar &a, array::Scalar &b, double *OUTPUT)
Computes the inner product .
IPMeanSquareFunctional2S(std::shared_ptr< const Grid > grid, array::Scalar *weights=NULL)
virtual void valueAt(array::Scalar &x, double *OUTPUT)
virtual void gradientAt(array::Scalar &x, array::Scalar &gradient)
IPMeanSquareFunctional2S & operator=(IPMeanSquareFunctional2S const &)
IPMeanSquareFunctional2S(IPMeanSquareFunctional2S const &)
Implements a functional corresponding to a (possibly weighted) sum of squares of components of an arr...
IPMeanSquareFunctional2V & operator=(IPMeanSquareFunctional2V const &)
virtual void gradientAt(array::Vector &x, array::Vector &gradient)
virtual void dot(array::Vector &a, array::Vector &b, double *OUTPUT)
Computes the inner product .
virtual void valueAt(array::Vector &x, double *OUTPUT)
IPMeanSquareFunctional2V(IPMeanSquareFunctional2V const &)
virtual void normalize(double scale)
Implicitly set the normalization constant for the functional.
IPMeanSquareFunctional2V(std::shared_ptr< const Grid > grid, array::Scalar *weights=NULL)
Implements a functional corresponding to a (possibly weighted) sum of squares of components of an arr...