Commit c19ec2db authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#782 Wrappers/Seldon: add functions to check a matrix or a vector is filled...

#782 Wrappers/Seldon: add functions to check a matrix or a vector is filled with zero, and use these functions in two asserts.
parent fe4efe4a
......@@ -126,6 +126,7 @@ namespace HappyHeart
const auto& d2I3dC = const_invariant_manager.template GetSecondDerivativeWrtCauchyGreen<3>();
{
assert(Wrappers::Seldon::IsZeroMatrix(d2W));
Seldon::Add(dWdI1, d2I1dC, d2W);
Seldon::Add(dWdI2, d2I2dC, d2W);
Seldon::Add(dWdI3, d2I3dC, d2W);
......@@ -182,6 +183,7 @@ namespace HappyHeart
{
assert(Wrappers::Seldon::IsZeroVector(dW));
Seldon::Add(dWdI1, dI1dC, dW);
Seldon::Add(dWdI2, dI2dC, dW);
Seldon::Add(dWdI3, dI3dC, dW);
......
......@@ -15,6 +15,7 @@
# include "Utilities/Exceptions/Exception.hpp"
# include "Utilities/MatrixOrVector.hpp"
# include "Utilities/Numeric/Numeric.hpp"
namespace HappyHeart
......@@ -182,9 +183,24 @@ namespace HappyHeart
::Seldon::Vector<int> ContiguousSequence(int first_index, int N);
::Seldon::Vector<int> ContiguousSequence(unsigned int first_index, unsigned int N);
/*!
* \brief Check whether a matrix is filled with zero or not.
*/
template<class SeldonMatrixT>
bool IsZeroMatrix(const SeldonMatrixT& matrix);
/*!
* \brief Check whether a vector is filled with zero or not.
*/
template<class SeldonVectorT>
bool IsZeroVector(const SeldonVectorT& vector);
} // namespace Seldon
......
......@@ -211,6 +211,42 @@ namespace HappyHeart
}
}
template<class SeldonMatrixT>
bool IsZeroMatrix(const SeldonMatrixT& matrix)
{
const auto Nrow = matrix.GetM();
const auto Ncol = matrix.GetN();
for (auto i = 0; i < Nrow; ++i)
{
for (auto j = 0; j < Ncol; ++j)
{
if (!NumericNS::IsZero(matrix(i, j)))
return false;
}
}
return true;
}
template<class SeldonVectorT>
bool IsZeroVector(const SeldonVectorT& vector)
{
const auto Nitem = vector.GetM();
for (auto i = 0; i < Nitem; ++i)
{
if (!NumericNS::IsZero(vector(i)))
return false;
}
return true;
}
} // namespace Seldon
......
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