Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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)
 
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
 
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 GetType () 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, MatrixStorage policy=eFULL)
 
 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, MatrixStorage policy=eFULL)
 
 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 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
 
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 471 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 472 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(),
44  m_numberOfSuperDiagonals(std::numeric_limits<unsigned int>::max()),
45  m_numberOfSubDiagonals(std::numeric_limits<unsigned int>::max()),
46  m_tempSpace()
47  {
48  m_data = Array<OneD, DataType>(GetRequiredStorageSize());
49  }
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 52 of file StandardMatrix.cpp.

54  :
55  Matrix<DataType>(rows, columns, policy),
56  m_data(),
58  m_numberOfSuperDiagonals(superDiagonals),
59  m_numberOfSubDiagonals(subDiagonals),
60  m_tempSpace()
61  {
62  m_data = Array<OneD, DataType>(GetRequiredStorageSize());
63  }
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 66 of file StandardMatrix.cpp.

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

87  :
88  Matrix<DataType>(rows, columns, policy),
89  m_data(),
91  m_numberOfSuperDiagonals(superDiagonals),
92  m_numberOfSubDiagonals(subDiagonals),
93  m_tempSpace()
94  {
95  m_data = Array<OneD, DataType>(GetRequiredStorageSize());
96  std::fill(m_data.begin(), m_data.end(), initValue);
97  }
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 100 of file StandardMatrix.cpp.

References CellMLToNektar.pycml::copy().

103  :
104  Matrix<DataType>(rows, columns, policy),
105  m_data(),
107  m_numberOfSuperDiagonals(superDiagonals),
108  m_numberOfSubDiagonals(subDiagonals),
109  m_tempSpace()
110  {
111  unsigned int size = GetRequiredStorageSize();
112  m_data = Array<OneD, DataType>(size);
113  std::copy(data, data + size, m_data.begin());
114  }
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 117 of file StandardMatrix.cpp.

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

120  :
121  Matrix<DataType>(rows, columns, policy),
122  m_data(),
124  m_numberOfSuperDiagonals(superDiagonals),
125  m_numberOfSubDiagonals(subDiagonals),
126  m_tempSpace()
127  {
128  m_data = Array<OneD, DataType>(GetRequiredStorageSize());
130  }
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 133 of file StandardMatrix.cpp.

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

136  :
137  Matrix<DataType>(rows, columns, policy),
138  m_data(),
139  m_wrapperType(wrapperType),
140  m_numberOfSuperDiagonals(superDiagonals),
141  m_numberOfSubDiagonals(subDiagonals),
142  m_tempSpace()
143  {
144  if( wrapperType == eWrapper )
145  {
146  m_data = Array<OneD, DataType>(d, eVECTOR_WRAPPER);
147  }
148  else
149  {
150  m_data = Array<OneD, DataType>(GetRequiredStorageSize());
152  }
153  }
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 156 of file StandardMatrix.cpp.

156  :
157  Matrix<DataType>(rhs),
158  m_data(),
159  m_wrapperType(rhs.m_wrapperType),
160  m_numberOfSuperDiagonals(rhs.m_numberOfSuperDiagonals),
161  m_numberOfSubDiagonals(rhs.m_numberOfSubDiagonals),
162  m_tempSpace()
163  {
165  }
template<typename DataType >
Nektar::NekMatrix< DataType, StandardMatrixTag >::NekMatrix ( const ThisType rhs,
PointerWrapper  wrapperType 
)
protected

Definition at line 461 of file StandardMatrix.cpp.

461  :
462  BaseType(rhs),
463  m_data(),
464  m_wrapperType(wrapperType),
465  m_numberOfSuperDiagonals(rhs.m_numberOfSuperDiagonals),
466  m_numberOfSubDiagonals(rhs.m_numberOfSubDiagonals)
467  {
469  }

Member Function Documentation

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

Definition at line 675 of file StandardMatrix.cpp.

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

676  {
677  NekDouble returnval;
678  int nvals = this->GetColumns();
679  Array<OneD, NekDouble> EigValReal(nvals);
680  Array<OneD, NekDouble> EigValImag(nvals);
681 
682  EigenSolve(EigValReal,EigValImag);
683 
684  Vmath::Vmul(nvals,EigValReal,1,EigValReal,1,EigValReal,1);
685  Vmath::Vmul(nvals,EigValImag,1,EigValImag,1,EigValImag,1);
686  Vmath::Vadd(nvals,EigValReal,1,EigValImag,1,EigValReal,1);
687 
688  returnval = sqrt(Vmath::Vmax(nvals,EigValReal,1)/Vmath::Vmin(nvals,EigValReal,1));
689 
690  return returnval;
691  }
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:779
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:871
unsigned int GetColumns() const
Definition: MatrixBase.cpp:78
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:299
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:183
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 390 of file StandardMatrix.cpp.

391  {
392  return Advance(curRow, curColumn, this->GetTransposeFlag());
393  }
boost::tuples::tuple< unsigned int, unsigned int > Advance(unsigned int curRow, unsigned int curColumn) const
char GetTransposeFlag() const
Definition: MatrixBase.cpp:114
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 397 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.

398  {
399  unsigned int numRows = this->GetTransposedRows(transpose);
400  unsigned int numColumns = this->GetTransposedColumns(transpose);
401 
402  switch(this->GetStorageType())
403  {
404  case eFULL:
406  numRows, numColumns, curRow, curColumn);
407  break;
408  case eDIAGONAL:
410  numRows, numColumns, curRow, curColumn);
411  break;
412  case eUPPER_TRIANGULAR:
414  numRows, numColumns, curRow, curColumn);
415  break;
416 
417  case eLOWER_TRIANGULAR:
419  numRows, numColumns, curRow, curColumn);
420  break;
421 
422  case eSYMMETRIC:
425  numRows, numColumns, curRow, curColumn);
426  break;
427  case eBANDED:
429  numRows, numColumns, curRow, curColumn);
430  break;
431  case eSYMMETRIC_BANDED:
433  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
434  break;
436  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
437  break;
439  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
440  break;
441 
442  default:
443  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
444  }
445  return boost::tuples::tuple<unsigned int, unsigned int>(curRow, curColumn);
446  }
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mod...
Definition: ErrorUtil.hpp:191
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)
MatrixStorage GetStorageType() const
Definition: MatrixBase.hpp:72
unsigned int GetTransposedColumns(char transpose) const
Definition: MatrixBase.cpp:84
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:65
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 637 of file StandardMatrix.cpp.

Referenced by operator==().

638  {
639  return begin(this->GetTransposeFlag());
640  }
char GetTransposeFlag() const
Definition: MatrixBase.cpp:114
template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::iterator Nektar::NekMatrix< DataType, StandardMatrixTag >::begin ( char  transpose)

Definition at line 643 of file StandardMatrix.cpp.

References Nektar::iterator.

644  {
645  if( transpose == 'N' )
646  {
647  return iterator(this->GetData().data(), this->GetData().data() + this->GetData().num_elements());
648  }
649  else
650  {
651  return iterator(this, transpose);
652  }
653  }
iterator_impl< DataType, ThisType > iterator
template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::const_iterator Nektar::NekMatrix< DataType, StandardMatrixTag >::begin ( ) const

Definition at line 272 of file StandardMatrix.cpp.

273  {
274  return begin(this->GetTransposeFlag());
275  }
char GetTransposeFlag() const
Definition: MatrixBase.cpp:114
template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::const_iterator Nektar::NekMatrix< DataType, StandardMatrixTag >::begin ( char  transpose) const

Definition at line 278 of file StandardMatrix.cpp.

279  {
280  if( transpose == 'N' )
281  {
283  }
284  else
285  {
286  return const_iterator(this, transpose);
287  }
288  }
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 216 of file StandardMatrix.cpp.

References Nektar::ConstMatrix< DataType >::CalculateIndex(), and Nektar::StdRegions::GetSize().

217  {
218  unsigned int numRows = this->GetSize()[0];
219  unsigned int numColumns = this->GetSize()[1];
221  row, col, numRows, numColumns, transpose,
223  }
const unsigned int * GetSize() const
Definition: MatrixBase.cpp:97
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:120
MatrixStorage GetStorageType() const
Definition: MatrixBase.hpp:72
template<typename DataType >
unsigned int Nektar::NekMatrix< DataType, StandardMatrixTag >::CalculateNumberOfRows ( ) const

Definition at line 350 of file StandardMatrix.cpp.

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

Definition at line 449 of file StandardMatrix.cpp.

References Nektar::eWrapper.

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

Definition at line 455 of file StandardMatrix.cpp.

References Nektar::eWrapper.

456  {
457  return boost::shared_ptr<NekMatrix<DataType, StandardMatrixTag> >(new NekMatrix<DataType, StandardMatrixTag>(*rhs, eWrapper));
458  }
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 694 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().

697  {
698  ASSERTL0(this->GetRows()==this->GetColumns(), "Only square matrices can be called");
699 
700  switch(this->GetType())
701  {
702  case eFULL:
704  this->GetData(), EigValReal,
705  EigValImag, EigVecs);
706  break;
707  case eDIAGONAL:
708  Vmath::Vcopy(this->GetRows(),&(this->GetData())[0],1, &EigValReal[0],1);
709  Vmath::Zero(this->GetRows(),&EigValImag[0],1);
710  break;
711  case eUPPER_TRIANGULAR:
712  case eLOWER_TRIANGULAR:
713  case eSYMMETRIC:
714  case eBANDED:
715  case eSYMMETRIC_BANDED:
718  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
719  break;
720 
721  default:
722  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
723  }
724  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mod...
Definition: ErrorUtil.hpp:191
unsigned int GetColumns() const
Definition: MatrixBase.cpp:78
unsigned int GetRows() const
Definition: MatrixBase.cpp:59
MatrixStorage GetType() const
Definition: MatrixBase.hpp:67
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:373
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1061
template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::iterator Nektar::NekMatrix< DataType, StandardMatrixTag >::end ( )

Definition at line 656 of file StandardMatrix.cpp.

657  {
658  return end(this->GetTransposeFlag());
659  }
char GetTransposeFlag() const
Definition: MatrixBase.cpp:114
template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::iterator Nektar::NekMatrix< DataType, StandardMatrixTag >::end ( char  transpose)

Definition at line 662 of file StandardMatrix.cpp.

References Nektar::iterator.

663  {
664  if( transpose == 'N' )
665  {
666  return iterator(this->GetData().data(), this->GetData().data() + this->GetData().num_elements(), true);
667  }
668  else
669  {
670  return iterator(this, transpose, true);
671  }
672  }
iterator_impl< DataType, ThisType > iterator
template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::const_iterator Nektar::NekMatrix< DataType, StandardMatrixTag >::end ( ) const

Definition at line 291 of file StandardMatrix.cpp.

292  {
293  return end(this->GetTransposeFlag());
294  }
char GetTransposeFlag() const
Definition: MatrixBase.cpp:114
template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::const_iterator Nektar::NekMatrix< DataType, StandardMatrixTag >::end ( char  transpose) const

Definition at line 297 of file StandardMatrix.cpp.

298  {
299  if( transpose == 'N' )
300  {
301  return const_iterator(m_data.data(), m_data.data() + m_data.num_elements(), true);
302  }
303  else
304  {
305  return const_iterator(this, transpose, true);
306  }
307  }
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 473 of file StandardMatrix.cpp.

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

Definition at line 316 of file StandardMatrix.cpp.

Referenced by Nektar::Transpose().

317  {
318  if( m_numberOfSubDiagonals != std::numeric_limits<unsigned int>::max() )
319  {
320  return m_numberOfSubDiagonals;
321  }
322  else if( this->GetRows() > 0 )
323  {
324  return this->GetRows()-1;
325  }
326  else
327  {
328  return 0;
329  }
330  }
unsigned int GetRows() const
Definition: MatrixBase.cpp:59
template<typename DataType >
unsigned int Nektar::NekMatrix< DataType, StandardMatrixTag >::GetNumberOfSuperDiagonals ( ) const

Definition at line 333 of file StandardMatrix.cpp.

Referenced by Nektar::Transpose().

334  {
335  if( m_numberOfSuperDiagonals != std::numeric_limits<unsigned int>::max() )
336  {
338  }
339  else if( this->GetRows() > 0 )
340  {
341  return this->GetRows()-1;
342  }
343  else
344  {
345  return 0;
346  }
347  }
unsigned int GetRows() const
Definition: MatrixBase.cpp:59
template<typename DataType >
const Array< OneD, const DataType > & Nektar::NekMatrix< DataType, StandardMatrixTag >::GetPtr ( ) const

Definition at line 254 of file StandardMatrix.cpp.

Referenced by Nektar::Transpose().

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

Definition at line 625 of file StandardMatrix.cpp.

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

Definition at line 266 of file StandardMatrix.cpp.

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

Definition at line 631 of file StandardMatrix.cpp.

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

Definition at line 208 of file StandardMatrix.cpp.

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

209  {
211  this->GetRows(), this->GetColumns(),
213  }
unsigned int GetColumns() const
Definition: MatrixBase.cpp:78
MatrixStorage GetStorageType() const
Definition: MatrixBase.hpp:72
unsigned int GetRows() const
Definition: MatrixBase.cpp:59
static unsigned int GetRequiredStorageSize(MatrixStorage type, unsigned int rows, unsigned int columns, unsigned int subDiags=0, unsigned int superDiags=0)
Definition: MatrixBase.cpp:176
template<typename DataType >
unsigned int Nektar::NekMatrix< DataType, StandardMatrixTag >::GetStorageSize ( ) const

Definition at line 310 of file StandardMatrix.cpp.

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

Definition at line 767 of file StandardMatrix.cpp.

768  {
769  if( m_tempSpace.capacity() == 0 )
770  {
771  m_tempSpace = Array<OneD, DataType>(this->GetData().capacity());
772  }
773  return m_tempSpace;
774  }
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 226 of file StandardMatrix.cpp.

References ASSERTL2.

227  {
228  ASSERTL2(row < this->GetRows(), std::string("Row ") + boost::lexical_cast<std::string>(row) +
229  std::string(" requested in a matrix with a maximum of ") + boost::lexical_cast<std::string>(this->GetRows()) +
230  std::string(" rows"));
231  ASSERTL2(column < this->GetColumns(), std::string("Column ") + boost::lexical_cast<std::string>(column) +
232  std::string(" requested in a matrix with a maximum of ") + boost::lexical_cast<std::string>(this->GetColumns()) +
233  std::string(" columns"));
234 
235  return GetValue(row, column, this->GetTransposeFlag());
236  }
char GetTransposeFlag() const
Definition: MatrixBase.cpp:114
unsigned int GetColumns() const
Definition: MatrixBase.cpp:78
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:59
#define ASSERTL2(condition, msg)
Assert Level 2 – Debugging which is used FULLDEBUG compilation mode. This level assert is designed t...
Definition: ErrorUtil.hpp:250
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 239 of file StandardMatrix.cpp.

240  {
241  static DataType defaultReturnValue;
242  unsigned int index = CalculateIndex(row, column, transpose);
243  if( index != std::numeric_limits<unsigned int>::max() )
244  {
245  return m_data[index];
246  }
247  else
248  {
249  return defaultReturnValue;
250  }
251  }
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 386 of file StandardMatrix.cpp.

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

Definition at line 727 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::SymmetricMatrixFuncs::Invert(), Nektar::DiagonalMatrixFuncs::Invert(), and NEKERROR.

728  {
729  ASSERTL0(this->GetRows()==this->GetColumns(), "Only square matrices can be inverted.");
730  ASSERTL0(this->GetTransposeFlag()=='N', "Only untransposed matrices may be inverted.");
731 
732  switch(this->GetType())
733  {
734  case eFULL:
735  FullMatrixFuncs::Invert(this->GetRows(), this->GetColumns(),
736  this->GetData(), this->GetTransposeFlag());
737  break;
738  case eDIAGONAL:
740  this->GetData());
741  break;
742  case eSYMMETRIC:
744  this->GetData());
745  break;
746  case eUPPER_TRIANGULAR:
747  case eLOWER_TRIANGULAR:
748  case eBANDED:
749  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
750  break;
751  case eSYMMETRIC_BANDED:
752  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
753  break;
755  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
756  break;
758  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
759  break;
760 
761  default:
762  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
763  }
764  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mod...
Definition: ErrorUtil.hpp:191
static void Invert(unsigned int rows, unsigned int columns, Array< OneD, DataType > &data, const char transpose)
Definition: MatrixFuncs.h:86
char GetTransposeFlag() const
Definition: MatrixBase.cpp:114
unsigned int GetColumns() const
Definition: MatrixBase.cpp:78
unsigned int GetRows() const
Definition: MatrixBase.cpp:59
MatrixStorage GetType() const
Definition: MatrixBase.hpp:67
static void Invert(unsigned int rows, unsigned int columns, Array< OneD, DataType > &data)
Definition: MatrixFuncs.h:206
static void Invert(unsigned int rows, unsigned int columns, Array< OneD, DataType > &data)
Definition: MatrixFuncs.h:262
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 189 of file StandardMatrix.cpp.

References ASSERTL2.

190  {
191  ASSERTL2(row < this->GetRows(), std::string("Row ") + boost::lexical_cast<std::string>(row) +
192  std::string(" requested in a matrix with a maximum of ") + boost::lexical_cast<std::string>(this->GetRows()) +
193  std::string(" rows"));
194  ASSERTL2(column < this->GetColumns(), std::string("Column ") + boost::lexical_cast<std::string>(column) +
195  std::string(" requested in a matrix with a maximum of ") + boost::lexical_cast<std::string>(this->GetColumns()) +
196  std::string(" columns"));
197 
198  return this->GetValue(row, column, this->GetTransposeFlag());
199  }
char GetTransposeFlag() const
Definition: MatrixBase.cpp:114
unsigned int GetColumns() const
Definition: MatrixBase.cpp:78
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:59
#define ASSERTL2(condition, msg)
Assert Level 2 – Debugging which is used FULLDEBUG compilation mode. This level assert is designed t...
Definition: ErrorUtil.hpp:250
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 202 of file StandardMatrix.cpp.

203  {
204  return this->GetValue(row, column, transpose);
205  }
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 571 of file StandardMatrix.cpp.

References ASSERTL2.

572  {
573  ASSERTL2(row < this->GetRows(), std::string("Row ") + boost::lexical_cast<std::string>(row) +
574  std::string(" requested in a matrix with a maximum of ") + boost::lexical_cast<std::string>(this->GetRows()) +
575  std::string(" rows"));
576  ASSERTL2(column < this->GetColumns(), std::string("Column ") + boost::lexical_cast<std::string>(column) +
577  std::string(" requested in a matrix with a maximum of ") + boost::lexical_cast<std::string>(this->GetColumns()) +
578  std::string(" columns"));
579 
580  return (*this)(row, column, this->GetTransposeFlag());
581  }
char GetTransposeFlag() const
Definition: MatrixBase.cpp:114
unsigned int GetColumns() const
Definition: MatrixBase.cpp:78
unsigned int GetRows() const
Definition: MatrixBase.cpp:59
#define ASSERTL2(condition, msg)
Assert Level 2 – Debugging which is used FULLDEBUG compilation mode. This level assert is designed t...
Definition: ErrorUtil.hpp:250
template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::Proxy Nektar::NekMatrix< DataType, StandardMatrixTag >::operator() ( unsigned int  row,
unsigned int  column,
char  transpose 
)

Definition at line 584 of file StandardMatrix.cpp.

585  {
586  unsigned int index = this->CalculateIndex(row, column, transpose);
587  if( index != std::numeric_limits<unsigned int>::max() )
588  {
589  return Proxy(this->GetData()[index]);
590  }
591  else
592  {
593  return Proxy();
594  }
595 
596  }
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 793 of file StandardMatrix.cpp.

794  {
795  for(unsigned int i = 0; i < this->GetPtr().num_elements(); ++i)
796  {
797  this->GetPtr()[i] *= s;
798  }
799  return *this;
800  }
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 784 of file StandardMatrix.cpp.

References Nektar::NegateInPlace().

785  {
786  NekMatrix<DataType, StandardMatrixTag> result(*this);
787  NegateInPlace(result);
788  return result;
789  }
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 168 of file StandardMatrix.cpp.

References CellMLToNektar.pycml::copy(), Nektar::Array< OneD, DataType >::data(), m_data, m_numberOfSubDiagonals, m_numberOfSuperDiagonals, and Nektar::Matrix< DataType >::operator=().

169  {
170  if( this == &rhs )
171  {
172  return *this;
173  }
174 
176  m_numberOfSubDiagonals = rhs.m_numberOfSubDiagonals;
177  m_numberOfSuperDiagonals = rhs.m_numberOfSuperDiagonals;
178 
180 
181  unsigned int requiredStorageSize = GetRequiredStorageSize();
182  std::copy(rhs.m_data.data(), rhs.m_data.data() + requiredStorageSize, m_data.data());
183 
184  return *this;
185  }
Matrix< DataType > & operator=(const Matrix< DataType > &rhs)
Definition: MatrixBase.cpp:306
template<typename DataType >
template<typename InnerMatrixType >
ThisType& Nektar::NekMatrix< DataType, StandardMatrixTag >::operator= ( const NekMatrix< InnerMatrixType, ScaledMatrixTag > &  rhs)
inline

Definition at line 337 of file StandardMatrix.hpp.

338  {
339  BaseType::operator=(rhs);
340  m_numberOfSubDiagonals = rhs.GetNumberOfSubDiagonals();
341  m_numberOfSuperDiagonals = rhs.GetNumberOfSuperDiagonals();
342 
344 
345  unsigned int requiredStorageSize = GetRequiredStorageSize();
346  DataType scale = rhs.Scale();
347 
348  DataType* lhs_array = m_data.data();
349  const DataType* rhs_array = rhs.GetRawPtr();
350 
351  for(unsigned int i = 0; i < requiredStorageSize; ++i)
352  {
353  lhs_array[i] = scale*rhs_array[i];
354  }
355 
356  return *this;
357 
358  }
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 356 of file StandardMatrix.cpp.

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

357  {
358  if( this->GetRows() != rhs.GetRows() ||
359  this->GetColumns() != rhs.GetColumns() )
360  {
361  return false;
362  }
363 
364  if( this->GetTransposeFlag() == rhs.GetTransposeFlag() )
365  {
366  return std::equal(begin(), end(), rhs.begin());
367  }
368  else
369  {
370  for(unsigned int i = 0; i < this->GetRows(); ++i)
371  {
372  for(unsigned int j = 0; j < this->GetColumns(); ++j)
373  {
374  if( (*this)(i,j) != rhs(i,j) )
375  {
376  return false;
377  }
378  }
379  }
380  }
381 
382  return true;
383  }
char GetTransposeFlag() const
Definition: MatrixBase.cpp:114
unsigned int GetColumns() const
Definition: MatrixBase.cpp:78
unsigned int GetRows() const
Definition: MatrixBase.cpp:59
template<typename DataType >
void Nektar::NekMatrix< DataType, StandardMatrixTag >::PerformCopyConstruction ( const ThisType rhs)
private

Definition at line 522 of file StandardMatrix.cpp.

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

523  {
524  if( m_wrapperType == eWrapper )
525  {
526  m_data = rhs.m_data;
527  }
528  else
529  {
530  m_data = Array<OneD, DataType>(GetRequiredStorageSize());
531  CopyArrayN(rhs.m_data, m_data, m_data.num_elements());
532  }
533  }
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 476 of file StandardMatrix.cpp.

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

477  {
478  if( m_wrapperType == eCopy )
479  {
480  unsigned int requiredStorageSize = GetRequiredStorageSize();
481  if( m_data.num_elements() > requiredStorageSize )
482  {
483  Array<OneD, DataType> newArray(requiredStorageSize);
484  CopyArrayN(m_data, newArray, requiredStorageSize);
485  m_data = newArray;
486  }
487  }
488  else if( m_wrapperType == eWrapper )
489  {
490  ASSERTL0(true, "Can't call RemoveExcessCapacity on a wrapped matrix.");
491  }
492  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
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 495 of file StandardMatrix.cpp.

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

496  {
497  if( m_wrapperType == eCopy )
498  {
499  if( m_data.num_elements() < requiredStorageSize )
500  {
501  Array<OneD, DataType> newData(requiredStorageSize);
502  std::copy(m_data.data(), m_data.data() + m_data.num_elements(), newData.data());
503  m_data = newData;
504  }
505  }
506  else if( m_wrapperType == eWrapper )
507  {
508  // If the current matrix is wrapped, then just copy over the top,
509  // but the sizes of the two matrices must be the same.
510  ASSERTL0(m_data.num_elements() >= requiredStorageSize, "Wrapped NekMatrices must have the same dimension in operator=");
511  }
512  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
size_type num_elements() const
Returns the array's size.
template<typename DataType >
void Nektar::NekMatrix< DataType, StandardMatrixTag >::ResizeDataArrayIfNeeded ( )
protected

Definition at line 515 of file StandardMatrix.cpp.

516  {
517  unsigned int requiredStorageSize = GetRequiredStorageSize();
518  ResizeDataArrayIfNeeded(requiredStorageSize);
519  }
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 260 of file StandardMatrix.cpp.

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

Definition at line 556 of file StandardMatrix.cpp.

References ASSERTL0.

Referenced by Nektar::Multiply().

557  {
558  this->Resize(rows, cols);
559 
560  // Some places in Nektar++ access the matrix data array and
561  // use num_elements() to see how big it is. When using
562  // expression templates, the data array's capacity is often larger
563  // than the actual number of elements, so this statement is
564  // required to report the correct number of elements.
565  this->GetData().ChangeSize(this->GetRequiredStorageSize());
566  ASSERTL0(this->GetRequiredStorageSize() <= this->GetData().num_elements(), "Can't resize matrices if there is not enough capacity.");
567  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
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:258
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 599 of file StandardMatrix.cpp.

References ASSERTL2.

600  {
601  ASSERTL2(row < this->GetRows(), std::string("Row ") + boost::lexical_cast<std::string>(row) +
602  std::string(" requested in a matrix with a maximum of ") + boost::lexical_cast<std::string>(this->GetRows()) +
603  std::string(" rows"));
604  ASSERTL2(column < this->GetColumns(), std::string("Column ") + boost::lexical_cast<std::string>(column) +
605  std::string(" requested in a matrix with a maximum of ") + boost::lexical_cast<std::string>(this->GetColumns()) +
606  std::string(" columns"));
607  SetValue(row, column, d, this->GetTransposeFlag());
608  }
void SetValue(unsigned int row, unsigned int column, typename boost::call_traits< DataType >::const_reference d)
char GetTransposeFlag() const
Definition: MatrixBase.cpp:114
unsigned int GetColumns() const
Definition: MatrixBase.cpp:78
unsigned int GetRows() const
Definition: MatrixBase.cpp:59
#define ASSERTL2(condition, msg)
Assert Level 2 – Debugging which is used FULLDEBUG compilation mode. This level assert is designed t...
Definition: ErrorUtil.hpp:250
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 611 of file StandardMatrix.cpp.

References ErrorUtil::efatal, and NEKERROR.

612  {
613  unsigned int index = this->CalculateIndex(row, column, transpose);
614  if( index != std::numeric_limits<unsigned int>::max() )
615  {
616  this->GetData()[index] = d;
617  }
618  else
619  {
620  NEKERROR(ErrorUtil::efatal, "Can't assign values into zeroed elements of a special array.");
621  }
622  }
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mod...
Definition: ErrorUtil.hpp:191
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 777 of file StandardMatrix.cpp.

778  {
779  std::swap(m_tempSpace, this->GetData());
780  }
template<typename DataType >
unsigned int Nektar::NekMatrix< DataType, StandardMatrixTag >::v_GetStorageSize ( ) const
privatevirtual
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 536 of file StandardMatrix.cpp.

537  {
539  }
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 548 of file StandardMatrix.cpp.

549  {
551  }
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 582 of file StandardMatrix.hpp.

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

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

Definition at line 587 of file StandardMatrix.hpp.

Referenced by operator=().

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

Definition at line 586 of file StandardMatrix.hpp.

Referenced by operator=().

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

Definition at line 590 of file StandardMatrix.hpp.

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

Definition at line 583 of file StandardMatrix.hpp.