diff --git a/src/OpenFOAM/matrices/Matrix/Matrix.C b/src/OpenFOAM/matrices/Matrix/Matrix.C index de27a21058..7a59373716 100644 --- a/src/OpenFOAM/matrices/Matrix/Matrix.C +++ b/src/OpenFOAM/matrices/Matrix/Matrix.C @@ -33,21 +33,20 @@ License template template -Foam::tmp> Foam::Matrix::rightMultiplyImpl +Foam::tmp> Foam::Matrix::AmulImpl ( - const ListType& colVec + const ListType& x ) const { const Matrix& mat = *this; #ifdef FULLDEBUG - if (mat.n() != colVec.size()) + if (mat.n() != x.size()) { FatalErrorInFunction << "Attempt to multiply incompatible Matrix and Vector:" << nl << "Matrix : (" << mat.m() << ", " << mat.n() << ')' << nl - << "Vector : " << colVec.size() << " rows" << nl - << "The number of Matrix columns must equal the Vector size" << nl + << "Matrix columns != Vector size (" << x.size() << ')' << nl << abort(FatalError); } #endif @@ -59,7 +58,7 @@ Foam::tmp> Foam::Matrix::rightMultiplyImpl { for (label j = 0; j < mat.n(); ++j) { - result[i] += mat(i, j)*colVec[j]; + result[i] += mat(i, j)*x[j]; } } @@ -69,21 +68,20 @@ Foam::tmp> Foam::Matrix::rightMultiplyImpl template template -Foam::tmp> Foam::Matrix::leftMultiplyImpl +Foam::tmp> Foam::Matrix::TmulImpl ( - const ListType& rowVec + const ListType& x ) const { const Matrix& mat = *this; #ifdef FULLDEBUG - if (rowVec.size() != mat.m()) + if (mat.m() != x.size()) { FatalErrorInFunction << "Attempt to multiply incompatible Matrix and Vector:" << nl << "Matrix : (" << mat.m() << ", " << mat.n() << ')' << nl - << "Vector : " << rowVec.size() << " columns" << nl - << "The number of Matrix rows must equal the Vector size" << nl + << "Matrix rows != Vector size (" << x.size() << ')' << nl << abort(FatalError); } #endif @@ -93,7 +91,7 @@ Foam::tmp> Foam::Matrix::leftMultiplyImpl for (label i = 0; i < mat.m(); ++i) { - const Type& val = rowVec[i]; + const Type& val = x[i]; for (label j = 0; j < mat.n(); ++j) { result[j] += val*mat(i, j); diff --git a/src/OpenFOAM/matrices/Matrix/Matrix.H b/src/OpenFOAM/matrices/Matrix/Matrix.H index 3ef51cbc84..9de6f4f3f0 100644 --- a/src/OpenFOAM/matrices/Matrix/Matrix.H +++ b/src/OpenFOAM/matrices/Matrix/Matrix.H @@ -85,13 +85,13 @@ class Matrix //- Allocate storage for the contents inline void doAlloc(); - //- Multiply matrix with a column vector on the right (A * x) + //- Multiply matrix with vector (A * x) template - tmp> rightMultiplyImpl(const ListType& colVec) const; + tmp> AmulImpl(const ListType& x) const; - //- Multiply matrix with a row vector on the left (x * A) + //- Multiply matrix transpose with vector (AT * x, or x * A) template - tmp> leftMultiplyImpl(const ListType& rowVec) const; + tmp> TmulImpl(const ListType& x) const; public: @@ -310,30 +310,27 @@ public: //- Return the transpose of the matrix Form T() const; - //- Multiply matrix with a column vector on the right (A * x) - inline tmp> rightMultiply + //- Multiply matrix with vector (A * x) + inline tmp> Amul ( - const UList& colVec + const UList& x ) const; - //- Multiply matrix with a column vector on the right (A * x) + //- Multiply matrix with vector (A * x) template - inline tmp> rightMultiply + inline tmp> Amul ( - const IndirectListBase& colVec + const IndirectListBase& x ) const; - //- Multiply matrix with a row vector on the left (x * A) - inline tmp> leftMultiply - ( - const UList& rowVec - ) const; + //- Multiply matrix transpose with vector (AT * x, or x * A) + inline tmp> Tmul(const UList& x) const; - //- Multiply matrix with a row vector on the left (x * A) + //- Multiply matrix transpose with vector (AT * x, or x * A) template - inline tmp> leftMultiply + inline tmp> Tmul ( - const IndirectListBase& rowVec + const IndirectListBase& x ) const; diff --git a/src/OpenFOAM/matrices/Matrix/MatrixI.H b/src/OpenFOAM/matrices/Matrix/MatrixI.H index 8abd40af82..a3edc704e6 100644 --- a/src/OpenFOAM/matrices/Matrix/MatrixI.H +++ b/src/OpenFOAM/matrices/Matrix/MatrixI.H @@ -404,44 +404,44 @@ void Foam::Matrix::shallowResize(const label m, const label n) template -inline Foam::tmp> Foam::Matrix::rightMultiply +inline Foam::tmp> Foam::Matrix::Amul ( - const UList& colVec + const UList& x ) const { - return this->rightMultiplyImpl(colVec); + return this->AmulImpl(x); } template template -inline Foam::tmp> Foam::Matrix::rightMultiply +inline Foam::tmp> Foam::Matrix::Amul ( - const IndirectListBase& colVec + const IndirectListBase& x ) const { - return this->rightMultiplyImpl(colVec); + return this->AmulImpl(x); } template -inline Foam::tmp> Foam::Matrix::leftMultiply +inline Foam::tmp> Foam::Matrix::Tmul ( - const UList& rowVec + const UList& x ) const { - return this->leftMultiplyImpl(rowVec); + return this->TmulImpl(x); } template template -inline Foam::tmp> Foam::Matrix::leftMultiply +inline Foam::tmp> Foam::Matrix::Tmul ( - const IndirectListBase& rowVec + const IndirectListBase& x ) const { - return this->leftMultiplyImpl(rowVec); + return this->TmulImpl(x); } @@ -546,7 +546,7 @@ inline Foam::tmp> Foam::operator* const UList& x ) { - mat.rightMultiply(x); + return mat.Amul(x); } @@ -557,7 +557,7 @@ inline Foam::tmp> Foam::operator* const IndirectListBase& x ) { - mat.rightMultiply(x); + return mat.Amul(x); } @@ -568,7 +568,7 @@ inline Foam::tmp> Foam::operator* const Matrix& mat ) { - mat.leftMultiply(x); + return mat.Tmul(x); } @@ -579,7 +579,7 @@ inline Foam::tmp> Foam::operator* const Matrix& mat ) { - mat.leftMultiply(x); + return mat.Tmul(x); }