Commit 3d5f3eb0 authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#1533 Add a Petsc wrapper around MatEqual.

parent 870915f5
...@@ -666,6 +666,29 @@ namespace MoReFEM ...@@ -666,6 +666,29 @@ namespace MoReFEM
mpi.Barrier(); mpi.Barrier();
} }
bool AreStrictlyEqual(const Matrix & lhs,
const Matrix& rhs,
const char* invoking_file, int invoking_line)
{
PetscBool value;
int error_code = MatEqual(lhs.Internal(), rhs.Internal(), &value);
if (error_code)
throw ExceptionNS::Exception(error_code, "MatEqual", invoking_file, invoking_line);
switch (value)
{
case PETSC_TRUE:
return true;
case PETSC_FALSE:
return false;
}
assert(false);
exit(EXIT_FAILURE);
}
} // namespace Petsc } // namespace Petsc
......
...@@ -621,6 +621,23 @@ namespace MoReFEM ...@@ -621,6 +621,23 @@ namespace MoReFEM
void Swap(Matrix& , Matrix& ); void Swap(Matrix& , Matrix& );
/*!
* \brief Checks whether Petsc matrices are equal.
*
* This is a thin wrapper over PETSc's \a MatEqual, it probably won't work if there are rounding errors (see the namesake for PETSc vectors -
* I had to resort to something else than \a VecEqual for this reason).
*
* \copydoc doxygen_hide_lhs_rhs_arg
* \copydoc doxygen_hide_invoking_file_and_line
*
* \return True if lhs and rhs are identical (same pointer or bitwise equality).
*/
bool AreStrictlyEqual(const Matrix & lhs,
const Matrix& rhs,
const char* invoking_file, int invoking_line);
} // namespace Petsc } // namespace Petsc
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment