mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
SquareMatrix: Add setSize and assignment to identity
This commit is contained in:
@ -99,7 +99,7 @@ public:
|
||||
|
||||
// Member operators
|
||||
|
||||
//- Assignment of all entries to zero
|
||||
//- Assignment of all elements to zero
|
||||
void operator=(const zero);
|
||||
};
|
||||
|
||||
|
||||
@ -106,10 +106,21 @@ public:
|
||||
inline autoPtr<SquareMatrix<Type>> clone() const;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Edit
|
||||
|
||||
//- Resize the matrix preserving the elements
|
||||
inline void setSize(const label m);
|
||||
|
||||
|
||||
// Member operators
|
||||
|
||||
//- Assignment of all entries to zero
|
||||
//- Assignment of all elements to zero
|
||||
void operator=(const zero);
|
||||
|
||||
//- Assignment elements to the
|
||||
void operator=(const Identity<Type>);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -152,6 +152,15 @@ Foam::SquareMatrix<Type>::clone() const
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
inline void Foam::SquareMatrix<Type>::setSize(const label m)
|
||||
{
|
||||
Matrix<SquareMatrix<Type>, Type>::setSize(m, m);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
@ -161,6 +170,17 @@ void Foam::SquareMatrix<Type>::operator=(const zero)
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::SquareMatrix<Type>::operator=(const Identity<Type>)
|
||||
{
|
||||
Matrix<SquareMatrix<Type>, Type>::operator=(Zero);
|
||||
for (label i=0; i<this->n(); i++)
|
||||
{
|
||||
this->operator()(i, i) = I;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
|
||||
@ -44,7 +44,7 @@ void Foam::solve
|
||||
label iMax = i;
|
||||
scalar largestCoeff = mag(tmpMatrix[iMax][i]);
|
||||
|
||||
// Swap entries around to find a good pivot
|
||||
// Swap elements around to find a good pivot
|
||||
for (label j=i+1; j<m; j++)
|
||||
{
|
||||
if (mag(tmpMatrix(j, i)) > largestCoeff)
|
||||
|
||||
Reference in New Issue
Block a user