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. More...
 
 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. More...
 
 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. More...
 
 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. More...
 
 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. More...
 
 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. More...
 
 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. More...
 
ConstGetValueType operator() (unsigned int row, unsigned int column, char transpose) const
 Returns the element value at the given row and column. More...
 
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. More...
 
ConstGetValueType GetValue (unsigned int row, unsigned int column, char transpose) const
 Returns the element value at the given row and column. More...
 
const Array< OneD, const
DataType > & 
GetPtr () const
 
DataType Scale () const
 Returns the scaling used by this matrix. More...
 
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. More...
 
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 ()
 
void SetValue (unsigned int row, unsigned int column, typename boost::call_traits< DataType >::const_reference d)
 
- Public Member Functions inherited from Nektar::ConstMatrix< DataType >
virtual ~ConstMatrix ()
 
boost::call_traits< DataType >
::value_type 
operator() (unsigned int row, unsigned int column) const
 
unsigned int GetStorageSize () const
 
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 ()
 
char GetTransposeFlag () const
 

Static Public Member Functions

static ThisType CreateWrapper (const ThisType &rhs)
 
static boost::shared_ptr
< ThisType
CreateWrapper (const boost::shared_ptr< ThisType > &rhs)
 
- Static Public Member Functions inherited from Nektar::ConstMatrix< DataType >
static unsigned int CalculateIndex (MatrixStorage type, unsigned int row, unsigned int col, unsigned int numRows, unsigned int numColumns, const char transpose= 'N', unsigned int numSubDiags=0, unsigned int numSuperDiags=0)
 
static unsigned int GetRequiredStorageSize (MatrixStorage type, unsigned int rows, unsigned int columns, unsigned int subDiags=0, unsigned int superDiags=0)
 

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)
 
ConstMatrix< DataType > & operator= (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. More...
 
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.

40  :
41  Matrix<DataType>(0, 0),
42  m_data(),
45  m_numberOfSuperDiagonals(std::numeric_limits<unsigned int>::max()),
46  m_numberOfSubDiagonals(std::numeric_limits<unsigned int>::max()),
47  m_tempSpace()
48  {
49  m_data = Array<OneD, DataType>(GetRequiredStorageSize());
50  }
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.

55  :
56  Matrix<DataType>(rows, columns),
57  m_data(),
59  m_storagePolicy(policy),
60  m_numberOfSuperDiagonals(superDiagonals),
61  m_numberOfSubDiagonals(subDiagonals),
62  m_tempSpace()
63  {
64  m_data = Array<OneD, DataType>(GetRequiredStorageSize());
65  }
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.

72  :
73  Matrix<DataType>(rows, columns),
74  m_data(),
76  m_storagePolicy(policy),
77  m_numberOfSuperDiagonals(superDiagonals),
78  m_numberOfSubDiagonals(subDiagonals),
79  m_tempSpace()
80  {
81  unsigned int requiredStorage = this->GetRequiredStorageSize();
82  unsigned int actualSize = std::max(requiredStorage, capacity);
83  m_data = Array<OneD, DataType>(actualSize);
84  }
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.

90  :
91  Matrix<DataType>(rows, columns),
92  m_data(),
94  m_storagePolicy(policy),
95  m_numberOfSuperDiagonals(superDiagonals),
96  m_numberOfSubDiagonals(subDiagonals),
97  m_tempSpace()
98  {
99  m_data = Array<OneD, DataType>(GetRequiredStorageSize());
100  std::fill(m_data.begin(), m_data.end(), initValue);
101  }
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.

107  :
108  Matrix<DataType>(rows, columns),
109  m_data(),
111  m_storagePolicy(policy),
112  m_numberOfSuperDiagonals(superDiagonals),
113  m_numberOfSubDiagonals(subDiagonals),
114  m_tempSpace()
115  {
116  unsigned int size = GetRequiredStorageSize();
117  m_data = Array<OneD, DataType>(size);
118  std::copy(data, data + size, m_data.begin());
119  }
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().

125  :
126  Matrix<DataType>(rows, columns),
127  m_data(),
129  m_storagePolicy(policy),
130  m_numberOfSuperDiagonals(superDiagonals),
131  m_numberOfSubDiagonals(subDiagonals),
132  m_tempSpace()
133  {
134  m_data = Array<OneD, DataType>(GetRequiredStorageSize());
136  }
size_type num_elements() const
Returns the array's size.
void CopyArrayN(const Array< OneD, ConstDataType > &source, Array< OneD, DataType > &dest, unsigned int n)
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().

142  :
143  Matrix<DataType>(rows, columns),
144  m_data(),
145  m_wrapperType(wrapperType),
146  m_storagePolicy(policy),
147  m_numberOfSuperDiagonals(superDiagonals),
148  m_numberOfSubDiagonals(subDiagonals),
149  m_tempSpace()
150  {
151  if( wrapperType == eWrapper )
152  {
153  m_data = Array<OneD, DataType>(d, eVECTOR_WRAPPER);
154  }
155  else
156  {
157  m_data = Array<OneD, DataType>(GetRequiredStorageSize());
159  }
160  }
size_type num_elements() const
Returns the array's size.
void CopyArrayN(const Array< OneD, ConstDataType > &source, Array< OneD, DataType > &dest, unsigned int n)
template<typename DataType >
Nektar::NekMatrix< DataType, StandardMatrixTag >::NekMatrix ( const ThisType rhs)

Definition at line 163 of file StandardMatrix.cpp.

163  :
164  Matrix<DataType>(rhs),
165  m_data(),
166  m_wrapperType(rhs.m_wrapperType),
167  m_storagePolicy(rhs.m_storagePolicy),
168  m_numberOfSuperDiagonals(rhs.m_numberOfSuperDiagonals),
169  m_numberOfSubDiagonals(rhs.m_numberOfSubDiagonals),
170  m_tempSpace()
171  {
173  }
template<typename DataType >
Nektar::NekMatrix< DataType, StandardMatrixTag >::NekMatrix ( const ThisType rhs,
PointerWrapper  wrapperType 
)
protected

Definition at line 480 of file StandardMatrix.cpp.

480  :
481  BaseType(rhs),
482  m_data(),
483  m_wrapperType(wrapperType),
484  m_storagePolicy(rhs.m_storagePolicy),
485  m_numberOfSuperDiagonals(rhs.m_numberOfSuperDiagonals),
486  m_numberOfSubDiagonals(rhs.m_numberOfSubDiagonals)
487  {
489  }

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().

702  {
703  NekDouble returnval;
704  int nvals = this->GetColumns();
705  Array<OneD, NekDouble> EigValReal(nvals);
706  Array<OneD, NekDouble> EigValImag(nvals);
707 
708  EigenSolve(EigValReal,EigValImag);
709 
710  Vmath::Vmul(nvals,EigValReal,1,EigValReal,1,EigValReal,1);
711  Vmath::Vmul(nvals,EigValImag,1,EigValImag,1,EigValImag,1);
712  Vmath::Vadd(nvals,EigValReal,1,EigValImag,1,EigValReal,1);
713 
714  returnval = sqrt(Vmath::Vmax(nvals,EigValReal,1)/Vmath::Vmin(nvals,EigValReal,1));
715 
716  return returnval;
717  }
void EigenSolve(Array< OneD, NekDouble > &EigValReal, Array< OneD, NekDouble > &EigValImag, Array< OneD, NekDouble > &EigVecs=NullNekDouble1DArray)
T Vmax(int n, const T *x, const int incx)
Return the maximum element in x – called vmax to avoid conflict with max.
Definition: Vmath.cpp:765
T Vmin(int n, const T *x, const int incx)
Return the minimum element in x - called vmin to avoid conflict with min.
Definition: Vmath.cpp:857
unsigned int GetColumns() const
Definition: MatrixBase.cpp:84
double NekDouble
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
Definition: Vmath.cpp:285
void Vmul(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x*y.
Definition: Vmath.cpp:169
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.

410  {
411  return Advance(curRow, curColumn, this->GetTransposeFlag());
412  }
boost::tuples::tuple< unsigned int, unsigned int > Advance(unsigned int curRow, unsigned int curColumn) const
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.

417  {
418  unsigned int numRows = this->GetTransposedRows(transpose);
419  unsigned int numColumns = this->GetTransposedColumns(transpose);
420 
421  switch(m_storagePolicy)
422  {
423  case eFULL:
425  numRows, numColumns, curRow, curColumn);
426  break;
427  case eDIAGONAL:
429  numRows, numColumns, curRow, curColumn);
430  break;
431  case eUPPER_TRIANGULAR:
433  numRows, numColumns, curRow, curColumn);
434  break;
435 
436  case eLOWER_TRIANGULAR:
438  numRows, numColumns, curRow, curColumn);
439  break;
440 
441  case eSYMMETRIC:
444  numRows, numColumns, curRow, curColumn);
445  break;
446  case eBANDED:
448  numRows, numColumns, curRow, curColumn);
449  break;
450  case eSYMMETRIC_BANDED:
452  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
453  break;
455  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
456  break;
458  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
459  break;
460 
461  default:
462  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
463  }
464  return boost::tuples::tuple<unsigned int, unsigned int>(curRow, curColumn);
465  }
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mod...
Definition: ErrorUtil.hpp:158
static boost::tuples::tuple< unsigned int, unsigned int > Advance(const unsigned int totalRows, const unsigned int totalColumns, const unsigned int curRow, const unsigned int curColumn)
static boost::tuples::tuple< unsigned int, unsigned int > Advance(const unsigned int totalRows, const unsigned int totalColumns, const unsigned int curRow, const unsigned int curColumn)
unsigned int GetTransposedColumns(char transpose) const
Definition: MatrixBase.cpp:90
static boost::tuples::tuple< unsigned int, unsigned int > Advance(const unsigned int totalRows, const unsigned int totalColumns, const unsigned int curRow, const unsigned int curColumn, char transpose= 'N')
static boost::tuples::tuple< unsigned int, unsigned int > Advance(const unsigned int totalRows, const unsigned int totalColumns, const unsigned int curRow, const unsigned int curColumn)
static boost::tuples::tuple< unsigned int, unsigned int > Advance(const unsigned int totalRows, const unsigned int totalColumns, const unsigned int curRow, const unsigned int curColumn)
unsigned int GetTransposedRows(char transpose) const
Definition: MatrixBase.cpp:71
static boost::tuples::tuple< unsigned int, unsigned int > Advance(const unsigned int totalRows, const unsigned int totalColumns, const unsigned int curRow, const unsigned int curColumn)
Definition: MatrixFuncs.cpp:91
template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::iterator Nektar::NekMatrix< DataType, StandardMatrixTag >::begin ( )

Definition at line 663 of file StandardMatrix.cpp.

Referenced by operator==().

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.

670  {
671  if( transpose == 'N' )
672  {
673  return iterator(this->GetData().data(), this->GetData().data() + this->GetData().num_elements());
674  }
675  else
676  {
677  return iterator(this, transpose);
678  }
679  }
iterator_impl< DataType, ThisType > iterator
template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::const_iterator Nektar::NekMatrix< DataType, StandardMatrixTag >::begin ( ) const

Definition at line 285 of file StandardMatrix.cpp.

template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::const_iterator Nektar::NekMatrix< DataType, StandardMatrixTag >::begin ( char  transpose) const

Definition at line 291 of file StandardMatrix.cpp.

292  {
293  if( transpose == 'N' )
294  {
296  }
297  else
298  {
299  return const_iterator(this, transpose);
300  }
301  }
iterator_impl< const DataType, const ThisType > const_iterator
size_type num_elements() const
Returns the array's size.
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::ConstMatrix< DataType >::CalculateIndex(), and Nektar::LibUtilities::GetSize().

230  {
231  unsigned int numRows = this->GetSize()[0];
232  unsigned int numColumns = this->GetSize()[1];
234  row, col, numRows, numColumns, transpose,
236  }
const unsigned int * GetSize() const
Definition: MatrixBase.cpp:103
static unsigned int CalculateIndex(MatrixStorage type, unsigned int row, unsigned int col, unsigned int numRows, unsigned int numColumns, const char transpose= 'N', unsigned int numSubDiags=0, unsigned int numSuperDiags=0)
Definition: MatrixBase.cpp:126
MatrixStorage GetStorageType() const
Definition: MatrixBase.cpp:59
template<typename DataType >
unsigned int Nektar::NekMatrix< DataType, StandardMatrixTag >::CalculateNumberOfRows ( ) const

Definition at line 363 of file StandardMatrix.cpp.

364  {
366  }
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.

469  {
470  return NekMatrix<DataType, StandardMatrixTag>(rhs, eWrapper);
471  }
template<typename DataType >
boost::shared_ptr< NekMatrix< DataType, StandardMatrixTag > > Nektar::NekMatrix< DataType, StandardMatrixTag >::CreateWrapper ( const boost::shared_ptr< ThisType > &  rhs)
static

Definition at line 474 of file StandardMatrix.cpp.

References Nektar::eWrapper.

475  {
476  return boost::shared_ptr<NekMatrix<DataType, StandardMatrixTag> >(new NekMatrix<DataType, StandardMatrixTag>(*rhs, eWrapper));
477  }
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().

723  {
724  ASSERTL0(this->GetRows()==this->GetColumns(), "Only square matrices can be called");
725 
726  switch(this->GetType())
727  {
728  case eFULL:
730  this->GetData(), EigValReal,
731  EigValImag, EigVecs);
732  break;
733  case eDIAGONAL:
734  Vmath::Vcopy(this->GetRows(),&(this->GetData())[0],1, &EigValReal[0],1);
735  Vmath::Zero(this->GetRows(),&EigValImag[0],1);
736  break;
737  case eUPPER_TRIANGULAR:
738  case eLOWER_TRIANGULAR:
739  case eSYMMETRIC:
740  case eBANDED:
741  case eSYMMETRIC_BANDED:
744  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
745  break;
746 
747  default:
748  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
749  }
750  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mod...
Definition: ErrorUtil.hpp:158
unsigned int GetColumns() const
Definition: MatrixBase.cpp:84
unsigned int GetRows() const
Definition: MatrixBase.cpp:65
static void EigenSolve(unsigned int n, const Array< OneD, const double > &A, Array< OneD, NekDouble > &EigValReal, Array< OneD, NekDouble > &EigValImag, Array< OneD, NekDouble > &EigVecs=NullNekDouble1DArray)
Definition: MatrixFuncs.h:133
void Zero(int n, T *x, const int incx)
Zero vector.
Definition: Vmath.cpp:359
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1047
template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::iterator Nektar::NekMatrix< DataType, StandardMatrixTag >::end ( )

Definition at line 682 of file StandardMatrix.cpp.

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.

689  {
690  if( transpose == 'N' )
691  {
692  return iterator(this->GetData().data(), this->GetData().data() + this->GetData().num_elements(), true);
693  }
694  else
695  {
696  return iterator(this, transpose, true);
697  }
698  }
iterator_impl< DataType, ThisType > iterator
template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::const_iterator Nektar::NekMatrix< DataType, StandardMatrixTag >::end ( ) const

Definition at line 304 of file StandardMatrix.cpp.

template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::const_iterator Nektar::NekMatrix< DataType, StandardMatrixTag >::end ( char  transpose) const

Definition at line 310 of file StandardMatrix.cpp.

311  {
312  if( transpose == 'N' )
313  {
314  return const_iterator(m_data.data(), m_data.data() + m_data.num_elements(), true);
315  }
316  else
317  {
318  return const_iterator(this, transpose, true);
319  }
320  }
iterator_impl< const DataType, const ThisType > const_iterator
size_type num_elements() const
Returns the array's size.
template<typename DataType >
Array< OneD, DataType > & Nektar::NekMatrix< DataType, StandardMatrixTag >::GetData ( )
protected

Definition at line 493 of file StandardMatrix.cpp.

493 { 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().

330  {
331  if( m_numberOfSubDiagonals != std::numeric_limits<unsigned int>::max() )
332  {
333  return m_numberOfSubDiagonals;
334  }
335  else if( this->GetRows() > 0 )
336  {
337  return this->GetRows()-1;
338  }
339  else
340  {
341  return 0;
342  }
343  }
unsigned int GetRows() const
Definition: MatrixBase.cpp:65
template<typename DataType >
unsigned int Nektar::NekMatrix< DataType, StandardMatrixTag >::GetNumberOfSuperDiagonals ( ) const

Definition at line 346 of file StandardMatrix.cpp.

Referenced by Nektar::Transpose().

347  {
348  if( m_numberOfSuperDiagonals != std::numeric_limits<unsigned int>::max() )
349  {
351  }
352  else if( this->GetRows() > 0 )
353  {
354  return this->GetRows()-1;
355  }
356  else
357  {
358  return 0;
359  }
360  }
unsigned int GetRows() const
Definition: MatrixBase.cpp:65
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().

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

Definition at line 651 of file StandardMatrix.cpp.

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

Definition at line 279 of file StandardMatrix.cpp.

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

Definition at line 657 of file StandardMatrix.cpp.

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

Definition at line 221 of file StandardMatrix.cpp.

References Nektar::ConstMatrix< DataType >::GetRequiredStorageSize().

222  {
224  this->GetRows(), this->GetColumns(),
226  }
unsigned int GetColumns() const
Definition: MatrixBase.cpp:84
MatrixStorage GetStorageType() const
Definition: MatrixBase.cpp:59
unsigned int GetRows() const
Definition: MatrixBase.cpp:65
static unsigned int GetRequiredStorageSize(MatrixStorage type, unsigned int rows, unsigned int columns, unsigned int subDiags=0, unsigned int superDiags=0)
Definition: MatrixBase.cpp:182
template<typename DataType >
unsigned int Nektar::NekMatrix< DataType, StandardMatrixTag >::GetStorageSize ( ) const

Definition at line 323 of file StandardMatrix.cpp.

324  {
325  return m_data.num_elements();
326  }
size_type num_elements() const
Returns the array's size.
template<typename DataType >
Array< OneD, DataType > & Nektar::NekMatrix< DataType, StandardMatrixTag >::GetTempSpace ( )

Definition at line 790 of file StandardMatrix.cpp.

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

Definition at line 402 of file StandardMatrix.cpp.

Referenced by operator==().

403  {
404  return this->GetRawTransposeFlag();
405  }
char GetRawTransposeFlag() const
Definition: MatrixBase.cpp:273
template<typename DataType >
MatrixStorage Nektar::NekMatrix< DataType, StandardMatrixTag >::GetType ( ) const

Definition at line 177 of file StandardMatrix.cpp.

Referenced by Nektar::Transpose().

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.

240  {
241  ASSERTL2(row < this->GetRows(), std::string("Row ") + boost::lexical_cast<std::string>(row) +
242  std::string(" requested in a matrix with a maximum of ") + boost::lexical_cast<std::string>(this->GetRows()) +
243  std::string(" rows"));
244  ASSERTL2(column < this->GetColumns(), std::string("Column ") + boost::lexical_cast<std::string>(column) +
245  std::string(" requested in a matrix with a maximum of ") + boost::lexical_cast<std::string>(this->GetColumns()) +
246  std::string(" columns"));
247 
248  return GetValue(row, column, this->GetTransposeFlag());
249  }
unsigned int GetColumns() const
Definition: MatrixBase.cpp:84
boost::call_traits< DataType >::const_reference GetValue(unsigned int row, unsigned int column) const
Returns the element value at the given row and column.
unsigned int GetRows() const
Definition: MatrixBase.cpp:65
#define ASSERTL2(condition, msg)
Assert Level 2 – Debugging which is used FULLDEBUG compilation mode. This level assert is designed t...
Definition: ErrorUtil.hpp:213
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.

253  {
254  static DataType defaultReturnValue;
255  unsigned int index = CalculateIndex(row, column, transpose);
256  if( index != std::numeric_limits<unsigned int>::max() )
257  {
258  return m_data[index];
259  }
260  else
261  {
262  return defaultReturnValue;
263  }
264  }
unsigned int CalculateIndex(unsigned int row, unsigned int col, const char transpose) const
template<typename DataType >
PointerWrapper Nektar::NekMatrix< DataType, StandardMatrixTag >::GetWrapperType ( ) const

Definition at line 399 of file StandardMatrix.cpp.

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::FullMatrixFuncs::Invert(), Nektar::DiagonalMatrixFuncs::Invert(), and NEKERROR.

754  {
755  ASSERTL0(this->GetRows()==this->GetColumns(), "Only square matrices can be inverted.");
756  ASSERTL0(this->GetTransposeFlag()=='N', "Only untransposed matrices may be inverted.");
757 
758  switch(this->GetType())
759  {
760  case eFULL:
761  FullMatrixFuncs::Invert(this->GetRows(), this->GetColumns(),
762  this->GetData(), this->GetTransposeFlag());
763  break;
764  case eDIAGONAL:
766  this->GetData());
767  break;
768  case eUPPER_TRIANGULAR:
769  case eLOWER_TRIANGULAR:
770  case eSYMMETRIC:
771  case eBANDED:
772  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
773  break;
774  case eSYMMETRIC_BANDED:
775  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
776  break;
778  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
779  break;
781  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
782  break;
783 
784  default:
785  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
786  }
787  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mod...
Definition: ErrorUtil.hpp:158
static void Invert(unsigned int rows, unsigned int columns, Array< OneD, DataType > &data, const char transpose)
Definition: MatrixFuncs.h:86
unsigned int GetColumns() const
Definition: MatrixBase.cpp:84
unsigned int GetRows() const
Definition: MatrixBase.cpp:65
static void Invert(unsigned int rows, unsigned int columns, Array< OneD, DataType > &data)
Definition: MatrixFuncs.h:215
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.

Definition at line 202 of file StandardMatrix.cpp.

References ASSERTL2.

203  {
204  ASSERTL2(row < this->GetRows(), std::string("Row ") + boost::lexical_cast<std::string>(row) +
205  std::string(" requested in a matrix with a maximum of ") + boost::lexical_cast<std::string>(this->GetRows()) +
206  std::string(" rows"));
207  ASSERTL2(column < this->GetColumns(), std::string("Column ") + boost::lexical_cast<std::string>(column) +
208  std::string(" requested in a matrix with a maximum of ") + boost::lexical_cast<std::string>(this->GetColumns()) +
209  std::string(" columns"));
210 
211  return this->GetValue(row, column, this->GetTransposeFlag());
212  }
unsigned int GetColumns() const
Definition: MatrixBase.cpp:84
boost::call_traits< DataType >::const_reference GetValue(unsigned int row, unsigned int column) const
Returns the element value at the given row and column.
unsigned int GetRows() const
Definition: MatrixBase.cpp:65
#define ASSERTL2(condition, msg)
Assert Level 2 – Debugging which is used FULLDEBUG compilation mode. This level assert is designed t...
Definition: ErrorUtil.hpp:213
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.

216  {
217  return this->GetValue(row, column, transpose);
218  }
boost::call_traits< DataType >::const_reference GetValue(unsigned int row, unsigned int column) const
Returns the element value at the given row and column.
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.

598  {
599  ASSERTL2(row < this->GetRows(), std::string("Row ") + boost::lexical_cast<std::string>(row) +
600  std::string(" requested in a matrix with a maximum of ") + boost::lexical_cast<std::string>(this->GetRows()) +
601  std::string(" rows"));
602  ASSERTL2(column < this->GetColumns(), std::string("Column ") + boost::lexical_cast<std::string>(column) +
603  std::string(" requested in a matrix with a maximum of ") + boost::lexical_cast<std::string>(this->GetColumns()) +
604  std::string(" columns"));
605 
606  return (*this)(row, column, this->GetTransposeFlag());
607  }
unsigned int GetColumns() const
Definition: MatrixBase.cpp:84
unsigned int GetRows() const
Definition: MatrixBase.cpp:65
#define ASSERTL2(condition, msg)
Assert Level 2 – Debugging which is used FULLDEBUG compilation mode. This level assert is designed t...
Definition: ErrorUtil.hpp:213
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.

611  {
612  unsigned int index = this->CalculateIndex(row, column, transpose);
613  if( index != std::numeric_limits<unsigned int>::max() )
614  {
615  return Proxy(this->GetData()[index]);
616  }
617  else
618  {
619  return Proxy();
620  }
621 
622  }
unsigned int CalculateIndex(unsigned int row, unsigned int col, const char transpose) const
template<typename DataType >
NekMatrix< DataType, StandardMatrixTag > & Nektar::NekMatrix< DataType, StandardMatrixTag >::operator*= ( const NumberType s)

Definition at line 816 of file StandardMatrix.cpp.

817  {
818  for(unsigned int i = 0; i < this->GetPtr().num_elements(); ++i)
819  {
820  this->GetPtr()[i] *= s;
821  }
822  return *this;
823  }
size_type num_elements() const
Returns the array's size.
const Array< OneD, const DataType > & GetPtr() const
template<typename DataType >
NekMatrix< DataType, StandardMatrixTag > Nektar::NekMatrix< DataType, StandardMatrixTag >::operator- ( ) const

Definition at line 807 of file StandardMatrix.cpp.

References Nektar::NegateInPlace().

808  {
809  NekMatrix<DataType, StandardMatrixTag> result(*this);
810  NegateInPlace(result);
811  return result;
812  }
void NegateInPlace(NekVector< DataType > &v)
Definition: NekVector.cpp:962
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, m_storagePolicy, and Nektar::Matrix< DataType >::operator=().

181  {
182  if( this == &rhs )
183  {
184  return *this;
185  }
186 
188  m_storagePolicy = rhs.m_storagePolicy;
189  m_numberOfSubDiagonals = rhs.m_numberOfSubDiagonals;
190  m_numberOfSuperDiagonals = rhs.m_numberOfSuperDiagonals;
191 
193 
194  unsigned int requiredStorageSize = GetRequiredStorageSize();
195  std::copy(rhs.m_data.data(), rhs.m_data.data() + requiredStorageSize, m_data.data());
196 
197  return *this;
198  }
Matrix< DataType > & operator=(const Matrix< DataType > &rhs)
Definition: MatrixBase.cpp:310
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.

342  {
343  BaseType::operator=(rhs);
344  m_storagePolicy = rhs.GetType();
345  m_numberOfSubDiagonals = rhs.GetNumberOfSubDiagonals();
346  m_numberOfSuperDiagonals = rhs.GetNumberOfSuperDiagonals();
347 
349 
350  unsigned int requiredStorageSize = GetRequiredStorageSize();
351  DataType scale = rhs.Scale();
352 
353  DataType* lhs_array = m_data.data();
354  const DataType* rhs_array = rhs.GetRawPtr();
355 
356  for(unsigned int i = 0; i < requiredStorageSize; ++i)
357  {
358  lhs_array[i] = scale*rhs_array[i];
359  }
360 
361  return *this;
362 
363  }
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().

370  {
371  if( this->GetRows() != rhs.GetRows() ||
372  this->GetColumns() != rhs.GetColumns() )
373  {
374  return false;
375  }
376 
377  if( this->GetTransposeFlag() == rhs.GetTransposeFlag() )
378  {
379  return std::equal(begin(), end(), rhs.begin());
380  }
381  else
382  {
383  for(unsigned int i = 0; i < this->GetRows(); ++i)
384  {
385  for(unsigned int j = 0; j < this->GetColumns(); ++j)
386  {
387  if( (*this)(i,j) != rhs(i,j) )
388  {
389  return false;
390  }
391  }
392  }
393  }
394 
395  return true;
396  }
unsigned int GetColumns() const
Definition: MatrixBase.cpp:84
unsigned int GetRows() const
Definition: MatrixBase.cpp:65
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().

543  {
544  if( m_wrapperType == eWrapper )
545  {
546  m_data = rhs.m_data;
547  }
548  else
549  {
550  m_data = Array<OneD, DataType>(GetRequiredStorageSize());
551  CopyArrayN(rhs.m_data, m_data, m_data.num_elements());
552  }
553  }
size_type num_elements() const
Returns the array's size.
void CopyArrayN(const Array< OneD, ConstDataType > &source, Array< OneD, DataType > &dest, unsigned int n)
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.

497  {
498  if( m_wrapperType == eCopy )
499  {
500  unsigned int requiredStorageSize = GetRequiredStorageSize();
501  if( m_data.num_elements() > requiredStorageSize )
502  {
503  Array<OneD, DataType> newArray(requiredStorageSize);
504  CopyArrayN(m_data, newArray, requiredStorageSize);
505  m_data = newArray;
506  }
507  }
508  else if( m_wrapperType == eWrapper )
509  {
510  ASSERTL0(true, "Can't call RemoveExcessCapacity on a wrapped matrix.");
511  }
512  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
size_type num_elements() const
Returns the array's size.
void CopyArrayN(const Array< OneD, ConstDataType > &source, Array< OneD, DataType > &dest, unsigned int n)
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.

516  {
517  if( m_wrapperType == eCopy )
518  {
519  if( m_data.num_elements() < requiredStorageSize )
520  {
521  Array<OneD, DataType> newData(requiredStorageSize);
522  std::copy(m_data.data(), m_data.data() + m_data.num_elements(), newData.data());
523  m_data = newData;
524  }
525  }
526  else if( m_wrapperType == eWrapper )
527  {
528  // If the current matrix is wrapped, then just copy over the top,
529  // but the sizes of the two matrices must be the same.
530  ASSERTL0(m_data.num_elements() >= requiredStorageSize, "Wrapped NekMatrices must have the same dimension in operator=");
531  }
532  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
size_type num_elements() const
Returns the array's size.
template<typename DataType >
void Nektar::NekMatrix< DataType, StandardMatrixTag >::ResizeDataArrayIfNeeded ( )
protected

Definition at line 535 of file StandardMatrix.cpp.

536  {
537  unsigned int requiredStorageSize = GetRequiredStorageSize();
538  ResizeDataArrayIfNeeded(requiredStorageSize);
539  }
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.

274  {
275  return DataType(1);
276  }
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().

583  {
584  this->Resize(rows, cols);
585 
586  // Some places in Nektar++ access the matrix data array and
587  // use num_elements() to see how big it is. When using
588  // expression templates, the data array's capacity is often larger
589  // than the actual number of elements, so this statement is
590  // required to report the correct number of elements.
591  this->GetData().ChangeSize(this->GetRequiredStorageSize());
592  ASSERTL0(this->GetRequiredStorageSize() <= this->GetData().num_elements(), "Can't resize matrices if there is not enough capacity.");
593  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
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 n...
Definition: MatrixBase.cpp:260
void ChangeSize(unsigned int newSize)
template<typename DataType >
void Nektar::NekMatrix< DataType, StandardMatrixTag >::SetValue ( unsigned int  row,
unsigned int  column,
typename boost::call_traits< DataType >::const_reference  d 
)

Definition at line 625 of file StandardMatrix.cpp.

References ASSERTL2.

626  {
627  ASSERTL2(row < this->GetRows(), std::string("Row ") + boost::lexical_cast<std::string>(row) +
628  std::string(" requested in a matrix with a maximum of ") + boost::lexical_cast<std::string>(this->GetRows()) +
629  std::string(" rows"));
630  ASSERTL2(column < this->GetColumns(), std::string("Column ") + boost::lexical_cast<std::string>(column) +
631  std::string(" requested in a matrix with a maximum of ") + boost::lexical_cast<std::string>(this->GetColumns()) +
632  std::string(" columns"));
633  SetValue(row, column, d, this->GetTransposeFlag());
634  }
void SetValue(unsigned int row, unsigned int column, typename boost::call_traits< DataType >::const_reference d)
unsigned int GetColumns() const
Definition: MatrixBase.cpp:84
unsigned int GetRows() const
Definition: MatrixBase.cpp:65
#define ASSERTL2(condition, msg)
Assert Level 2 – Debugging which is used FULLDEBUG compilation mode. This level assert is designed t...
Definition: ErrorUtil.hpp:213
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.

638  {
639  unsigned int index = this->CalculateIndex(row, column, transpose);
640  if( index != std::numeric_limits<unsigned int>::max() )
641  {
642  this->GetData()[index] = d;
643  }
644  else
645  {
646  NEKERROR(ErrorUtil::efatal, "Can't assign values into zeroed elements of a special array.");
647  }
648  }
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mod...
Definition: ErrorUtil.hpp:158
unsigned int CalculateIndex(unsigned int row, unsigned int col, const char transpose) const
template<typename DataType >
void Nektar::NekMatrix< DataType, StandardMatrixTag >::SwapTempAndDataBuffers ( )

Definition at line 800 of file StandardMatrix.cpp.

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

Implements Nektar::ConstMatrix< DataType >.

Definition at line 568 of file StandardMatrix.cpp.

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

Implements Nektar::ConstMatrix< DataType >.

Definition at line 556 of file StandardMatrix.cpp.

557  {
559  }
ConstGetValueType operator()(unsigned int row, unsigned int column) const
Returns the element value at the given row and column.
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

Implements Nektar::Matrix< DataType >.

Definition at line 574 of file StandardMatrix.cpp.

575  {
577  }
void SetValue(unsigned int row, unsigned int column, typename boost::call_traits< DataType >::const_reference d)

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.