Commit 9bbf0957 authored by Henry Weller's avatar Henry Weller
Browse files

SquareMatrix: Add setSize and assignment to identity

parent 0ce35860
......@@ -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)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment