From: Matthias Maier Date: Sun, 3 May 2015 14:27:49 +0000 (+0200) Subject: Add missing variants X-Git-Tag: v8.3.0-rc1~179^2~10 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=28f4620f430685950452ae4c15df27ea320328b5;p=dealii.git Add missing variants --- diff --git a/include/deal.II/lac/linear_operator.h b/include/deal.II/lac/linear_operator.h index 7eed984db9..f6fc3f2f57 100644 --- a/include/deal.II/lac/linear_operator.h +++ b/include/deal.II/lac/linear_operator.h @@ -1858,7 +1858,7 @@ PackagedOperation operator+(const Range &u, const Range &v) /** * @relates PackagedOperation * - * Create a PackagedOperation object that stores the addition of two vectors. + * Create a PackagedOperation object that stores the subtraction of two vectors. * * The PackagedOperation object that is created stores a reference to @p u * and @p v. Thus, the vectors must remain valid references for the whole @@ -2084,6 +2084,112 @@ operator*(const PackagedOperation &comp, return return_comp; } + +/** + * @relates PackagedOperation + * + * Create a PackagedOperation object from a reference to a matrix @p m and + * a reference to a vector @p u of the Domain space. The object stores the + * PackagedOperation $\text{m} \,u$ (in matrix notation). If a different + * result type than Vector is desired, the matrix should be + * explicitly wrapper with linear_operator instead. + * + * return (return_add) are implemented with + * vmult(__1,u) (vmult_add(__1,u)). + * + * The PackagedOperation object that is created stores references to @p u + * and @p m. Thus, both must remain valid references for the whole lifetime + * of the PackagedOperation object. All changes made on @p u or @p m after + * the creation of the PackagedOperation object are reflected by the + * operator object. + * + * @ingroup LAOperators + */ +template ::type::value>::type, + typename = typename std::enable_if, Domain>, Matrix>::value>::type, + typename = typename std::enable_if, Domain, Matrix>::type::value>::type> +PackagedOperation > +operator*(const Matrix &m, + const Domain &u) +{ + return linear_operator, Domain>(m) * u; +} + + +/** + * @relates PackagedOperation + * + * Same as above, taking a packaged operation instead of a vector. + * + * @ingroup LAOperators + */ +template ::type::value>::type, + typename = typename std::enable_if, Domain>, Matrix>::value>::type, + typename = typename std::enable_if, Domain, Matrix>::type::value>::type> +PackagedOperation > +operator*(const Matrix &m, + const PackagedOperation &u) +{ + return linear_operator, Domain>(m) * u; +} + + +/** + * @relates PackagedOperation + * + * Create a PackagedOperation object from a reference to a matrix @p m and + * a reference to a vector @p u of the Domain space. The object stores the + * PackagedOperation $\text{m}^T \,u$ (in matrix notation). If a different + * result type than Vector is desired, the matrix should be + * explicitly wrapper with linear_operator instead. + * + * return (return_add) are implemented with + * Tvmult(__1,u) (Tvmult_add(__1,u)). + * + * The PackagedOperation object that is created stores references to @p u + * and @p m. Thus, both must remain valid references for the whole lifetime + * of the PackagedOperation object. All changes made on @p u or @p m after + * the creation of the PackagedOperation object are reflected by the + * operator object. + * + * @ingroup LAOperators + */ +template ::type::value>::type, + typename = typename std::enable_if >, Matrix>::value>::type, + typename = typename std::enable_if, Matrix>::type::value>::type> +PackagedOperation > +operator*(const Range &u, + const Matrix &m) +{ + return u * linear_operator>(m); +} + + +/** + * @relates PackagedOperation + * + * Same as above, taking a packaged operation instead of a vector. + * + * @ingroup LAOperators + */ +template ::type::value>::type, + typename = typename std::enable_if >, Matrix>::value>::type, + typename = typename std::enable_if, Matrix>::type::value>::type> +PackagedOperation > +operator*(const PackagedOperation &u, + const Matrix &m) +{ + return u * linear_operator>(m); +} + //@} DEAL_II_NAMESPACE_CLOSE