bool
has_ghost_elements() const;
+ /**
+ * Test for equality. This function assumes that the present vector and
+ * the one to compare with have the same size already, since comparing
+ * vectors of different sizes makes not much sense anyway.
+ */
+ bool
+ operator==(const Vector<Number, MemorySpace> &v) const;
+
+ /**
+ * Test for inequality. This function assumes that the present vector and
+ * the one to compare with have the same size already, since comparing
+ * vectors of different sizes makes not much sense anyway.
+ */
+ bool
+ operator!=(const Vector<Number, MemorySpace> &v) const;
+
/**
* Return the global size of the vector, equal to the sum of the number of
* locally owned indices among all processors.
+ template <typename Number, typename MemorySpace>
+ bool
+ Vector<Number, MemorySpace>::operator==(
+ const Vector<Number, MemorySpace> &v) const
+ {
+ Assert(size() == v.size(), ExcDimensionMismatch(size(), v.size()));
+
+ const size_t this_local_length = vector->getLocalLength();
+ const size_t other_local_length = v.vector->getLocalLength();
+ if (this_local_length != other_local_length)
+ return false;
+
+# if DEAL_II_TRILINOS_VERSION_GTE(13, 2, 0)
+ auto this_vector_2d = vector->template getLocalView<Kokkos::HostSpace>(
+ Tpetra::Access::ReadOnly);
+ auto other_vector_2d = v.vector->template getLocalView<Kokkos::HostSpace>(
+ Tpetra::Access::ReadOnly);
+
+# else
+ vector->template sync<Kokkos::HostSpace>();
+ v.vector->template sync<Kokkos::HostSpace>();
+ auto this_vector_2d = vector->template getLocalView<Kokkos::HostSpace>();
+ auto other_vector_2d =
+ v.vector->template getLocalView<Kokkos::HostSpace>();
+# endif
+ auto this_vector_1d = Kokkos::subview(this_vector_2d, Kokkos::ALL(), 0);
+ auto other_vector_1d = Kokkos::subview(other_vector_2d, Kokkos::ALL(), 0);
+
+ for (size_type i = 0; i < this_local_length; ++i)
+ if (this_vector_1d(i) != other_vector_1d(i))
+ return false;
+
+ return true;
+ }
+
+
+
+ template <typename Number, typename MemorySpace>
+ bool
+ Vector<Number, MemorySpace>::operator!=(
+ const Vector<Number, MemorySpace> &v) const
+ {
+ return (!(*this == v));
+ }
+
+
+
template <typename Number, typename MemorySpace>
typename Vector<Number, MemorySpace>::size_type
Vector<Number, MemorySpace>::size() const