19 #include "pism/inverse/functional/IPMeanSquareFunctional.hh"
20 #include "pism/util/Grid.hh"
21 #include "pism/util/array/Vector.hh"
22 #include "pism/util/array/Scalar.hh"
23 #include "pism/util/pism_utilities.hh"
42 for (
auto p =
m_grid->points(); p; p.next()) {
43 const int i = p.i(), j = p.j();
45 value += (*m_weights)(i, j);
48 for (
auto p =
m_grid->points(); p; p.next()) {
66 for (
auto p =
m_grid->points(); p; p.next()) {
67 const int i = p.i(), j = p.j();
73 for (
auto p =
m_grid->points(); p; p.next()) {
74 const int i = p.i(), j = p.j();
77 value += (x_ij.
u*x_ij.
u + x_ij.
v*x_ij.
v);
94 for (
auto p =
m_grid->points(); p; p.next()) {
95 const int i = p.i(), j = p.j();
102 for (
auto p =
m_grid->points(); p; p.next()) {
103 const int i = p.i(), j = p.j();
107 value += (a_ij.
u*b_ij.
u + a_ij.
v*b_ij.
v);
122 for (
auto p =
m_grid->points(); p; p.next()) {
123 const int i = p.i(), j = p.j();
129 for (
auto p =
m_grid->points(); p; p.next()) {
130 const int i = p.i(), j = p.j();
151 for (
auto p =
m_grid->points(); p; p.next()) {
152 const int i = p.i(), j = p.j();
154 value += (*m_weights)(i, j);
157 for (
auto p =
m_grid->points(); p; p.next()) {
175 for (
auto p =
m_grid->points(); p; p.next()) {
176 const int i = p.i(), j = p.j();
178 double &x_ij = x(i, j);
179 value += x_ij*x_ij*(*m_weights)(i, j);
182 for (
auto p =
m_grid->points(); p; p.next()) {
183 const int i = p.i(), j = p.j();
185 double &x_ij = x(i, j);
203 for (
auto p =
m_grid->points(); p; p.next()) {
204 const int i = p.i(), j = p.j();
206 value += (a(i, j)*b(i, j))*(*
m_weights)(i, j);
209 for (
auto p =
m_grid->points(); p; p.next()) {
210 const int i = p.i(), j = p.j();
212 value += (a(i, j)*b(i, j));
228 for (
auto p =
m_grid->points(); p; p.next()) {
229 const int i = p.i(), j = p.j();
234 for (
auto p =
m_grid->points(); p; p.next()) {
235 const int i = p.i(), j = p.j();
This class represents a 2D vector field (such as ice velocity) at a certain grid point.
void add(const PetscAccessible &v)
Makes sure that we call begin_access() and end_access() for all accessed array::Arrays.
void add(double alpha, const Array2D< T > &x)
void set(double c)
Result: v[j] <- c for all j.
std::shared_ptr< const Grid > m_grid
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 .
array::Scalar * m_weights
virtual void valueAt(array::Scalar &x, double *OUTPUT)
Computes the value of the functional at the vector x.
virtual void gradientAt(array::Scalar &x, array::Scalar &gradient)
Computes the gradient of the functional at the vector x.
virtual void gradientAt(array::Vector &x, array::Vector &gradient)
Computes the gradient of the functional at the vector x.
virtual void dot(array::Vector &a, array::Vector &b, double *OUTPUT)
Computes the inner product .
virtual void valueAt(array::Vector &x, double *OUTPUT)
Computes the value of the functional at the vector x.
virtual void normalize(double scale)
Implicitly set the normalization constant for the functional.
array::Scalar * m_weights
void GlobalSum(MPI_Comm comm, double *local, double *result, int count)