Commit 6cc2a8db authored by Gautier Bureau's avatar Gautier Bureau Committed by GILLES Sebastien
Browse files

#829 Norm added to Vector and Matrix.

parent 2e30e0be
......@@ -418,6 +418,18 @@ namespace HappyHeart
petsc_matrix_ = petsc_matrix;
}
double Matrix::Norm(NormType type, const char* invoking_file, int invoking_line) const
{
PetscReal norm;
int error_code = MatNorm(Internal(), type, &norm);
if (error_code)
throw ExceptionNS::Exception(error_code, "MatNorm", invoking_file, invoking_line);
return static_cast<double>(norm);
}
} // namespace Petsc
......
......@@ -413,6 +413,12 @@ namespace HappyHeart
void View(const Mpi& mpi, const std::string& output_file, const char* invoking_file, int invoking_line,
PetscViewerFormat format = PETSC_VIEWER_DEFAULT) const;
/*!
* \brief Wrapper over MatNorm. Available norms are NORM_1, NORM_FROBENIUS and NORM_INFINITY.
*
*/
double Norm(NormType type, const char* invoking_file, int invoking_line) const;
private:
......
......@@ -420,7 +420,20 @@ namespace HappyHeart
return std::make_pair(position, value);
}
double Vector::Norm(NormType type, const char* invoking_file, int invoking_line) const
{
PetscReal norm;
int error_code = VecNorm(Internal(), type, &norm);
if (error_code)
throw ExceptionNS::Exception(error_code, "VecNorm", invoking_file, invoking_line);
return static_cast<double>(norm);
}
void Vector::View(const Mpi& mpi, const char* invoking_file, int invoking_line) const
{
......
......@@ -461,7 +461,13 @@ namespace HappyHeart
* \param[in] invoking_line File that invoked the function or class; usually __LINE__.
* \return First element is the position of the maximum found, second is its value.
*/
std::pair<PetscInt, PetscReal> Max( const char* invoking_file, int invoking_line) const;
std::pair<PetscInt, PetscReal> Max(const char* invoking_file, int invoking_line) const;
/*!
* \brief Wrapper over VecNorm. Available norms are NORM_1, NORM_2 and NORM_INFINITY.
*
*/
double Norm(NormType type, const char* invoking_file, int invoking_line) const;
/*!
* \brief Update the ghost values.
......@@ -578,7 +584,6 @@ namespace HappyHeart
*
*/
void DotProduct(const Vector& x, const Vector& y, PetscScalar& val, const char* invoking_file, int invoking_line);
/*!
......@@ -599,7 +604,7 @@ namespace HappyHeart
const char* invoking_file, int invoking_line);
/*!
* \brief Compute Norm L2.
* \brief Compute Norm L2. For development purposes only. Another method exists to compute the norm.
*/
double NormL2(const Mpi& mpi,
const Vector& vector,
......
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