Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
Nektar::NekMatrix< DataType, StandardMatrixTag > Class Template Reference

Standard Matrix. More...

#include <StandardMatrix.hpp>

Inheritance diagram for Nektar::NekMatrix< DataType, StandardMatrixTag >:
Inheritance graph
[legend]
Collaboration diagram for Nektar::NekMatrix< DataType, StandardMatrixTag >:
Collaboration graph
[legend]

Classes

class  iterator_impl
class  Proxy

Public Types

typedef Matrix< DataType > BaseType
typedef NekMatrix< DataType,
StandardMatrixTag > 
ThisType
typedef DataType NumberType
typedef const DataType & ConstGetValueType
typedef DataType GetValueType
typedef iterator_impl< const
DataType, const ThisType
const_iterator
typedef iterator_impl
< DataType, ThisType
iterator

Public Member Functions

 NekMatrix ()
 Creates an empty matrix.
 NekMatrix (unsigned int rows, unsigned int columns, MatrixStorage policy=eFULL, unsigned int subDiagonals=std::numeric_limits< unsigned int >::max(), unsigned int superDiagonals=std::numeric_limits< unsigned int >::max())
 Creates a rows by columns matrix.
 NekMatrix (unsigned int rows, unsigned int columns, MatrixStorage policy, unsigned int subDiagonals, unsigned int superDiagonals, unsigned int capacity)
 NekMatrix (unsigned int rows, unsigned int columns, typename boost::call_traits< DataType >::const_reference initValue, MatrixStorage policy=eFULL, unsigned int subDiagonals=std::numeric_limits< unsigned int >::max(), unsigned int superDiagonals=std::numeric_limits< unsigned int >::max())
 Creates a rows by columns matrix.
 NekMatrix (unsigned int rows, unsigned int columns, const DataType *data, MatrixStorage policy=eFULL, unsigned int subDiagonals=std::numeric_limits< unsigned int >::max(), unsigned int superDiagonals=std::numeric_limits< unsigned int >::max())
 Creates a rows by columns matrix.
 NekMatrix (unsigned int rows, unsigned int columns, const Array< OneD, const DataType > &d, MatrixStorage policy=eFULL, unsigned int subDiagonals=std::numeric_limits< unsigned int >::max(), unsigned int superDiagonals=std::numeric_limits< unsigned int >::max())
 Creates a rows by columns matrix.
 NekMatrix (unsigned int rows, unsigned int columns, const Array< OneD, DataType > &d, PointerWrapper wrapperType=eCopy, MatrixStorage policy=eFULL, unsigned int subDiagonals=std::numeric_limits< unsigned int >::max(), unsigned int superDiagonals=std::numeric_limits< unsigned int >::max())
 Creates a rows by columns matrix.
 NekMatrix (const ThisType &rhs)
MatrixStorage GetType () const
ThisTypeoperator= (const ThisType &rhs)
template<typename InnerMatrixType >
ThisTypeoperator= (const NekMatrix< InnerMatrixType, ScaledMatrixTag > &rhs)
ConstGetValueType operator() (unsigned int row, unsigned int column) const
 Returns the element value at the given row and column.
ConstGetValueType operator() (unsigned int row, unsigned int column, char transpose) const
 Returns the element value at the given row and column.
unsigned int GetRequiredStorageSize () const
unsigned int CalculateIndex (unsigned int row, unsigned int col, const char transpose) const
boost::call_traits< DataType >
::const_reference 
GetValue (unsigned int row, unsigned int column) const
 Returns the element value at the given row and column.
ConstGetValueType GetValue (unsigned int row, unsigned int column, char transpose) const
 Returns the element value at the given row and column.
const Array< OneD, const
DataType > & 
GetPtr () const
DataType Scale () const
 Returns the scaling used by this matrix.
const DataType * GetRawPtr () const
iterator begin ()
iterator begin (char transpose)
iterator end ()
iterator end (char transpose)
const_iterator begin () const
const_iterator begin (char transpose) const
const_iterator end () const
const_iterator end (char transpose) const
unsigned int GetStorageSize () const
unsigned int GetNumberOfSubDiagonals () const
unsigned int GetNumberOfSuperDiagonals () const
unsigned int CalculateNumberOfRows () const
bool operator== (const NekMatrix< DataType, StandardMatrixTag > &rhs) const
 Returns true if the this matrix and rhs are equivalent.
PointerWrapper GetWrapperType () const
char GetTransposeFlag () const
boost::tuples::tuple< unsigned
int, unsigned int > 
Advance (unsigned int curRow, unsigned int curColumn) const
boost::tuples::tuple< unsigned
int, unsigned int > 
Advance (unsigned int curRow, unsigned int curColumn, char transpose) const
void SetSize (unsigned int rows, unsigned int cols)
Proxy operator() (unsigned int row, unsigned int column)
Proxy operator() (unsigned int row, unsigned int column, char transpose)
void SetValue (unsigned int row, unsigned int column, typename boost::call_traits< DataType >::const_reference d)
void SetValue (unsigned int row, unsigned int column, typename boost::call_traits< DataType >::const_reference d, char transpose)
Array< OneD, DataType > & GetPtr ()
DataType * GetRawPtr ()
NekDouble AbsMaxtoMinEigenValueRatio (void)
void EigenSolve (Array< OneD, NekDouble > &EigValReal, Array< OneD, NekDouble > &EigValImag, Array< OneD, NekDouble > &EigVecs=NullNekDouble1DArray)
void Invert ()
Array< OneD, DataType > & GetTempSpace ()
void SwapTempAndDataBuffers ()
ThisTypeoperator*= (const NumberType &s)
NekMatrix< DataType,
StandardMatrixTag > 
operator- () const
- Public Member Functions inherited from Nektar::Matrix< DataType >
virtual ~Matrix ()
- Public Member Functions inherited from Nektar::ConstMatrix< DataType >
virtual ~ConstMatrix ()
MatrixStorage GetStorageType () const
unsigned int GetRows () const
unsigned int GetTransposedRows (char transpose) const
unsigned int GetColumns () const
unsigned int GetTransposedColumns (char transpose) const
const unsigned int * GetSize () const
void Transpose ()

Static Public Member Functions

static ThisType CreateWrapper (const ThisType &rhs)
static boost::shared_ptr
< ThisType
CreateWrapper (const boost::shared_ptr< ThisType > &rhs)

Protected Member Functions

 NekMatrix (const ThisType &rhs, PointerWrapper wrapperType)
Array< OneD, DataType > & GetData ()
void RemoveExcessCapacity ()
void ResizeDataArrayIfNeeded (unsigned int requiredStorageSize)
void ResizeDataArrayIfNeeded ()
- Protected Member Functions inherited from Nektar::Matrix< DataType >
 Matrix (unsigned int rows, unsigned int columns)
 Matrix (const Matrix< DataType > &rhs)
Matrix< DataType > & operator= (const Matrix< DataType > &rhs)
Matrix< DataType > & operator= (const ConstMatrix< DataType > &rhs)
- Protected Member Functions inherited from Nektar::ConstMatrix< DataType >
 ConstMatrix (unsigned int rows, unsigned int columns)
 ConstMatrix (const ConstMatrix< DataType > &rhs)
void Resize (unsigned int rows, unsigned int columns)
 Resets the rows and columns in the array. This method does not update the data storage to match the new row and column counts.
void SetTransposeFlag (char newValue)
char GetRawTransposeFlag () const

Private Member Functions

void PerformCopyConstruction (const ThisType &rhs)
virtual boost::call_traits
< DataType >::value_type 
v_GetValue (unsigned int row, unsigned int column) const
virtual unsigned int v_GetStorageSize () const
virtual MatrixStorage v_GetStorageType () const
virtual void v_SetValue (unsigned int row, unsigned int column, typename boost::call_traits< DataType >::const_reference d)

Private Attributes

Array< OneD, DataType > m_data
PointerWrapper m_wrapperType
MatrixStorage m_storagePolicy
unsigned int m_numberOfSuperDiagonals
unsigned int m_numberOfSubDiagonals
Array< OneD, DataType > m_tempSpace

Detailed Description

template<typename DataType>
class Nektar::NekMatrix< DataType, StandardMatrixTag >

Standard Matrix.

Parameters
DataTypeThe type stored in each element.

Matrices are stored in column major order to make it easier to interoperate with Blas and Lapack.

Definition at line 63 of file StandardMatrix.hpp.

Member Typedef Documentation

template<typename DataType >
typedef Matrix<DataType> Nektar::NekMatrix< DataType, StandardMatrixTag >::BaseType

Definition at line 66 of file StandardMatrix.hpp.

template<typename DataType >
typedef iterator_impl<const DataType, const ThisType> Nektar::NekMatrix< DataType, StandardMatrixTag >::const_iterator

Definition at line 476 of file StandardMatrix.hpp.

template<typename DataType >
typedef const DataType& Nektar::NekMatrix< DataType, StandardMatrixTag >::ConstGetValueType

Definition at line 69 of file StandardMatrix.hpp.

template<typename DataType >
typedef DataType Nektar::NekMatrix< DataType, StandardMatrixTag >::GetValueType

Definition at line 70 of file StandardMatrix.hpp.

template<typename DataType >
typedef iterator_impl<DataType, ThisType> Nektar::NekMatrix< DataType, StandardMatrixTag >::iterator

Definition at line 477 of file StandardMatrix.hpp.

template<typename DataType >
typedef DataType Nektar::NekMatrix< DataType, StandardMatrixTag >::NumberType

Definition at line 68 of file StandardMatrix.hpp.

template<typename DataType >
typedef NekMatrix<DataType, StandardMatrixTag> Nektar::NekMatrix< DataType, StandardMatrixTag >::ThisType

Definition at line 67 of file StandardMatrix.hpp.

Constructor & Destructor Documentation

template<typename DataType >
Nektar::NekMatrix< DataType, StandardMatrixTag >::NekMatrix ( )

Creates an empty matrix.

Definition at line 40 of file StandardMatrix.cpp.

:
Matrix<DataType>(0, 0),
m_data(),
m_numberOfSuperDiagonals(std::numeric_limits<unsigned int>::max()),
m_numberOfSubDiagonals(std::numeric_limits<unsigned int>::max()),
{
m_data = Array<OneD, DataType>(GetRequiredStorageSize());
}
template<typename DataType >
Nektar::NekMatrix< DataType, StandardMatrixTag >::NekMatrix ( unsigned int  rows,
unsigned int  columns,
MatrixStorage  policy = eFULL,
unsigned int  subDiagonals = std::numeric_limits<unsigned int>::max(),
unsigned int  superDiagonals = std::numeric_limits<unsigned int>::max() 
)

Creates a rows by columns matrix.

rows The number of rows in the matrix. columns The number of columns in the matrix.

Definition at line 53 of file StandardMatrix.cpp.

:
Matrix<DataType>(rows, columns),
m_data(),
m_storagePolicy(policy),
m_numberOfSuperDiagonals(superDiagonals),
m_numberOfSubDiagonals(subDiagonals),
{
m_data = Array<OneD, DataType>(GetRequiredStorageSize());
}
template<typename DataType >
Nektar::NekMatrix< DataType, StandardMatrixTag >::NekMatrix ( unsigned int  rows,
unsigned int  columns,
MatrixStorage  policy,
unsigned int  subDiagonals,
unsigned int  superDiagonals,
unsigned int  capacity 
)

Definition at line 68 of file StandardMatrix.cpp.

:
Matrix<DataType>(rows, columns),
m_data(),
m_storagePolicy(policy),
m_numberOfSuperDiagonals(superDiagonals),
m_numberOfSubDiagonals(subDiagonals),
{
unsigned int requiredStorage = this->GetRequiredStorageSize();
unsigned int actualSize = std::max(requiredStorage, capacity);
m_data = Array<OneD, DataType>(actualSize);
}
template<typename DataType >
Nektar::NekMatrix< DataType, StandardMatrixTag >::NekMatrix ( unsigned int  rows,
unsigned int  columns,
typename boost::call_traits< DataType >::const_reference  initValue,
MatrixStorage  policy = eFULL,
unsigned int  subDiagonals = std::numeric_limits<unsigned int>::max(),
unsigned int  superDiagonals = std::numeric_limits<unsigned int>::max() 
)

Creates a rows by columns matrix.

rows The number of rows in the matrix. columns The number of columns in the matrix. initValue The value used to initialize each element. policySpecificData Data the is specific to the storage type assigned to this matrix. Check MatrixStoragePolicy<StorageType> to see if the StoragePolicy for this matrix has policy specific data.

Definition at line 87 of file StandardMatrix.cpp.

:
Matrix<DataType>(rows, columns),
m_data(),
m_storagePolicy(policy),
m_numberOfSuperDiagonals(superDiagonals),
m_numberOfSubDiagonals(subDiagonals),
{
m_data = Array<OneD, DataType>(GetRequiredStorageSize());
std::fill(m_data.begin(), m_data.end(), initValue);
}
template<typename DataType >
Nektar::NekMatrix< DataType, StandardMatrixTag >::NekMatrix ( unsigned int  rows,
unsigned int  columns,
const DataType *  data,
MatrixStorage  policy = eFULL,
unsigned int  subDiagonals = std::numeric_limits<unsigned int>::max(),
unsigned int  superDiagonals = std::numeric_limits<unsigned int>::max() 
)

Creates a rows by columns matrix.

rows The number of rows in the matrix. columns The number of columns in the matrix. data An array of data use to initialize the matrix. policySpecificData Data the is specific to the storage type assigned to this matrix. Check MatrixStoragePolicy<StorageType> to see if the StoragePolicy for this matrix has policy specific data.

Definition at line 104 of file StandardMatrix.cpp.

:
Matrix<DataType>(rows, columns),
m_data(),
m_storagePolicy(policy),
m_numberOfSuperDiagonals(superDiagonals),
m_numberOfSubDiagonals(subDiagonals),
{
unsigned int size = GetRequiredStorageSize();
m_data = Array<OneD, DataType>(size);
std::copy(data, data + size, m_data.begin());
}
template<typename DataType >
Nektar::NekMatrix< DataType, StandardMatrixTag >::NekMatrix ( unsigned int  rows,
unsigned int  columns,
const Array< OneD, const DataType > &  d,
MatrixStorage  policy = eFULL,
unsigned int  subDiagonals = std::numeric_limits<unsigned int>::max(),
unsigned int  superDiagonals = std::numeric_limits<unsigned int>::max() 
)

Creates a rows by columns matrix.

rows The number of rows in the matrix. columns The number of columns in the matrix. d An array of data used to initialize the matrix. Values from d are copied into the matrix. policySpecificData Data the is specific to the storage type assigned to this matrix. Check MatrixStoragePolicy<StorageType> to see if the StoragePolicy for this matrix has policy specific data.

Definition at line 122 of file StandardMatrix.cpp.

References Nektar::CopyArrayN(), and Nektar::Array< OneD, const DataType >::num_elements().

:
Matrix<DataType>(rows, columns),
m_data(),
m_storagePolicy(policy),
m_numberOfSuperDiagonals(superDiagonals),
m_numberOfSubDiagonals(subDiagonals),
{
m_data = Array<OneD, DataType>(GetRequiredStorageSize());
}
template<typename DataType >
Nektar::NekMatrix< DataType, StandardMatrixTag >::NekMatrix ( unsigned int  rows,
unsigned int  columns,
const Array< OneD, DataType > &  d,
PointerWrapper  wrapperType = eCopy,
MatrixStorage  policy = eFULL,
unsigned int  subDiagonals = std::numeric_limits<unsigned int>::max(),
unsigned int  superDiagonals = std::numeric_limits<unsigned int>::max() 
)

Creates a rows by columns matrix.

rows The number of rows in the matrix. columns The number of columns in the matrix. d An array of data used to initialize the matrix. If wrapperType is eCopy, then each element is copied from d to the matrix. If wrapperType is eWrapper, then the matrix uses d directly as its matrix data and no copies are made. policySpecificData Data the is specific to the storage type assigned to this matrix. Check MatrixStoragePolicy<StorageType> to see if the StoragePolicy for this matrix has policy specific data.

Definition at line 139 of file StandardMatrix.cpp.

References Nektar::CopyArrayN(), Nektar::eVECTOR_WRAPPER, Nektar::eWrapper, and Nektar::Array< OneD, const DataType >::num_elements().

:
Matrix<DataType>(rows, columns),
m_data(),
m_wrapperType(wrapperType),
m_storagePolicy(policy),
m_numberOfSuperDiagonals(superDiagonals),
m_numberOfSubDiagonals(subDiagonals),
{
if( wrapperType == eWrapper )
{
m_data = Array<OneD, DataType>(d, eVECTOR_WRAPPER);
}
else
{
m_data = Array<OneD, DataType>(GetRequiredStorageSize());
}
}
template<typename DataType >
Nektar::NekMatrix< DataType, StandardMatrixTag >::NekMatrix ( const ThisType rhs)

Definition at line 163 of file StandardMatrix.cpp.

:
Matrix<DataType>(rhs),
m_data(),
m_wrapperType(rhs.m_wrapperType),
m_storagePolicy(rhs.m_storagePolicy),
m_numberOfSuperDiagonals(rhs.m_numberOfSuperDiagonals),
m_numberOfSubDiagonals(rhs.m_numberOfSubDiagonals),
{
}
template<typename DataType >
Nektar::NekMatrix< DataType, StandardMatrixTag >::NekMatrix ( const ThisType rhs,
PointerWrapper  wrapperType 
)
protected

Definition at line 480 of file StandardMatrix.cpp.

:
BaseType(rhs),
m_data(),
m_wrapperType(wrapperType),
m_storagePolicy(rhs.m_storagePolicy),
m_numberOfSuperDiagonals(rhs.m_numberOfSuperDiagonals),
m_numberOfSubDiagonals(rhs.m_numberOfSubDiagonals)
{
}

Member Function Documentation

template<typename DataType >
NekDouble Nektar::NekMatrix< DataType, StandardMatrixTag >::AbsMaxtoMinEigenValueRatio ( void  )

Definition at line 701 of file StandardMatrix.cpp.

References Vmath::Vadd(), Vmath::Vmax(), Vmath::Vmin(), and Vmath::Vmul().

{
NekDouble returnval;
int nvals = this->GetColumns();
Array<OneD, NekDouble> EigValReal(nvals);
Array<OneD, NekDouble> EigValImag(nvals);
EigenSolve(EigValReal,EigValImag);
Vmath::Vmul(nvals,EigValReal,1,EigValReal,1,EigValReal,1);
Vmath::Vmul(nvals,EigValImag,1,EigValImag,1,EigValImag,1);
Vmath::Vadd(nvals,EigValReal,1,EigValImag,1,EigValReal,1);
returnval = sqrt(Vmath::Vmax(nvals,EigValReal,1)/Vmath::Vmin(nvals,EigValReal,1));
return returnval;
}
template<typename DataType >
boost::tuples::tuple< unsigned int, unsigned int > Nektar::NekMatrix< DataType, StandardMatrixTag >::Advance ( unsigned int  curRow,
unsigned int  curColumn 
) const

Definition at line 409 of file StandardMatrix.cpp.

{
return Advance(curRow, curColumn, this->GetTransposeFlag());
}
template<typename DataType >
boost::tuples::tuple< unsigned int, unsigned int > Nektar::NekMatrix< DataType, StandardMatrixTag >::Advance ( unsigned int  curRow,
unsigned int  curColumn,
char  transpose 
) const

Definition at line 416 of file StandardMatrix.cpp.

References Nektar::BandedMatrixFuncs::Advance(), Nektar::FullMatrixFuncs::Advance(), Nektar::UpperTriangularMatrixFuncs::Advance(), Nektar::LowerTriangularMatrixFuncs::Advance(), Nektar::SymmetricMatrixFuncs::Advance(), Nektar::DiagonalMatrixFuncs::Advance(), Nektar::eBANDED, Nektar::eDIAGONAL, ErrorUtil::efatal, Nektar::eFULL, Nektar::eLOWER_TRIANGULAR, Nektar::eLOWER_TRIANGULAR_BANDED, Nektar::ePOSITIVE_DEFINITE_SYMMETRIC, Nektar::ePOSITIVE_DEFINITE_SYMMETRIC_BANDED, Nektar::eSYMMETRIC, Nektar::eSYMMETRIC_BANDED, Nektar::eUPPER_TRIANGULAR, Nektar::eUPPER_TRIANGULAR_BANDED, and NEKERROR.

{
unsigned int numRows = this->GetTransposedRows(transpose);
unsigned int numColumns = this->GetTransposedColumns(transpose);
{
case eFULL:
numRows, numColumns, curRow, curColumn);
break;
case eDIAGONAL:
numRows, numColumns, curRow, curColumn);
break;
numRows, numColumns, curRow, curColumn);
break;
numRows, numColumns, curRow, curColumn);
break;
case eSYMMETRIC:
numRows, numColumns, curRow, curColumn);
break;
case eBANDED:
numRows, numColumns, curRow, curColumn);
break;
NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
break;
NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
break;
NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
break;
default:
NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
}
return boost::tuples::tuple<unsigned int, unsigned int>(curRow, curColumn);
}
template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::iterator Nektar::NekMatrix< DataType, StandardMatrixTag >::begin ( )

Definition at line 663 of file StandardMatrix.cpp.

Referenced by operator==().

{
return begin(this->GetTransposeFlag());
}
template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::iterator Nektar::NekMatrix< DataType, StandardMatrixTag >::begin ( char  transpose)

Definition at line 669 of file StandardMatrix.cpp.

References Nektar::iterator.

{
if( transpose == 'N' )
{
return iterator(this->GetData().data(), this->GetData().data() + this->GetData().num_elements());
}
else
{
return iterator(this, transpose);
}
}
template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::const_iterator Nektar::NekMatrix< DataType, StandardMatrixTag >::begin ( ) const

Definition at line 285 of file StandardMatrix.cpp.

{
return begin(this->GetTransposeFlag());
}
template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::const_iterator Nektar::NekMatrix< DataType, StandardMatrixTag >::begin ( char  transpose) const

Definition at line 291 of file StandardMatrix.cpp.

{
if( transpose == 'N' )
{
}
else
{
return const_iterator(this, transpose);
}
}
template<typename DataType >
unsigned int Nektar::NekMatrix< DataType, StandardMatrixTag >::CalculateIndex ( unsigned int  row,
unsigned int  col,
const char  transpose 
) const

Definition at line 229 of file StandardMatrix.cpp.

References Nektar::LibUtilities::GetSize().

{
unsigned int numRows = this->GetSize()[0];
unsigned int numColumns = this->GetSize()[1];
return Matrix<DataType>::CalculateIndex(this->GetStorageType(),
row, col, numRows, numColumns, transpose,
}
template<typename DataType >
unsigned int Nektar::NekMatrix< DataType, StandardMatrixTag >::CalculateNumberOfRows ( ) const

Definition at line 363 of file StandardMatrix.cpp.

template<typename DataType >
NekMatrix< DataType, StandardMatrixTag > Nektar::NekMatrix< DataType, StandardMatrixTag >::CreateWrapper ( const ThisType rhs)
static

Definition at line 468 of file StandardMatrix.cpp.

References Nektar::eWrapper.

{
return NekMatrix<DataType, StandardMatrixTag>(rhs, eWrapper);
}
template<typename DataType >
static boost::shared_ptr<ThisType> Nektar::NekMatrix< DataType, StandardMatrixTag >::CreateWrapper ( const boost::shared_ptr< ThisType > &  rhs)
static
template<typename DataType >
void Nektar::NekMatrix< DataType, StandardMatrixTag >::EigenSolve ( Array< OneD, NekDouble > &  EigValReal,
Array< OneD, NekDouble > &  EigValImag,
Array< OneD, NekDouble > &  EigVecs = NullNekDouble1DArray 
)

Definition at line 720 of file StandardMatrix.cpp.

References ASSERTL0, Nektar::eBANDED, Nektar::eDIAGONAL, ErrorUtil::efatal, Nektar::eFULL, Nektar::FullMatrixFuncs::EigenSolve(), Nektar::eLOWER_TRIANGULAR, Nektar::eLOWER_TRIANGULAR_BANDED, Nektar::eSYMMETRIC, Nektar::eSYMMETRIC_BANDED, Nektar::eUPPER_TRIANGULAR, Nektar::eUPPER_TRIANGULAR_BANDED, NEKERROR, Vmath::Vcopy(), and Vmath::Zero().

{
ASSERTL0(this->GetRows()==this->GetColumns(), "Only square matrices can be called");
switch(this->GetType())
{
case eFULL:
this->GetData(), EigValReal,
EigValImag, EigVecs);
break;
case eDIAGONAL:
Vmath::Vcopy(this->GetRows(),&(this->GetData())[0],1, &EigValReal[0],1);
Vmath::Zero(this->GetRows(),&EigValImag[0],1);
break;
case eSYMMETRIC:
case eBANDED:
NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
break;
default:
NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
}
}
template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::iterator Nektar::NekMatrix< DataType, StandardMatrixTag >::end ( )

Definition at line 682 of file StandardMatrix.cpp.

{
return end(this->GetTransposeFlag());
}
template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::iterator Nektar::NekMatrix< DataType, StandardMatrixTag >::end ( char  transpose)

Definition at line 688 of file StandardMatrix.cpp.

References Nektar::iterator.

{
if( transpose == 'N' )
{
return iterator(this->GetData().data(), this->GetData().data() + this->GetData().num_elements(), true);
}
else
{
return iterator(this, transpose, true);
}
}
template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::const_iterator Nektar::NekMatrix< DataType, StandardMatrixTag >::end ( ) const

Definition at line 304 of file StandardMatrix.cpp.

{
return end(this->GetTransposeFlag());
}
template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::const_iterator Nektar::NekMatrix< DataType, StandardMatrixTag >::end ( char  transpose) const

Definition at line 310 of file StandardMatrix.cpp.

{
if( transpose == 'N' )
{
}
else
{
return const_iterator(this, transpose, true);
}
}
template<typename DataType >
Array< OneD, DataType > & Nektar::NekMatrix< DataType, StandardMatrixTag >::GetData ( )
protected

Definition at line 493 of file StandardMatrix.cpp.

{ return m_data; }
template<typename DataType >
unsigned int Nektar::NekMatrix< DataType, StandardMatrixTag >::GetNumberOfSubDiagonals ( ) const

Definition at line 329 of file StandardMatrix.cpp.

Referenced by Nektar::Transpose().

{
if( m_numberOfSubDiagonals != std::numeric_limits<unsigned int>::max() )
{
}
else if( this->GetRows() > 0 )
{
return this->GetRows()-1;
}
else
{
return 0;
}
}
template<typename DataType >
unsigned int Nektar::NekMatrix< DataType, StandardMatrixTag >::GetNumberOfSuperDiagonals ( ) const

Definition at line 346 of file StandardMatrix.cpp.

Referenced by Nektar::Transpose().

{
if( m_numberOfSuperDiagonals != std::numeric_limits<unsigned int>::max() )
{
}
else if( this->GetRows() > 0 )
{
return this->GetRows()-1;
}
else
{
return 0;
}
}
template<typename DataType >
const Array< OneD, const DataType > & Nektar::NekMatrix< DataType, StandardMatrixTag >::GetPtr ( ) const

Definition at line 267 of file StandardMatrix.cpp.

Referenced by Nektar::Transpose().

{
return m_data;
}
template<typename DataType >
Array< OneD, DataType > & Nektar::NekMatrix< DataType, StandardMatrixTag >::GetPtr ( )

Definition at line 651 of file StandardMatrix.cpp.

{
return this->GetData();
}
template<typename DataType >
const DataType * Nektar::NekMatrix< DataType, StandardMatrixTag >::GetRawPtr ( ) const

Definition at line 279 of file StandardMatrix.cpp.

{
return m_data.data();
}
template<typename DataType >
DataType * Nektar::NekMatrix< DataType, StandardMatrixTag >::GetRawPtr ( )

Definition at line 657 of file StandardMatrix.cpp.

{
return this->GetData().data();
}
template<typename DataType >
unsigned int Nektar::NekMatrix< DataType, StandardMatrixTag >::GetRequiredStorageSize ( ) const

Definition at line 221 of file StandardMatrix.cpp.

{
return Matrix<DataType>::GetRequiredStorageSize(this->GetStorageType(),
this->GetRows(), this->GetColumns(),
}
template<typename DataType >
unsigned int Nektar::NekMatrix< DataType, StandardMatrixTag >::GetStorageSize ( ) const

Reimplemented from Nektar::ConstMatrix< DataType >.

Definition at line 323 of file StandardMatrix.cpp.

Referenced by v_GetStorageSize().

{
return m_data.num_elements();
}
template<typename DataType >
Array< OneD, DataType > & Nektar::NekMatrix< DataType, StandardMatrixTag >::GetTempSpace ( )

Definition at line 790 of file StandardMatrix.cpp.

{
if( m_tempSpace.capacity() == 0 )
{
m_tempSpace = Array<OneD, DataType>(this->GetData().capacity());
}
return m_tempSpace;
}
template<typename DataType >
char Nektar::NekMatrix< DataType, StandardMatrixTag >::GetTransposeFlag ( ) const

Reimplemented from Nektar::ConstMatrix< DataType >.

Definition at line 402 of file StandardMatrix.cpp.

Referenced by operator==().

{
return this->GetRawTransposeFlag();
}
template<typename DataType >
MatrixStorage Nektar::NekMatrix< DataType, StandardMatrixTag >::GetType ( ) const

Definition at line 177 of file StandardMatrix.cpp.

Referenced by Nektar::Transpose(), and v_GetStorageType().

{ return m_storagePolicy; }
template<typename DataType >
boost::call_traits< DataType >::const_reference Nektar::NekMatrix< DataType, StandardMatrixTag >::GetValue ( unsigned int  row,
unsigned int  column 
) const

Returns the element value at the given row and column.

Definition at line 239 of file StandardMatrix.cpp.

References ASSERTL2.

{
ASSERTL2(row < this->GetRows(), std::string("Row ") + boost::lexical_cast<std::string>(row) +
std::string(" requested in a matrix with a maximum of ") + boost::lexical_cast<std::string>(this->GetRows()) +
std::string(" rows"));
ASSERTL2(column < this->GetColumns(), std::string("Column ") + boost::lexical_cast<std::string>(column) +
std::string(" requested in a matrix with a maximum of ") + boost::lexical_cast<std::string>(this->GetColumns()) +
std::string(" columns"));
return GetValue(row, column, this->GetTransposeFlag());
}
template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::ConstGetValueType Nektar::NekMatrix< DataType, StandardMatrixTag >::GetValue ( unsigned int  row,
unsigned int  column,
char  transpose 
) const

Returns the element value at the given row and column.

row The element's row. column The element's column. transpose If transpose = 'N', then the return value is element [row, column]. If transpose = 'T', then the return value is element [column, row].

Definition at line 252 of file StandardMatrix.cpp.

{
static DataType defaultReturnValue;
unsigned int index = CalculateIndex(row, column, transpose);
if( index != std::numeric_limits<unsigned int>::max() )
{
return m_data[index];
}
else
{
return defaultReturnValue;
}
}
template<typename DataType >
PointerWrapper Nektar::NekMatrix< DataType, StandardMatrixTag >::GetWrapperType ( ) const

Definition at line 399 of file StandardMatrix.cpp.

{ return m_wrapperType; }
template<typename DataType >
void Nektar::NekMatrix< DataType, StandardMatrixTag >::Invert ( )

Definition at line 753 of file StandardMatrix.cpp.

References ASSERTL0, Nektar::eBANDED, Nektar::eDIAGONAL, ErrorUtil::efatal, Nektar::eFULL, Nektar::eLOWER_TRIANGULAR, Nektar::eLOWER_TRIANGULAR_BANDED, Nektar::eSYMMETRIC, Nektar::eSYMMETRIC_BANDED, Nektar::eUPPER_TRIANGULAR, Nektar::eUPPER_TRIANGULAR_BANDED, Nektar::LibUtilities::Invert(), and NEKERROR.

{
ASSERTL0(this->GetRows()==this->GetColumns(), "Only square matrices can be inverted.");
ASSERTL0(this->GetTransposeFlag()=='N', "Only untransposed matrices may be inverted.");
switch(this->GetType())
{
case eFULL:
this->GetData(), this->GetTransposeFlag());
break;
case eDIAGONAL:
this->GetData());
break;
case eSYMMETRIC:
case eBANDED:
NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
break;
NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
break;
NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
break;
NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
break;
default:
NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
}
}
template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::ConstGetValueType Nektar::NekMatrix< DataType, StandardMatrixTag >::operator() ( unsigned int  row,
unsigned int  column 
) const

Returns the element value at the given row and column.

Reimplemented from Nektar::ConstMatrix< DataType >.

Definition at line 202 of file StandardMatrix.cpp.

References ASSERTL2.

Referenced by v_GetValue().

{
ASSERTL2(row < this->GetRows(), std::string("Row ") + boost::lexical_cast<std::string>(row) +
std::string(" requested in a matrix with a maximum of ") + boost::lexical_cast<std::string>(this->GetRows()) +
std::string(" rows"));
ASSERTL2(column < this->GetColumns(), std::string("Column ") + boost::lexical_cast<std::string>(column) +
std::string(" requested in a matrix with a maximum of ") + boost::lexical_cast<std::string>(this->GetColumns()) +
std::string(" columns"));
return this->GetValue(row, column, this->GetTransposeFlag());
}
template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::ConstGetValueType Nektar::NekMatrix< DataType, StandardMatrixTag >::operator() ( unsigned int  row,
unsigned int  column,
char  transpose 
) const

Returns the element value at the given row and column.

row The element's row. column The element's column. transpose If transpose = 'N', then the return value is element [row, column]. If transpose = 'T', then the return value is element [column, row].

Definition at line 215 of file StandardMatrix.cpp.

{
return this->GetValue(row, column, transpose);
}
template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::Proxy Nektar::NekMatrix< DataType, StandardMatrixTag >::operator() ( unsigned int  row,
unsigned int  column 
)

Definition at line 597 of file StandardMatrix.cpp.

References ASSERTL2.

{
ASSERTL2(row < this->GetRows(), std::string("Row ") + boost::lexical_cast<std::string>(row) +
std::string(" requested in a matrix with a maximum of ") + boost::lexical_cast<std::string>(this->GetRows()) +
std::string(" rows"));
ASSERTL2(column < this->GetColumns(), std::string("Column ") + boost::lexical_cast<std::string>(column) +
std::string(" requested in a matrix with a maximum of ") + boost::lexical_cast<std::string>(this->GetColumns()) +
std::string(" columns"));
return (*this)(row, column, this->GetTransposeFlag());
}
template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::Proxy Nektar::NekMatrix< DataType, StandardMatrixTag >::operator() ( unsigned int  row,
unsigned int  column,
char  transpose 
)

Definition at line 610 of file StandardMatrix.cpp.

{
unsigned int index = this->CalculateIndex(row, column, transpose);
if( index != std::numeric_limits<unsigned int>::max() )
{
return Proxy(this->GetData()[index]);
}
else
{
return Proxy();
}
}
template<typename DataType >
NekMatrix< DataType, StandardMatrixTag > & Nektar::NekMatrix< DataType, StandardMatrixTag >::operator*= ( const NumberType s)

Definition at line 816 of file StandardMatrix.cpp.

{
for(unsigned int i = 0; i < this->GetPtr().num_elements(); ++i)
{
this->GetPtr()[i] *= s;
}
return *this;
}
template<typename DataType >
NekMatrix< DataType, StandardMatrixTag > Nektar::NekMatrix< DataType, StandardMatrixTag >::operator- ( ) const

Definition at line 807 of file StandardMatrix.cpp.

References Nektar::NegateInPlace().

{
NekMatrix<DataType, StandardMatrixTag> result(*this);
NegateInPlace(result);
return result;
}
template<typename DataType >
NekMatrix< DataType, StandardMatrixTag > & Nektar::NekMatrix< DataType, StandardMatrixTag >::operator= ( const ThisType rhs)

Definition at line 180 of file StandardMatrix.cpp.

References Nektar::Array< OneD, DataType >::data(), m_data, m_numberOfSubDiagonals, m_numberOfSuperDiagonals, and m_storagePolicy.

{
if( this == &rhs )
{
return *this;
}
Matrix<DataType>::operator=(rhs);
m_storagePolicy = rhs.m_storagePolicy;
m_numberOfSubDiagonals = rhs.m_numberOfSubDiagonals;
m_numberOfSuperDiagonals = rhs.m_numberOfSuperDiagonals;
unsigned int requiredStorageSize = GetRequiredStorageSize();
std::copy(rhs.m_data.data(), rhs.m_data.data() + requiredStorageSize, m_data.data());
return *this;
}
template<typename DataType >
template<typename InnerMatrixType >
ThisType& Nektar::NekMatrix< DataType, StandardMatrixTag >::operator= ( const NekMatrix< InnerMatrixType, ScaledMatrixTag > &  rhs)
inline

Definition at line 341 of file StandardMatrix.hpp.

{
BaseType::operator=(rhs);
m_storagePolicy = rhs.GetType();
m_numberOfSubDiagonals = rhs.GetNumberOfSubDiagonals();
m_numberOfSuperDiagonals = rhs.GetNumberOfSuperDiagonals();
unsigned int requiredStorageSize = GetRequiredStorageSize();
DataType scale = rhs.Scale();
DataType* lhs_array = m_data.data();
const DataType* rhs_array = rhs.GetRawPtr();
for(unsigned int i = 0; i < requiredStorageSize; ++i)
{
lhs_array[i] = scale*rhs_array[i];
}
return *this;
}
template<typename DataType >
bool Nektar::NekMatrix< DataType, StandardMatrixTag >::operator== ( const NekMatrix< DataType, StandardMatrixTag > &  rhs) const

Returns true if the this matrix and rhs are equivalent.

Two matrices are equivalent if they have the same size and each element is the same.

Definition at line 369 of file StandardMatrix.cpp.

References begin(), Nektar::ConstMatrix< DataType >::GetColumns(), Nektar::ConstMatrix< DataType >::GetRows(), and GetTransposeFlag().

{
if( this->GetRows() != rhs.GetRows() ||
this->GetColumns() != rhs.GetColumns() )
{
return false;
}
if( this->GetTransposeFlag() == rhs.GetTransposeFlag() )
{
return std::equal(begin(), end(), rhs.begin());
}
else
{
for(unsigned int i = 0; i < this->GetRows(); ++i)
{
for(unsigned int j = 0; j < this->GetColumns(); ++j)
{
if( (*this)(i,j) != rhs(i,j) )
{
return false;
}
}
}
}
return true;
}
template<typename DataType >
void Nektar::NekMatrix< DataType, StandardMatrixTag >::PerformCopyConstruction ( const ThisType rhs)
private

Definition at line 542 of file StandardMatrix.cpp.

References Nektar::CopyArrayN(), Nektar::eWrapper, m_data, and Nektar::Array< OneD, const DataType >::num_elements().

{
{
m_data = rhs.m_data;
}
else
{
m_data = Array<OneD, DataType>(GetRequiredStorageSize());
}
}
template<typename DataType >
void Nektar::NekMatrix< DataType, StandardMatrixTag >::RemoveExcessCapacity ( )
protected

Definition at line 496 of file StandardMatrix.cpp.

References ASSERTL0, Nektar::CopyArrayN(), Nektar::eCopy, and Nektar::eWrapper.

{
{
unsigned int requiredStorageSize = GetRequiredStorageSize();
if( m_data.num_elements() > requiredStorageSize )
{
Array<OneD, DataType> newArray(requiredStorageSize);
CopyArrayN(m_data, newArray, requiredStorageSize);
m_data = newArray;
}
}
else if( m_wrapperType == eWrapper )
{
ASSERTL0(true, "Can't call RemoveExcessCapacity on a wrapped matrix.");
}
}
template<typename DataType >
void Nektar::NekMatrix< DataType, StandardMatrixTag >::ResizeDataArrayIfNeeded ( unsigned int  requiredStorageSize)
protected

Definition at line 515 of file StandardMatrix.cpp.

References ASSERTL0, Nektar::Array< OneD, DataType >::data(), Nektar::eCopy, and Nektar::eWrapper.

{
{
if( m_data.num_elements() < requiredStorageSize )
{
Array<OneD, DataType> newData(requiredStorageSize);
std::copy(m_data.data(), m_data.data() + m_data.num_elements(), newData.data());
m_data = newData;
}
}
else if( m_wrapperType == eWrapper )
{
// If the current matrix is wrapped, then just copy over the top,
// but the sizes of the two matrices must be the same.
ASSERTL0(m_data.num_elements() >= requiredStorageSize, "Wrapped NekMatrices must have the same dimension in operator=");
}
}
template<typename DataType >
void Nektar::NekMatrix< DataType, StandardMatrixTag >::ResizeDataArrayIfNeeded ( )
protected

Definition at line 535 of file StandardMatrix.cpp.

{
unsigned int requiredStorageSize = GetRequiredStorageSize();
ResizeDataArrayIfNeeded(requiredStorageSize);
}
template<typename DataType >
DataType Nektar::NekMatrix< DataType, StandardMatrixTag >::Scale ( ) const

Returns the scaling used by this matrix.

Since this matrix is not a scaled matrix, this method always returns 1.

Definition at line 273 of file StandardMatrix.cpp.

{
return DataType(1);
}
template<typename DataType >
void Nektar::NekMatrix< DataType, StandardMatrixTag >::SetSize ( unsigned int  rows,
unsigned int  cols 
)

Definition at line 582 of file StandardMatrix.cpp.

References ASSERTL0.

Referenced by Nektar::Multiply().

{
this->Resize(rows, cols);
// Some places in Nektar++ access the matrix data array and
// use num_elements() to see how big it is. When using
// expression templates, the data array's capacity is often larger
// than the actual number of elements, so this statement is
// required to report the correct number of elements.
ASSERTL0(this->GetRequiredStorageSize() <= this->GetData().num_elements(), "Can't resize matrices if there is not enough capacity.");
}
template<typename DataType >
void Nektar::NekMatrix< DataType, StandardMatrixTag >::SetValue ( unsigned int  row,
unsigned int  column,
typename boost::call_traits< DataType >::const_reference  d 
)

Reimplemented from Nektar::Matrix< DataType >.

Definition at line 625 of file StandardMatrix.cpp.

References ASSERTL2.

Referenced by v_SetValue().

{
ASSERTL2(row < this->GetRows(), std::string("Row ") + boost::lexical_cast<std::string>(row) +
std::string(" requested in a matrix with a maximum of ") + boost::lexical_cast<std::string>(this->GetRows()) +
std::string(" rows"));
ASSERTL2(column < this->GetColumns(), std::string("Column ") + boost::lexical_cast<std::string>(column) +
std::string(" requested in a matrix with a maximum of ") + boost::lexical_cast<std::string>(this->GetColumns()) +
std::string(" columns"));
SetValue(row, column, d, this->GetTransposeFlag());
}
template<typename DataType >
void Nektar::NekMatrix< DataType, StandardMatrixTag >::SetValue ( unsigned int  row,
unsigned int  column,
typename boost::call_traits< DataType >::const_reference  d,
char  transpose 
)

Definition at line 637 of file StandardMatrix.cpp.

References ErrorUtil::efatal, and NEKERROR.

{
unsigned int index = this->CalculateIndex(row, column, transpose);
if( index != std::numeric_limits<unsigned int>::max() )
{
this->GetData()[index] = d;
}
else
{
NEKERROR(ErrorUtil::efatal, "Can't assign values into zeroed elements of a special array.");
}
}
template<typename DataType >
void Nektar::NekMatrix< DataType, StandardMatrixTag >::SwapTempAndDataBuffers ( )

Definition at line 800 of file StandardMatrix.cpp.

{
std::swap(m_tempSpace, this->GetData());
}
template<typename DataType >
unsigned int Nektar::NekMatrix< DataType, StandardMatrixTag >::v_GetStorageSize ( ) const
privatevirtual

Definition at line 562 of file StandardMatrix.cpp.

References GetStorageSize().

template<typename DataType >
MatrixStorage Nektar::NekMatrix< DataType, StandardMatrixTag >::v_GetStorageType ( ) const
privatevirtual

Definition at line 568 of file StandardMatrix.cpp.

References GetType().

template<typename DataType >
boost::call_traits< DataType >::value_type Nektar::NekMatrix< DataType, StandardMatrixTag >::v_GetValue ( unsigned int  row,
unsigned int  column 
) const
privatevirtual

Definition at line 556 of file StandardMatrix.cpp.

References operator()().

template<typename DataType >
void Nektar::NekMatrix< DataType, StandardMatrixTag >::v_SetValue ( unsigned int  row,
unsigned int  column,
typename boost::call_traits< DataType >::const_reference  d 
)
privatevirtual

Definition at line 574 of file StandardMatrix.cpp.

References SetValue().

Member Data Documentation

template<typename DataType >
Array<OneD, DataType> Nektar::NekMatrix< DataType, StandardMatrixTag >::m_data
private

Definition at line 593 of file StandardMatrix.hpp.

Referenced by operator=(), and PerformCopyConstruction().

template<typename DataType >
unsigned int Nektar::NekMatrix< DataType, StandardMatrixTag >::m_numberOfSubDiagonals
private

Definition at line 599 of file StandardMatrix.hpp.

Referenced by operator=().

template<typename DataType >
unsigned int Nektar::NekMatrix< DataType, StandardMatrixTag >::m_numberOfSuperDiagonals
private

Definition at line 598 of file StandardMatrix.hpp.

Referenced by operator=().

template<typename DataType >
MatrixStorage Nektar::NekMatrix< DataType, StandardMatrixTag >::m_storagePolicy
private

Definition at line 595 of file StandardMatrix.hpp.

Referenced by operator=().

template<typename DataType >
Array<OneD, DataType> Nektar::NekMatrix< DataType, StandardMatrixTag >::m_tempSpace
private

Definition at line 602 of file StandardMatrix.hpp.

template<typename DataType >
PointerWrapper Nektar::NekMatrix< DataType, StandardMatrixTag >::m_wrapperType
private

Definition at line 594 of file StandardMatrix.hpp.