mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: rename dense matrix multiply methods
- make names consistent with lduMatrix
A*x => Matrix::Amul
AT*x => Matrix::Tmul (same as x*A)
This commit is contained in:
committed by
Andrew Heather
parent
8e5e4180d3
commit
46dcba1b44
@ -33,21 +33,20 @@ License
|
||||
|
||||
template<class Form, class Type>
|
||||
template<class ListType>
|
||||
Foam::tmp<Foam::Field<Type>> Foam::Matrix<Form, Type>::rightMultiplyImpl
|
||||
Foam::tmp<Foam::Field<Type>> Foam::Matrix<Form, Type>::AmulImpl
|
||||
(
|
||||
const ListType& colVec
|
||||
const ListType& x
|
||||
) const
|
||||
{
|
||||
const Matrix<Form, Type>& 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::Field<Type>> Foam::Matrix<Form, Type>::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::Field<Type>> Foam::Matrix<Form, Type>::rightMultiplyImpl
|
||||
|
||||
template<class Form, class Type>
|
||||
template<class ListType>
|
||||
Foam::tmp<Foam::Field<Type>> Foam::Matrix<Form, Type>::leftMultiplyImpl
|
||||
Foam::tmp<Foam::Field<Type>> Foam::Matrix<Form, Type>::TmulImpl
|
||||
(
|
||||
const ListType& rowVec
|
||||
const ListType& x
|
||||
) const
|
||||
{
|
||||
const Matrix<Form, Type>& 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::Field<Type>> Foam::Matrix<Form, Type>::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);
|
||||
|
||||
@ -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<class ListType>
|
||||
tmp<Field<Type>> rightMultiplyImpl(const ListType& colVec) const;
|
||||
tmp<Field<Type>> 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<class ListType>
|
||||
tmp<Field<Type>> leftMultiplyImpl(const ListType& rowVec) const;
|
||||
tmp<Field<Type>> 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<Field<Type>> rightMultiply
|
||||
//- Multiply matrix with vector (A * x)
|
||||
inline tmp<Field<Type>> Amul
|
||||
(
|
||||
const UList<Type>& colVec
|
||||
const UList<Type>& x
|
||||
) const;
|
||||
|
||||
//- Multiply matrix with a column vector on the right (A * x)
|
||||
//- Multiply matrix with vector (A * x)
|
||||
template<class Addr>
|
||||
inline tmp<Field<Type>> rightMultiply
|
||||
inline tmp<Field<Type>> Amul
|
||||
(
|
||||
const IndirectListBase<Type, Addr>& colVec
|
||||
const IndirectListBase<Type, Addr>& x
|
||||
) const;
|
||||
|
||||
//- Multiply matrix with a row vector on the left (x * A)
|
||||
inline tmp<Field<Type>> leftMultiply
|
||||
(
|
||||
const UList<Type>& rowVec
|
||||
) const;
|
||||
//- Multiply matrix transpose with vector (AT * x, or x * A)
|
||||
inline tmp<Field<Type>> Tmul(const UList<Type>& x) const;
|
||||
|
||||
//- Multiply matrix with a row vector on the left (x * A)
|
||||
//- Multiply matrix transpose with vector (AT * x, or x * A)
|
||||
template<class Addr>
|
||||
inline tmp<Field<Type>> leftMultiply
|
||||
inline tmp<Field<Type>> Tmul
|
||||
(
|
||||
const IndirectListBase<Type, Addr>& rowVec
|
||||
const IndirectListBase<Type, Addr>& x
|
||||
) const;
|
||||
|
||||
|
||||
|
||||
@ -404,44 +404,44 @@ void Foam::Matrix<Form, Type>::shallowResize(const label m, const label n)
|
||||
|
||||
|
||||
template<class Form, class Type>
|
||||
inline Foam::tmp<Foam::Field<Type>> Foam::Matrix<Form, Type>::rightMultiply
|
||||
inline Foam::tmp<Foam::Field<Type>> Foam::Matrix<Form, Type>::Amul
|
||||
(
|
||||
const UList<Type>& colVec
|
||||
const UList<Type>& x
|
||||
) const
|
||||
{
|
||||
return this->rightMultiplyImpl(colVec);
|
||||
return this->AmulImpl(x);
|
||||
}
|
||||
|
||||
|
||||
template<class Form, class Type>
|
||||
template<class Addr>
|
||||
inline Foam::tmp<Foam::Field<Type>> Foam::Matrix<Form, Type>::rightMultiply
|
||||
inline Foam::tmp<Foam::Field<Type>> Foam::Matrix<Form, Type>::Amul
|
||||
(
|
||||
const IndirectListBase<Type, Addr>& colVec
|
||||
const IndirectListBase<Type, Addr>& x
|
||||
) const
|
||||
{
|
||||
return this->rightMultiplyImpl(colVec);
|
||||
return this->AmulImpl(x);
|
||||
}
|
||||
|
||||
|
||||
template<class Form, class Type>
|
||||
inline Foam::tmp<Foam::Field<Type>> Foam::Matrix<Form, Type>::leftMultiply
|
||||
inline Foam::tmp<Foam::Field<Type>> Foam::Matrix<Form, Type>::Tmul
|
||||
(
|
||||
const UList<Type>& rowVec
|
||||
const UList<Type>& x
|
||||
) const
|
||||
{
|
||||
return this->leftMultiplyImpl(rowVec);
|
||||
return this->TmulImpl(x);
|
||||
}
|
||||
|
||||
|
||||
template<class Form, class Type>
|
||||
template<class Addr>
|
||||
inline Foam::tmp<Foam::Field<Type>> Foam::Matrix<Form, Type>::leftMultiply
|
||||
inline Foam::tmp<Foam::Field<Type>> Foam::Matrix<Form, Type>::Tmul
|
||||
(
|
||||
const IndirectListBase<Type, Addr>& rowVec
|
||||
const IndirectListBase<Type, Addr>& x
|
||||
) const
|
||||
{
|
||||
return this->leftMultiplyImpl(rowVec);
|
||||
return this->TmulImpl(x);
|
||||
}
|
||||
|
||||
|
||||
@ -546,7 +546,7 @@ inline Foam::tmp<Foam::Field<Type>> Foam::operator*
|
||||
const UList<Type>& x
|
||||
)
|
||||
{
|
||||
mat.rightMultiply(x);
|
||||
return mat.Amul(x);
|
||||
}
|
||||
|
||||
|
||||
@ -557,7 +557,7 @@ inline Foam::tmp<Foam::Field<Type>> Foam::operator*
|
||||
const IndirectListBase<Type, Addr>& x
|
||||
)
|
||||
{
|
||||
mat.rightMultiply(x);
|
||||
return mat.Amul(x);
|
||||
}
|
||||
|
||||
|
||||
@ -568,7 +568,7 @@ inline Foam::tmp<Foam::Field<Type>> Foam::operator*
|
||||
const Matrix<Form, Type>& mat
|
||||
)
|
||||
{
|
||||
mat.leftMultiply(x);
|
||||
return mat.Tmul(x);
|
||||
}
|
||||
|
||||
|
||||
@ -579,7 +579,7 @@ inline Foam::tmp<Foam::Field<Type>> Foam::operator*
|
||||
const Matrix<Form, Type>& mat
|
||||
)
|
||||
{
|
||||
mat.leftMultiply(x);
|
||||
return mat.Tmul(x);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user