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

#867 Wrappers/Seldon: extend a bit MatMult operations so that type of...

#867 Wrappers/Seldon: extend a bit MatMult operations so that type of resulting matrices might differ from the one in input (solely to be able to mix GlobalMatrix and Wrappers::Petsc::Matrix in tests; in usual HappyHeart code it should make no difference).
parent eea783a7
......@@ -32,8 +32,8 @@ namespace HappyHeart
namespace Petsc
{
/*!
* \brief Wrapper over MatAXPY, that performs Y = a * X + Y.
*
......@@ -41,11 +41,20 @@ namespace HappyHeart
* \param[in] invoking_file File that invoked the function or class; usually __FILE__.
* \param[in] invoking_line File that invoked the function or class; usually __LINE__.
*/
template<class MatrixT>
std::enable_if_t<std::is_base_of<Private::BaseMatrix, MatrixT>::value, void>
template
<
class MatrixT,
class MatrixU
>
std::enable_if_t
<
std::is_base_of<Private::BaseMatrix, MatrixT>::value
&& std::is_base_of<Private::BaseMatrix, MatrixU>::value,
void
>
AXPY(PetscScalar a,
const MatrixT& X,
MatrixT& Y,
MatrixU& Y,
const char* invoking_file, int invoking_line,
const MatStructure& structure = SAME_NONZERO_PATTERN);
......@@ -59,7 +68,7 @@ namespace HappyHeart
template<class MatrixT>
std::enable_if_t<std::is_base_of<Private::BaseMatrix, MatrixT>::value, void>
MatMult(const MatrixT& matrix, const Vector& v1, Vector& v2,
const char* invoking_file, int invoking_line);
const char* invoking_file, int invoking_line);
/*!
......@@ -71,7 +80,7 @@ namespace HappyHeart
template<class MatrixT>
std::enable_if_t<std::is_base_of<Private::BaseMatrix, MatrixT>::value, void>
MatMultAdd(const MatrixT& matrix, const Vector& v1, const Vector& v2, Vector& v3,
const char* invoking_file, int invoking_line);
const char* invoking_file, int invoking_line);
......@@ -84,7 +93,7 @@ namespace HappyHeart
template<class MatrixT>
std::enable_if_t<std::is_base_of<Private::BaseMatrix, MatrixT>::value, void>
MatMultTranspose(const MatrixT& matrix, const Vector& v1, Vector& v2,
const char* invoking_file, int invoking_line);
const char* invoking_file, int invoking_line);
/*!
......@@ -96,7 +105,7 @@ namespace HappyHeart
template<class MatrixT>
std::enable_if_t<std::is_base_of<Private::BaseMatrix, MatrixT>::value, void>
MatMultTransposeAdd(const MatrixT& matrix, const Vector& v1, const Vector& v2, Vector& v3,
const char* invoking_file, int invoking_line);
const char* invoking_file, int invoking_line);
/*!
......@@ -110,12 +119,21 @@ namespace HappyHeart
* \param[in] invoking_file File that invoked the function or class; usually __FILE__.
* \param[in] invoking_line File that invoked the function or class; usually __LINE__.
*/
template<class MatrixT>
std::enable_if_t<std::is_base_of<Private::BaseMatrix, MatrixT>::value, void>
template
<
class MatrixT,
class MatrixU
>
std::enable_if_t
<
std::is_base_of<Private::BaseMatrix, MatrixT>::value
&& std::is_base_of<Private::BaseMatrix, MatrixU>::value,
void
>
MatMatMult(const MatrixT& matrix1,
const MatrixT& matrix2,
MatrixT& matrix3,
const char* invoking_file, int invoking_line);
const MatrixT& matrix2,
MatrixU& matrix3,
const char* invoking_file, int invoking_line);
/*!
......@@ -129,13 +147,22 @@ namespace HappyHeart
* \param[in] invoking_file File that invoked the function or class; usually __FILE__.
* \param[in] invoking_line File that invoked the function or class; usually __LINE__.
*/
template<class MatrixT>
std::enable_if_t<std::is_base_of<Private::BaseMatrix, MatrixT>::value, void>
template
<
class MatrixT,
class MatrixU
>
std::enable_if_t
<
std::is_base_of<Private::BaseMatrix, MatrixT>::value
&& std::is_base_of<Private::BaseMatrix, MatrixU>::value,
void
>
MatMatMatMult(const MatrixT& matrix1,
const MatrixT& matrix2,
const MatrixT& matrix3,
MatrixT& matrix4,
const char* invoking_file, int invoking_line);
const MatrixT& matrix2,
const MatrixT& matrix3,
MatrixU& matrix4,
const char* invoking_file, int invoking_line);
......
......@@ -14,8 +14,8 @@
namespace HappyHeart
{
namespace Wrappers
{
......@@ -26,7 +26,9 @@ namespace HappyHeart
template<class MatrixT>
std::enable_if_t<std::is_base_of<Private::BaseMatrix, MatrixT>::value, void>
MatMultTranspose(const MatrixT& matrix, const Vector& v1, Vector& v2,
MatMultTranspose(const MatrixT& matrix,
const Vector& v1,
Vector& v2,
const char* invoking_file, int invoking_line)
{
int error_code = ::MatMultTranspose(matrix.Internal(), v1.Internal(), v2.Internal());
......@@ -37,8 +39,11 @@ namespace HappyHeart
template<class MatrixT>
std::enable_if_t<std::is_base_of<Private::BaseMatrix, MatrixT>::value, void>
MatMultTransposeAdd(const MatrixT& matrix, const Vector& v1, const Vector& v2, Vector& v3,
const char* invoking_file, int invoking_line)
MatMultTransposeAdd(const MatrixT& matrix,
const Vector& v1,
const Vector& v2,
Vector& v3,
const char* invoking_file, int invoking_line)
{
int error_code = ::MatMultTransposeAdd(matrix.Internal(), v1.Internal(), v2.Internal(), v3.Internal());
if (error_code)
......@@ -46,12 +51,21 @@ namespace HappyHeart
}
template<class MatrixT>
std::enable_if_t<std::is_base_of<Private::BaseMatrix, MatrixT>::value, void>
template
<
class MatrixT,
class MatrixU
>
std::enable_if_t
<
std::is_base_of<Private::BaseMatrix, MatrixT>::value
&& std::is_base_of<Private::BaseMatrix, MatrixU>::value,
void
>
MatMatMult(const MatrixT& matrix1,
const MatrixT& matrix2,
MatrixT& matrix3,
const char* invoking_file, int invoking_line)
const MatrixT& matrix2,
MatrixU& matrix3,
const char* invoking_file, int invoking_line)
{
Mat result;
......@@ -68,12 +82,21 @@ namespace HappyHeart
}
template<class MatrixT>
std::enable_if_t<std::is_base_of<Private::BaseMatrix, MatrixT>::value, void>
template
<
class MatrixT,
class MatrixU
>
std::enable_if_t
<
std::is_base_of<Private::BaseMatrix, MatrixT>::value
&& std::is_base_of<Private::BaseMatrix, MatrixU>::value,
void
>
MatMatMatMult(const MatrixT& matrix1,
const MatrixT& matrix2,
const MatrixT& matrix3,
MatrixT& matrix4,
MatrixU& matrix4,
const char* invoking_file, int invoking_line)
{
Mat result;
......@@ -91,12 +114,24 @@ namespace HappyHeart
throw ExceptionNS::Exception(error_code, "MatMatMatMult", invoking_file, invoking_line);
}
template<class MatrixT>
std::enable_if_t<std::is_base_of<Private::BaseMatrix, MatrixT>::value, void>
AXPY(PetscScalar a, const MatrixT& X, MatrixT& Y, const char* invoking_file,
int invoking_line, const MatStructure& structure)
template
<
class MatrixT,
class MatrixU
>
std::enable_if_t
<
std::is_base_of<Private::BaseMatrix, MatrixT>::value
&& std::is_base_of<Private::BaseMatrix, MatrixU>::value,
void
>
AXPY(PetscScalar a,
const MatrixT& X,
MatrixU& Y,
const char* invoking_file, int invoking_line,
const MatStructure& structure)
{
int error_code = ::MatAXPY(Y.Internal(), a, X.Internal(), structure);
if (error_code)
......@@ -106,7 +141,10 @@ namespace HappyHeart
template<class MatrixT>
std::enable_if_t<std::is_base_of<Private::BaseMatrix, MatrixT>::value, void>
MatMult(const MatrixT& matrix, const Vector& v1, Vector& v2, const char* invoking_file, int invoking_line)
MatMult(const MatrixT& matrix,
const Vector& v1,
Vector& v2,
const char* invoking_file, int invoking_line)
{
int error_code = ::MatMult(matrix.Internal(), v1.Internal(), v2.Internal());
if (error_code)
......@@ -116,22 +154,24 @@ namespace HappyHeart
template<class MatrixT>
std::enable_if_t<std::is_base_of<Private::BaseMatrix, MatrixT>::value, void>
MatMultAdd(const MatrixT& matrix, const Vector& v1,
const Vector& v2,
Vector& v3, const char* invoking_file, int invoking_line)
MatMultAdd(const MatrixT& matrix,
const Vector& v1,
const Vector& v2,
Vector& v3,
const char* invoking_file, int invoking_line)
{
int error_code = ::MatMultAdd(matrix.Internal(), v1.Internal(), v2.Internal(), v3.Internal());
if (error_code)
throw ExceptionNS::Exception(error_code, "MatMultAdd", invoking_file, invoking_line);
}
} //namespace Petsc
} //namespace Wrappers
} // namespace HappyHeart
......
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