Nektar++
Public Member Functions | Static Public Member Functions | Protected 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
 
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 40 of file MatrixBase.cpp.

41 {
42 }

◆ ConstMatrix() [1/2]

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

Definition at line 239 of file MatrixBase.cpp.

241  : m_size(), m_transpose('N'), m_storageType(policy)
242 {
243  m_size[0] = rows;
244  m_size[1] = columns;
245 }
unsigned int m_size[2]
Definition: MatrixBase.hpp:128
MatrixStorage m_storageType
Definition: MatrixBase.hpp:130

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

◆ ConstMatrix() [2/2]

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

Definition at line 248 of file MatrixBase.cpp.

249  : m_size(), m_transpose(rhs.m_transpose), m_storageType(rhs.m_storageType)
250 {
251  m_size[0] = rhs.m_size[0];
252  m_size[1] = rhs.m_size[1];
253 }

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 128 of file MatrixBase.cpp.

132 {
133  if (transpose == 'T')
134  {
135  std::swap(row, col);
136  }
137  switch (type)
138  {
139  case eFULL:
140  return FullMatrixFuncs::CalculateIndex(numRows, numColumns, row,
141  col);
142  break;
143  case eDIAGONAL:
144  return DiagonalMatrixFuncs::CalculateIndex(row, col);
145  break;
146  case eUPPER_TRIANGULAR:
148  break;
149  case eLOWER_TRIANGULAR:
150  return LowerTriangularMatrixFuncs::CalculateIndex(numColumns, row,
151  col);
152  break;
153  case eSYMMETRIC:
155  return SymmetricMatrixFuncs::CalculateIndex(row, col);
156  break;
157  case eBANDED:
159  numRows, numColumns, row, col, numSubDiags, numSuperDiags);
160  break;
161  case eSYMMETRIC_BANDED:
163  {
164  ASSERTL1(numSubDiags == numSuperDiags,
165  std::string("Number of sub- and superdiagonals should ") +
166  std::string("be equal for a symmetric banded matrix"));
168  numSuperDiags);
169  }
170  break;
172  NEKERROR(ErrorUtil::efatal, "Not yet implemented.");
173  break;
175  NEKERROR(ErrorUtil::efatal, "Not yet implemented.");
176  break;
177 
178  default:
179  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
180  }
181 
182  return std::numeric_limits<unsigned int>::max();
183 }
#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)

References ASSERTL1, Nektar::UpperTriangularMatrixFuncs::CalculateIndex(), Nektar::SymmetricMatrixFuncs::CalculateIndex(), Nektar::SymmetricBandedMatrixFuncs::CalculateIndex(), Nektar::DiagonalMatrixFuncs::CalculateIndex(), Nektar::LowerTriangularMatrixFuncs::CalculateIndex(), Nektar::FullMatrixFuncs::CalculateIndex(), Nektar::BandedMatrixFuncs::CalculateIndex(), 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, and NEKERROR.

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 186 of file MatrixBase.cpp.

189 {
190  switch (type)
191  {
192  case eFULL:
193  return FullMatrixFuncs::GetRequiredStorageSize(rows, columns);
194  break;
195  case eDIAGONAL:
196  return DiagonalMatrixFuncs::GetRequiredStorageSize(rows, columns);
197  break;
198  case eUPPER_TRIANGULAR:
200  columns);
201  break;
202  case eLOWER_TRIANGULAR:
204  columns);
205  break;
206  case eSYMMETRIC:
208  return SymmetricMatrixFuncs::GetRequiredStorageSize(rows, columns);
209  break;
210  case eBANDED:
212  rows, columns, subDiags, superDiags);
213  break;
214  case eSYMMETRIC_BANDED:
216  {
217  ASSERTL1(subDiags == superDiags,
218  std::string("Number of sub- and superdiagonals should ") +
219  std::string("be equal for a symmetric banded matrix"));
221  rows, columns, superDiags);
222  }
223  break;
225  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
226  break;
228  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
229  break;
230 
231  default:
232  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
233  }
234 
235  return 0;
236 }
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 103 of file MatrixBase.cpp.

104 {
105  return m_size;
106 }

◆ GetStorageSize()

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

Definition at line 60 of file MatrixBase.cpp.

61 {
62  return v_GetStorageSize();
63 }
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 90 of file MatrixBase.cpp.

91 {
92  if (transpose == 'N')
93  {
94  return m_size[1];
95  }
96  else
97  {
98  return m_size[0];
99  }
100 }

◆ GetTransposedRows()

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

Definition at line 71 of file MatrixBase.cpp.

72 {
73  if (transpose == 'N')
74  {
75  return m_size[0];
76  }
77  else
78  {
79  return m_size[1];
80  }
81 }

◆ 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 46 of file MatrixBase.cpp.

47 {
48  ASSERTL2(row < GetRows(),
49  std::string("Row ") + std::to_string(row) +
50  std::string(" requested in a matrix with a maximum of ") +
51  std::to_string(GetRows()) + std::string(" rows"));
52  ASSERTL2(column < GetColumns(),
53  std::string("Column ") + std::to_string(column) +
54  std::string(" requested in a matrix with a maximum of ") +
55  std::to_string(GetColumns()) + std::string(" columns"));
56  return v_GetValue(row, column);
57 }
#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:65
virtual boost::call_traits< DataType >::value_type v_GetValue(unsigned int row, unsigned int column) const =0
unsigned int GetColumns() const
Definition: MatrixBase.cpp:84

References ASSERTL2.

◆ operator=()

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

Definition at line 256 of file MatrixBase.cpp.

258 {
259  m_size[0] = rhs.m_size[0];
260  m_size[1] = rhs.m_size[1];
261  m_transpose = rhs.m_transpose;
262  m_storageType = rhs.m_storageType;
263  return *this;
264 }

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 267 of file MatrixBase.cpp.

268 {
269  m_size[0] = rows;
270  m_size[1] = columns;
271 }

◆ SetTransposeFlag()

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

Definition at line 274 of file MatrixBase.cpp.

275 {
276  m_transpose = newValue;
277 }

◆ Transpose()

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

Definition at line 108 of file MatrixBase.cpp.

109 {
110  if (m_transpose == 'N')
111  {
112  m_transpose = 'T';
113  }
114  else
115  {
116  m_transpose = 'N';
117  }
118  v_Transpose();
119 }
virtual void v_Transpose()
Definition: MatrixBase.cpp:279

Referenced by Nektar::Transpose().

◆ v_GetStorageSize()

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

◆ v_GetTransposeFlag()

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

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

Definition at line 284 of file MatrixBase.cpp.

285 {
286  return m_transpose;
287 }

◆ v_GetValue()

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

◆ v_Transpose()

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

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

Definition at line 279 of file MatrixBase.cpp.

280 {
281 }

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