diff --git a/src/OpenFOAM/matrices/Matrix/Matrix.C b/src/OpenFOAM/matrices/Matrix/Matrix.C index d27013e8ae..fc262b707b 100644 --- a/src/OpenFOAM/matrices/Matrix/Matrix.C +++ b/src/OpenFOAM/matrices/Matrix/Matrix.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2019-2021 OpenCFD Ltd. + Copyright (C) 2019-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -405,6 +405,23 @@ Form Foam::Matrix::T() const } +template +Form Foam::Matrix::transpose() const +{ + Form At(labelPair{n(), m()}); + + for (label i = 0; i < m(); ++i) + { + for (label j = 0; j < n(); ++j) + { + At(j, i) = (*this)(i, j); + } + } + + return At; +} + + template Foam::List Foam::Matrix::diag() const { diff --git a/src/OpenFOAM/matrices/Matrix/Matrix.H b/src/OpenFOAM/matrices/Matrix/Matrix.H index c11d7a27ec..eb34e064d3 100644 --- a/src/OpenFOAM/matrices/Matrix/Matrix.H +++ b/src/OpenFOAM/matrices/Matrix/Matrix.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019-2021 OpenCFD Ltd. + Copyright (C) 2019-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -372,9 +372,12 @@ public: // Operations - //- Return (conjugate) transpose of Matrix + //- Return conjugate transpose of Matrix Form T() const; + //- Return non-conjugate transpose of Matrix + Form transpose() const; + //- Right-multiply Matrix by a column vector (A * x) inline tmp> Amul(const UList& x) const;