Matrix syntax fixes

This commit is contained in:
Hrvoje Jasak 2010-09-30 23:00:23 +01:00
parent 92e0e64f01
commit 3ce605626a
2 changed files with 19 additions and 29 deletions

View file

@ -25,9 +25,7 @@ License
Class Class
EigenSolver EigenSolver
Description \*---------------------------------------------------------------------------*/
\*----------------------------------------------------------------------------*/
#include "EigenSolver.H" #include "EigenSolver.H"
@ -37,19 +35,8 @@ Description
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class T> template<class T>
void Foam::EigenSolver<T>::checkMatrix(const Matrix<T>& mtx) const void Foam::EigenSolver<T>::checkMatrix(const SquareMatrix<T>& mtx) const
{ {
// Check shape
if (mtx.m() != mtx.n())
{
FatalErrorIn
(
"void EigenSolver<T>::checkMatrix(const Matrix<T>& m) const"
) << "Matrix is not square, cannot calculate eigen-values. "
<< "M = " << mtx.m() << " N = " << mtx.n()
<< abort(FatalError);
}
// Check symmetry // Check symmetry
T assymetry = pTraits<T>::zero; T assymetry = pTraits<T>::zero;
@ -65,7 +52,7 @@ void Foam::EigenSolver<T>::checkMatrix(const Matrix<T>& mtx) const
{ {
FatalErrorIn FatalErrorIn
( (
"void EigenSolver<T>::checkMatrix(const Matrix<T>& m) const" "void EigenSolver<T>::checkMatrix(const SquareMatrix<T>& m) const"
) << "Matrix is not symmetric. Assymetry = " << assymetry ) << "Matrix is not symmetric. Assymetry = " << assymetry
<< abort(FatalError); << abort(FatalError);
} }
@ -73,15 +60,15 @@ void Foam::EigenSolver<T>::checkMatrix(const Matrix<T>& mtx) const
template<class T> template<class T>
void Foam::EigenSolver<T>::factorise(const Matrix<T>& mtx) void Foam::EigenSolver<T>::factorise(const SquareMatrix<T>& mtx)
{ {
// Copy the original matrix into scratch space // Copy the original matrix into scratch space
Matrix<T> a = mtx; SquareMatrix<T> a = mtx;
label n = a.m(); label n = a.m();
// Create and initialise the matrix to hold eigen-vectors in columns // Create and initialise the matrix to hold eigen-vectors in columns
Matrix<T> v(n, n, pTraits<T>::zero); SquareMatrix<T> v(n, pTraits<T>::zero);
for (label ip = 0; ip < n; ip++) for (label ip = 0; ip < n; ip++)
{ {
@ -230,7 +217,10 @@ void Foam::EigenSolver<T>::factorise(const Matrix<T>& mtx)
} // End of main iteration loop } // End of main iteration loop
FatalErrorIn("void Foam::EigenSolver<T>::factorise(const Matrix<T>& mtx)") FatalErrorIn
(
"void EigenSolver<T>::factorise(const SquareMatrix<T>& mtx)"
)
<< "Maximum number of iterations exceeded" << "Maximum number of iterations exceeded"
<< abort(FatalError); << abort(FatalError);
} }
@ -239,12 +229,12 @@ void Foam::EigenSolver<T>::factorise(const Matrix<T>& mtx)
template<class T> template<class T>
inline void Foam::EigenSolver<T>::rotate inline void Foam::EigenSolver<T>::rotate
( (
Matrix<T>& a, SquareMatrix<T>& a,
const T s, const T s,
const T tau, const T tau,
const label i, const label i,
const label j, const label j,
const label k, const label k,
const label l const label l
) const ) const
{ {
@ -260,7 +250,7 @@ inline void Foam::EigenSolver<T>::rotate
// Construct from components // Construct from components
template<class T> template<class T>
Foam::EigenSolver<T>::EigenSolver(const Matrix<T>& mtx) Foam::EigenSolver<T>::EigenSolver(const SquareMatrix<T>& mtx)
: :
values_(mtx.m(), pTraits<T>::zero), values_(mtx.m(), pTraits<T>::zero),
vectors_(mtx.m()) vectors_(mtx.m())

View file

@ -36,7 +36,7 @@ SourceFiles
#ifndef EigenSolver_H #ifndef EigenSolver_H
#define EigenSolver_H #define EigenSolver_H
#include "Matrix.H" #include "SquareMatrix.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -71,15 +71,15 @@ class EigenSolver
//- Check matrix for shape and symmetry //- Check matrix for shape and symmetry
void checkMatrix(const Matrix<T>& mtx) const; void checkMatrix(const SquareMatrix<T>& mtx) const;
//- Factorise into eigen-values and eigen-vectors //- Factorise into eigen-values and eigen-vectors
void factorise(const Matrix<T>& mtx); void factorise(const SquareMatrix<T>& mtx);
//- Rotate the matrix //- Rotate the matrix
inline void rotate inline void rotate
( (
Matrix<T>& a, SquareMatrix<T>& a,
const T s, const T s,
const T tau, const T tau,
const label i, const label i,
@ -97,7 +97,7 @@ public:
// Constructors // Constructors
//- Construct from matrix //- Construct from matrix
EigenSolver(const Matrix<T>& mtx); EigenSolver(const SquareMatrix<T>& mtx);
// Destructor - default // Destructor - default