diff --git a/src/OpenFOAM/matrices/RectangularMatrix/RectangularMatrix.H b/src/OpenFOAM/matrices/RectangularMatrix/RectangularMatrix.H index bb1877e078..5b09ea7568 100644 --- a/src/OpenFOAM/matrices/RectangularMatrix/RectangularMatrix.H +++ b/src/OpenFOAM/matrices/RectangularMatrix/RectangularMatrix.H @@ -80,6 +80,11 @@ public: //- initializing all elements to the given value inline RectangularMatrix(const label m, const label n, const Type& val); + //- Construct for given number of rows/columns + //- initializing all elements to zero, and diagonal to one + template + inline RectangularMatrix(const labelPair& dims, const Identity); + //- Construct given number of rows/columns inline explicit RectangularMatrix(const labelPair& dims); diff --git a/src/OpenFOAM/matrices/RectangularMatrix/RectangularMatrixI.H b/src/OpenFOAM/matrices/RectangularMatrix/RectangularMatrixI.H index b014e29069..7cef3593e7 100644 --- a/src/OpenFOAM/matrices/RectangularMatrix/RectangularMatrixI.H +++ b/src/OpenFOAM/matrices/RectangularMatrix/RectangularMatrixI.H @@ -80,6 +80,23 @@ inline Foam::RectangularMatrix::RectangularMatrix {} +template +template +inline Foam::RectangularMatrix::RectangularMatrix +( + const labelPair& dims, + const Identity +) +: + Matrix, Type>(dims.first(), dims.second(), Zero) +{ + for (label i = 0; i < min(dims.first(), dims.second()); ++i) + { + this->operator()(i, i) = pTraits::one; + } +} + + template inline Foam::RectangularMatrix::RectangularMatrix (