MatrixOperations.hpp 6.58 KB
 GILLES Sebastien committed Mar 17, 2016 1 2 ``````//! \file // `````` 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 ``````// // MatrixTOperations.hpp // HappyHeart // // Created by Sebastien Gilles on 30/10/15. // Copyright © 2015 Inria. All rights reserved. // #ifndef HAPPY_HEART_x_THIRD_PARTY_x_WRAPPERS_x_PETSC_x_MATRIX_x_MATRIX_OPERATIONS_HPP_ # define HAPPY_HEART_x_THIRD_PARTY_x_WRAPPERS_x_PETSC_x_MATRIX_x_MATRIX_OPERATIONS_HPP_ # include # include # include "ThirdParty/IncludeWithoutWarning/Petsc/PetscSys.hpp" # include "ThirdParty/IncludeWithoutWarning/Petsc/PetscMat.hpp" # include "ThirdParty/Wrappers/Petsc/Vector/Vector.hpp" # include "ThirdParty/Wrappers/Petsc/Matrix/Private/BaseMatrix.hpp" # include "ThirdParty/Wrappers/Petsc/Exceptions/Petsc.hpp" namespace HappyHeart { namespace Wrappers { namespace Petsc { /*! * \brief Wrapper over MatAXPY, that performs Y = a * X + Y. * * \param[in] structure either SAME_NONZERO_PATTERN, DIFFERENT_NONZERO_PATTERN or SUBSET_NONZERO_PATTERN. * \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 std::enable_if_t::value, void> AXPY(PetscScalar a, const MatrixT& X, MatrixT& Y, const char* invoking_file, int invoking_line, const MatStructure& structure = SAME_NONZERO_PATTERN); /*! * \brief Wrapper over MatMult, that performs v2 = matrix * v1. * * \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 std::enable_if_t::value, void> MatMult(const MatrixT& matrix, const Vector& v1, Vector& v2, const char* invoking_file, int invoking_line); /*! * \brief Wrapper over MatMultAdd, that performs v3 = v2 + matrix * v1. * * \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 std::enable_if_t::value, void> MatMultAdd(const MatrixT& matrix, const Vector& v1, const Vector& v2, Vector& v3, const char* invoking_file, int invoking_line); /*! * \brief Wrapper over MatMultTranspose, that performs v2 = transpose(matrix) * v1. * * \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 std::enable_if_t::value, void> MatMultTranspose(const MatrixT& matrix, const Vector& v1, Vector& v2, const char* invoking_file, int invoking_line); /*! * \brief Wrapper over MatMultTransposeAdd, that performs v3 = v2 + transpose(matrix) * v1. * * \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 std::enable_if_t::value, void> MatMultTransposeAdd(const MatrixT& matrix, const Vector& v1, const Vector& v2, Vector& v3, const char* invoking_file, int invoking_line); /*! * \brief Wrapper over MatMatMult, that performs C = A * B. * * \todo #684 Investigate to use the argument fill, which provides an estimation of the non zero of the * resulting matrix. Currently PETSC_DEFAULT is used. * One can also reuse a pattern for several matrices, but so far I do not need that in HappyHeart so * I equally use the default setting. * * \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 std::enable_if_t::value, void> MatMatMult(const MatrixT& matrix1, const MatrixT& matrix2, MatrixT& matrix3, const char* invoking_file, int invoking_line); /*! * \brief Wrapper over MatMatMatMult, that performs D = A * B * C. * * \todo #684 Investigate to use the argument fill, which provides an estimation of the non zero of the * resulting matrix. Currently PETSC_DEFAULT is used. * One can also reuse a pattern for several matrices, but so far I do not need that in HappyHeart so * I equally use the default setting. * * \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 std::enable_if_t::value, void> MatMatMatMult(const MatrixT& matrix1, const MatrixT& matrix2, const MatrixT& matrix3, MatrixT& matrix4, const char* invoking_file, int invoking_line); } //namespace Petsc } //namespace Wrappers } // namespace HappyHeart # include "ThirdParty/Wrappers/Petsc/Matrix/MatrixOperations.hxx" #endif // HAPPY_HEART_x_THIRD_PARTY_x_WRAPPERS_x_PETSC_x_MATRIX_x_MATRIX_OPERATIONS_HPP_``````