ENH: harmonize matrix constructors (#1220)

- generalize identity matrix constructors for non-scalar types

- add constructors using labelPair for the row/column sizing information.
  For a SquareMatrix, this provides an unambiguous parameter resolution.

- reuse assignment operators

STYLE: adjust matrix comments
This commit is contained in:
Mark Olesen
2019-05-29 09:50:46 +02:00
committed by Andrew Heather
parent 2bdcd5b80d
commit 96d0a8f2af
18 changed files with 522 additions and 185 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
@ -46,24 +46,12 @@ inline Foam::RectangularMatrix<Type>::RectangularMatrix
template<class Type>
template<class MatrixType>
inline Foam::RectangularMatrix<Type>::RectangularMatrix
(
const ConstMatrixBlock<MatrixType>& block
const label n
)
:
Matrix<RectangularMatrix<Type>, Type>(block)
{}
template<class Type>
template<class MatrixType>
inline Foam::RectangularMatrix<Type>::RectangularMatrix
(
const MatrixBlock<MatrixType>& block
)
:
Matrix<RectangularMatrix<Type>, Type>(block)
Matrix<RectangularMatrix<Type>, Type>(n, n)
{}
@ -91,6 +79,60 @@ inline Foam::RectangularMatrix<Type>::RectangularMatrix
{}
template<class Type>
inline Foam::RectangularMatrix<Type>::RectangularMatrix
(
const labelPair& dims
)
:
RectangularMatrix<Type>(dims.first(), dims.second())
{}
template<class Type>
inline Foam::RectangularMatrix<Type>::RectangularMatrix
(
const labelPair& dims,
const zero
)
:
RectangularMatrix<Type>(dims.first(), dims.second(), Zero)
{}
template<class Type>
inline Foam::RectangularMatrix<Type>::RectangularMatrix
(
const labelPair& dims,
const Type& val
)
:
RectangularMatrix<Type>(dims.first(), dims.second(), val)
{}
template<class Type>
template<class MatrixType>
inline Foam::RectangularMatrix<Type>::RectangularMatrix
(
const ConstMatrixBlock<MatrixType>& mat
)
:
Matrix<RectangularMatrix<Type>, Type>(mat)
{}
template<class Type>
template<class MatrixType>
inline Foam::RectangularMatrix<Type>::RectangularMatrix
(
const MatrixBlock<MatrixType>& mat
)
:
Matrix<RectangularMatrix<Type>, Type>(mat)
{}
template<class Type>
inline Foam::RectangularMatrix<Type>::RectangularMatrix
(
@ -119,14 +161,14 @@ Foam::RectangularMatrix<Type>::clone() const
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Type>
void Foam::RectangularMatrix<Type>::operator=(const zero)
inline void Foam::RectangularMatrix<Type>::operator=(const zero)
{
Matrix<RectangularMatrix<Type>, Type>::operator=(Zero);
}
template<class Type>
void Foam::RectangularMatrix<Type>::operator=(const Type& val)
inline void Foam::RectangularMatrix<Type>::operator=(const Type& val)
{
Matrix<RectangularMatrix<Type>, Type>::operator=(val);
}
@ -164,4 +206,5 @@ inline Foam::RectangularMatrix<Type> outer
} // End namespace Foam
// ************************************************************************* //