diff options
author | Gael Guennebaud <g.gael@free.fr> | 2018-10-10 23:38:22 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2018-10-10 23:38:22 +0200 |
commit | ce243ee45bb1d17483f40411007eb31427d34766 (patch) | |
tree | 9bdac92d90af22bd49dd93097531cc0b351685fc /Eigen/src/Core/DiagonalMatrix.h | |
parent | 5335659c47d69d3ee1b6f9792fea5998731f9a53 (diff) |
bug #520: add diagmat +/- diagmat operators.
Diffstat (limited to 'Eigen/src/Core/DiagonalMatrix.h')
-rw-r--r-- | Eigen/src/Core/DiagonalMatrix.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Eigen/src/Core/DiagonalMatrix.h b/Eigen/src/Core/DiagonalMatrix.h index 4e8297ee6..afab2f1b6 100644 --- a/Eigen/src/Core/DiagonalMatrix.h +++ b/Eigen/src/Core/DiagonalMatrix.h @@ -83,6 +83,30 @@ class DiagonalBase : public EigenBase<Derived> { return DiagonalWrapper<const EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(Scalar,DiagonalVectorType,product) >(scalar * other.diagonal()); } + + template<typename OtherDerived> + EIGEN_DEVICE_FUNC + #ifdef EIGEN_PARSED_BY_DOXYGEN + inline unspecified_expression_type + #else + inline const DiagonalWrapper<const EIGEN_CWISE_BINARY_RETURN_TYPE(DiagonalVectorType,typename OtherDerived::DiagonalVectorType,sum) > + #endif + operator+(const DiagonalBase<OtherDerived>& other) const + { + return (diagonal() + other.diagonal()).asDiagonal(); + } + + template<typename OtherDerived> + EIGEN_DEVICE_FUNC + #ifdef EIGEN_PARSED_BY_DOXYGEN + inline unspecified_expression_type + #else + inline const DiagonalWrapper<const EIGEN_CWISE_BINARY_RETURN_TYPE(DiagonalVectorType,typename OtherDerived::DiagonalVectorType,difference) > + #endif + operator-(const DiagonalBase<OtherDerived>& other) const + { + return (diagonal() - other.diagonal()).asDiagonal(); + } }; #endif |