Nektar++
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
Nektar::ConstMatrix< DataType > Class Template Referenceabstract

#include <MatrixBase.hpp>

Inheritance diagram for Nektar::ConstMatrix< DataType >:
[legend]

Public Member Functions

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 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

 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

virtual boost::call_traits< DataType >::value_type v_GetValue (unsigned int row, unsigned int column) const =0
 
virtual unsigned int v_GetStorageSize () const =0
 
virtual void v_Transpose ()
 
virtual char v_GetTransposeFlag () const
 

Private Attributes

unsigned int m_size [2]
 
char m_transpose
 
MatrixStorage m_storageType
 

Detailed Description

template<typename DataType>
class Nektar::ConstMatrix< DataType >

Definition at line 53 of file MatrixBase.hpp.

Constructor & Destructor Documentation

◆ ~ConstMatrix()

template<typename DataType >
Nektar::ConstMatrix< DataType >::~ConstMatrix
virtual

Definition at line 36 of file MatrixBase.cpp.

37 {
38 }

◆ ConstMatrix() [1/2]

template<typename DataType >
Nektar::ConstMatrix< DataType >::ConstMatrix ( unsigned int  rows,
unsigned int  columns,
MatrixStorage  policy = eFULL 
)
protected

Definition at line 235 of file MatrixBase.cpp.

237  : m_size(), m_transpose('N'), m_storageType(policy)
238 {
239  m_size[0] = rows;
240  m_size[1] = columns;
241 }
unsigned int m_size[2]
Definition: MatrixBase.hpp:127
MatrixStorage m_storageType
Definition: MatrixBase.hpp:129

References Nektar::ConstMatrix< DataType >::m_size.

◆ ConstMatrix() [2/2]

template<typename DataType >
Nektar::ConstMatrix< DataType >::ConstMatrix ( const ConstMatrix< DataType > &  rhs)
protected

Definition at line 244 of file MatrixBase.cpp.

245  : m_size(), m_transpose(rhs.m_transpose), m_storageType(rhs.m_storageType)
246 {
247  m_size[0] = rhs.m_size[0];
248  m_size[1] = rhs.m_size[1];
249 }

References Nektar::ConstMatrix< DataType >::m_size.

Member Function Documentation

◆ CalculateIndex()

template<typename DataType >
unsigned int Nektar::ConstMatrix< DataType >::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

Definition at line 124 of file MatrixBase.cpp.

128 {
129  if (transpose == 'T')
130  {
131  std::swap(row, col);
132  }
133  switch (type)
134  {
135  case eFULL:
136  return FullMatrixFuncs::CalculateIndex(numRows, numColumns, row,
137  col);
138  break;
139  case eDIAGONAL:
140  return DiagonalMatrixFuncs::CalculateIndex(row, col);
141  break;
142  case eUPPER_TRIANGULAR:
144  break;
145  case eLOWER_TRIANGULAR:
146  return LowerTriangularMatrixFuncs::CalculateIndex(numColumns, row,
147  col);
148  break;
149  case eSYMMETRIC:
151  return SymmetricMatrixFuncs::CalculateIndex(row, col);
152  break;
153  case eBANDED:
155  numRows, numColumns, row, col, numSubDiags, numSuperDiags);
156  break;
157  case eSYMMETRIC_BANDED:
159  {
160  ASSERTL1(numSubDiags == numSuperDiags,
161  std::string("Number of sub- and superdiagonals should ") +
162  std::string("be equal for a symmetric banded matrix"));
164  numSuperDiags);
165  }
166  break;
168  NEKERROR(ErrorUtil::efatal, "Not yet implemented.");
169  break;
171  NEKERROR(ErrorUtil::efatal, "Not yet implemented.");
172  break;
173 
174  default:
175  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
176  }
177 
178  return std::numeric_limits<unsigned int>::max();
179 }
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
Definition: ErrorUtil.hpp:209
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:249
@ eLOWER_TRIANGULAR_BANDED
@ ePOSITIVE_DEFINITE_SYMMETRIC_BANDED
@ ePOSITIVE_DEFINITE_SYMMETRIC
@ eUPPER_TRIANGULAR_BANDED
static unsigned int CalculateIndex(unsigned int totalRows, unsigned int totalColumns, unsigned int row, unsigned int column, unsigned int sub, unsigned int super)
Definition: MatrixFuncs.cpp:77
static unsigned int CalculateIndex(unsigned int row, unsigned int col)
static unsigned int CalculateIndex(unsigned int totalRows, unsigned int totalColumns, unsigned int curRow, unsigned int curColumn)
static unsigned int CalculateIndex(unsigned int totalColumns, unsigned int curRow, unsigned int curColumn)
static unsigned int CalculateIndex(unsigned int curRow, unsigned int curColumn, unsigned int nSuperDiags)
static unsigned int CalculateIndex(unsigned int curRow, unsigned int curColumn)
static unsigned int CalculateIndex(unsigned int curRow, unsigned int curColumn)

Referenced by Nektar::NekMatrix< DataType, StandardMatrixTag >::CalculateIndex().

◆ GetColumns()

template<typename DataType >
unsigned int Nektar::ConstMatrix< DataType >::GetColumns

◆ GetRawTransposeFlag()

template<typename DataType >
char Nektar::ConstMatrix< DataType >::GetRawTransposeFlag ( ) const
inlineprotected

Definition at line 116 of file MatrixBase.hpp.

117  {
118  return m_transpose;
119  }

References Nektar::ConstMatrix< DataType >::m_transpose.

◆ GetRequiredStorageSize()

template<typename DataType >
unsigned int Nektar::ConstMatrix< DataType >::GetRequiredStorageSize ( MatrixStorage  type,
unsigned int  rows,
unsigned int  columns,
unsigned int  subDiags = 0,
unsigned int  superDiags = 0 
)
static

Definition at line 182 of file MatrixBase.cpp.

185 {
186  switch (type)
187  {
188  case eFULL:
189  return FullMatrixFuncs::GetRequiredStorageSize(rows, columns);
190  break;
191  case eDIAGONAL:
192  return DiagonalMatrixFuncs::GetRequiredStorageSize(rows, columns);
193  break;
194  case eUPPER_TRIANGULAR:
196  columns);
197  break;
198  case eLOWER_TRIANGULAR:
200  columns);
201  break;
202  case eSYMMETRIC:
204  return SymmetricMatrixFuncs::GetRequiredStorageSize(rows, columns);
205  break;
206  case eBANDED:
208  rows, columns, subDiags, superDiags);
209  break;
210  case eSYMMETRIC_BANDED:
212  {
213  ASSERTL1(subDiags == superDiags,
214  std::string("Number of sub- and superdiagonals should ") +
215  std::string("be equal for a symmetric banded matrix"));
217  rows, columns, superDiags);
218  }
219  break;
221  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
222  break;
224  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
225  break;
226 
227  default:
228  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
229  }
230 
231  return 0;
232 }
static unsigned int GetRequiredStorageSize(unsigned int totalRows, unsigned int totalColumns, unsigned int subDiags, unsigned int superDiags)
Calculates and returns the storage size required.
Definition: MatrixFuncs.cpp:44
static unsigned int GetRequiredStorageSize(unsigned int rows, unsigned int columns)
static unsigned int GetRequiredStorageSize(unsigned int rows, unsigned int columns)
static unsigned int GetRequiredStorageSize(unsigned int rows, unsigned int columns, unsigned int nSubSuperDiags)
static unsigned int GetRequiredStorageSize(unsigned int rows, unsigned int columns)
static unsigned int GetRequiredStorageSize(unsigned int rows, unsigned int columns)

References ASSERTL1, Nektar::eBANDED, Nektar::eDIAGONAL, Nektar::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, Nektar::FullMatrixFuncs::GetRequiredStorageSize(), Nektar::TriangularMatrixFuncs::GetRequiredStorageSize(), Nektar::SymmetricMatrixFuncs::GetRequiredStorageSize(), Nektar::DiagonalMatrixFuncs::GetRequiredStorageSize(), Nektar::SymmetricBandedMatrixFuncs::GetRequiredStorageSize(), Nektar::BandedMatrixFuncs::GetRequiredStorageSize(), and NEKERROR.

Referenced by Nektar::NekMatrix< DataType, StandardMatrixTag >::GetRequiredStorageSize().

◆ GetRows()

template<typename DataType >
unsigned int Nektar::ConstMatrix< DataType >::GetRows

◆ GetSize()

template<typename DataType >
const unsigned int * Nektar::ConstMatrix< DataType >::GetSize

Definition at line 99 of file MatrixBase.cpp.

100 {
101  return m_size;
102 }

◆ GetStorageSize()

template<typename DataType >
unsigned int Nektar::ConstMatrix< DataType >::GetStorageSize

Definition at line 56 of file MatrixBase.cpp.

57 {
58  return v_GetStorageSize();
59 }
virtual unsigned int v_GetStorageSize() const =0

◆ GetStorageType()

template<typename DataType >
MatrixStorage Nektar::ConstMatrix< DataType >::GetStorageType ( ) const
inline

Definition at line 69 of file MatrixBase.hpp.

70  {
71  return m_storageType;
72  }

References Nektar::ConstMatrix< DataType >::m_storageType.

◆ GetTransposedColumns()

template<typename DataType >
unsigned int Nektar::ConstMatrix< DataType >::GetTransposedColumns ( char  transpose) const

Definition at line 86 of file MatrixBase.cpp.

87 {
88  if (transpose == 'N')
89  {
90  return m_size[1];
91  }
92  else
93  {
94  return m_size[0];
95  }
96 }

◆ GetTransposedRows()

template<typename DataType >
unsigned int Nektar::ConstMatrix< DataType >::GetTransposedRows ( char  transpose) const

Definition at line 67 of file MatrixBase.cpp.

68 {
69  if (transpose == 'N')
70  {
71  return m_size[0];
72  }
73  else
74  {
75  return m_size[1];
76  }
77 }

◆ GetTransposeFlag()

template<typename DataType >
char Nektar::ConstMatrix< DataType >::GetTransposeFlag

◆ GetType()

template<typename DataType >
MatrixStorage Nektar::ConstMatrix< DataType >::GetType ( ) const
inline

Definition at line 64 of file MatrixBase.hpp.

65  {
66  return m_storageType;
67  }

References Nektar::ConstMatrix< DataType >::m_storageType.

Referenced by Nektar::Transpose().

◆ operator()()

template<typename DataType >
boost::call_traits< DataType >::value_type Nektar::ConstMatrix< DataType >::operator() ( unsigned int  row,
unsigned int  column 
) const

Definition at line 42 of file MatrixBase.cpp.

43 {
44  ASSERTL2(row < GetRows(),
45  std::string("Row ") + std::to_string(row) +
46  std::string(" requested in a matrix with a maximum of ") +
47  std::to_string(GetRows()) + std::string(" rows"));
48  ASSERTL2(column < GetColumns(),
49  std::string("Column ") + std::to_string(column) +
50  std::string(" requested in a matrix with a maximum of ") +
51  std::to_string(GetColumns()) + std::string(" columns"));
52  return v_GetValue(row, column);
53 }
#define ASSERTL2(condition, msg)
Assert Level 2 – Debugging which is used FULLDEBUG compilation mode. This level assert is designed to...
Definition: ErrorUtil.hpp:272
unsigned int GetRows() const
Definition: MatrixBase.cpp:61
virtual boost::call_traits< DataType >::value_type v_GetValue(unsigned int row, unsigned int column) const =0
unsigned int GetColumns() const
Definition: MatrixBase.cpp:80

References ASSERTL2.

◆ operator=()

template<typename DataType >
ConstMatrix< DataType > & Nektar::ConstMatrix< DataType >::operator= ( const ConstMatrix< DataType > &  rhs)
protected

Definition at line 252 of file MatrixBase.cpp.

254 {
255  m_size[0] = rhs.m_size[0];
256  m_size[1] = rhs.m_size[1];
257  m_transpose = rhs.m_transpose;
258  m_storageType = rhs.m_storageType;
259  return *this;
260 }

References Nektar::ConstMatrix< DataType >::m_size, Nektar::ConstMatrix< DataType >::m_storageType, and Nektar::ConstMatrix< DataType >::m_transpose.

Referenced by Nektar::Matrix< DataType >::operator=().

◆ Resize()

template<typename DataType >
void Nektar::ConstMatrix< DataType >::Resize ( unsigned int  rows,
unsigned int  columns 
)
protected

Resets the rows and columns in the array. This method does not update the data storage to match the new row and column counts.

Definition at line 263 of file MatrixBase.cpp.

264 {
265  m_size[0] = rows;
266  m_size[1] = columns;
267 }

◆ SetTransposeFlag()

template<typename DataType >
void Nektar::ConstMatrix< DataType >::SetTransposeFlag ( char  newValue)
protected

Definition at line 270 of file MatrixBase.cpp.

271 {
272  m_transpose = newValue;
273 }

◆ Transpose()

template<typename DataType >
void Nektar::ConstMatrix< DataType >::Transpose

Definition at line 104 of file MatrixBase.cpp.

105 {
106  if (m_transpose == 'N')
107  {
108  m_transpose = 'T';
109  }
110  else
111  {
112  m_transpose = 'N';
113  }
114  v_Transpose();
115 }
virtual void v_Transpose()
Definition: MatrixBase.cpp:275

Referenced by Nektar::Transpose().

◆ v_GetStorageSize()

template<typename DataType >
virtual unsigned int Nektar::ConstMatrix< DataType >::v_GetStorageSize ( ) const
privatepure virtual

◆ v_GetTransposeFlag()

template<typename DataType >
char Nektar::ConstMatrix< DataType >::v_GetTransposeFlag
privatevirtual

Reimplemented in Nektar::NekMatrix< NekMatrix< DataType, InnerMatrixType >, ScaledMatrixTag >.

Definition at line 280 of file MatrixBase.cpp.

281 {
282  return m_transpose;
283 }

◆ v_GetValue()

template<typename DataType >
virtual boost::call_traits<DataType>::value_type Nektar::ConstMatrix< DataType >::v_GetValue ( unsigned int  row,
unsigned int  column 
) const
privatepure virtual

◆ v_Transpose()

template<typename DataType >
void Nektar::ConstMatrix< DataType >::v_Transpose
privatevirtual

Reimplemented in Nektar::NekMatrix< NekMatrix< DataType, InnerMatrixType >, BlockMatrixTag >.

Definition at line 275 of file MatrixBase.cpp.

276 {
277 }

Member Data Documentation

◆ m_size

template<typename DataType >
unsigned int Nektar::ConstMatrix< DataType >::m_size[2]
private

◆ m_storageType

template<typename DataType >
MatrixStorage Nektar::ConstMatrix< DataType >::m_storageType
private

◆ m_transpose

template<typename DataType >
char Nektar::ConstMatrix< DataType >::m_transpose
private