19 #ifndef PISM_ARRAY_HELPERS_H
20 #define PISM_ARRAY_HELPERS_H
22 #include "pism/util/Grid.hh"
35 void add(
const V &x,
double alpha,
const V &y, V &result,
bool scatter =
true) {
38 for (
auto p = result.grid()->points(); p; p.next()) {
39 const int i = p.i(), j = p.j();
41 result(i, j) = x(i, j) + y(i, j) * alpha;
45 result.update_ghosts();
48 result.inc_state_counter();
52 void copy(
const V &input, V &result,
bool scatter =
true) {
56 for (
auto p = result.grid()->points(); p; p.next()) {
57 const int i = p.i(), j = p.j();
59 result(i, j) = input(i, j);
63 result.update_ghosts();
66 result.inc_state_counter();
Makes sure that we call begin_access() and end_access() for all accessed array::Arrays.
void add(const V &x, double alpha, const V &y, V &result, bool scatter=true)
Computes result = x + alpha * y, where x, y, and z are 2D Arrays (scalar or vector).
void copy(const V &input, V &result, bool scatter=true)