From 2d7c3c28bf0c0aa3aa2e6b960b49561fb5bdbd6e Mon Sep 17 00:00:00 2001 From: Norihiro Watanabe <norihiro.watanabe@ufz.de> Date: Fri, 7 Mar 2014 17:01:20 +0100 Subject: [PATCH] add explicit and assignment operator to DenseMatrix --- MathLib/LinAlg/Dense/DenseMatrix-impl.h | 8 ++++++++ MathLib/LinAlg/Dense/DenseMatrix.h | 7 ++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/MathLib/LinAlg/Dense/DenseMatrix-impl.h b/MathLib/LinAlg/Dense/DenseMatrix-impl.h index ef710200a19..21893c658c7 100644 --- a/MathLib/LinAlg/Dense/DenseMatrix-impl.h +++ b/MathLib/LinAlg/Dense/DenseMatrix-impl.h @@ -89,6 +89,14 @@ DenseMatrix<FP_TYPE, IDX_TYPE>::operator=(DenseMatrix && rhs) return *this; } +template<typename FP_TYPE, typename IDX_TYPE> +DenseMatrix<FP_TYPE, IDX_TYPE>& +DenseMatrix<FP_TYPE, IDX_TYPE>::operator=(FP_TYPE const& v) +{ + std::fill(this->_data, this->_data + this->_n_rows * this->_n_cols, static_cast<FP_TYPE>(v)); + return *this; +} + template<typename FP_TYPE, typename IDX_TYPE> void DenseMatrix<FP_TYPE, IDX_TYPE>::axpy(FP_TYPE alpha, const FP_TYPE* x, FP_TYPE beta, FP_TYPE* y) const diff --git a/MathLib/LinAlg/Dense/DenseMatrix.h b/MathLib/LinAlg/Dense/DenseMatrix.h index 1cfabae56cb..578afa3319c 100644 --- a/MathLib/LinAlg/Dense/DenseMatrix.h +++ b/MathLib/LinAlg/Dense/DenseMatrix.h @@ -33,7 +33,7 @@ public: public: /// Dense square matrix constructor. - DenseMatrix (IDX_TYPE rows) : DenseMatrix(rows, rows) {} + explicit DenseMatrix (IDX_TYPE rows) : DenseMatrix(rows, rows) {}; /// Dense rectangular matrix constructor. DenseMatrix (IDX_TYPE rows, IDX_TYPE cols); @@ -70,6 +70,11 @@ public: */ DenseMatrix& operator=(DenseMatrix && rhs); + /** + * Assignment operator + */ + DenseMatrix& operator=(FP_TYPE const& v); + /** * \f$ y = \alpha \cdot A x + \beta y\f$ */ -- GitLab