Nektar++
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Static Public Member Functions | List of all members
Nektar::SymmetricMatrixFuncs Struct Reference

#include <MatrixFuncs.h>

Inheritance diagram for Nektar::SymmetricMatrixFuncs:
[legend]

Static Public Member Functions

static unsigned int CalculateIndex (unsigned int curRow, unsigned int curColumn)
 
template<typename DataType >
static void Invert (unsigned int rows, unsigned int columns, Array< OneD, DataType > &data)
 
static std::tuple< unsigned int, unsigned int > Advance (const unsigned int totalRows, const unsigned int totalColumns, const unsigned int curRow, const unsigned int curColumn)
 
static unsigned int GetRequiredStorageSize (unsigned int rows, unsigned int columns)
 

Additional Inherited Members

- Static Private Member Functions inherited from Nektar::TriangularMatrixFuncs
static unsigned int GetRequiredStorageSize (unsigned int rows, unsigned int columns)
 

Detailed Description

Definition at line 212 of file MatrixFuncs.h.

Member Function Documentation

◆ Advance()

std::tuple< unsigned int, unsigned int > Nektar::SymmetricMatrixFuncs::Advance ( const unsigned int  totalRows,
const unsigned int  totalColumns,
const unsigned int  curRow,
const unsigned int  curColumn 
)
static

Definition at line 282 of file MatrixFuncs.cpp.

284  {
285  ASSERTL1(totalRows == totalColumns, "Symmetric matrices must be square.");
286  ASSERTL1(curRow < totalRows, "Attemping to iterate through an element on row " +
287  std::to_string(curRow) + " of a (" +
288  std::to_string(totalRows) + ", " +
289  std::to_string(totalColumns) + " symmetric matrix.");
290  ASSERTL1(curColumn < totalColumns, "Attemping to iterate through an element on row " +
291  std::to_string(curColumn) + " of a (" +
292  std::to_string(totalRows) + ", " +
293  std::to_string(totalColumns) + " symmetric matrix.");
294 
295  unsigned int nextRow = curRow;
296  unsigned int nextColumn = curColumn;
297 
298  if( nextRow < totalRows )
299  {
300  ++nextRow;
301  }
302 
303  if( nextRow >= totalRows )
304  {
305  nextRow = 0;
306  ++nextColumn;
307  }
308 
309  if( nextColumn >= totalColumns )
310  {
311  nextRow = std::numeric_limits<unsigned int>::max();
312  nextColumn = std::numeric_limits<unsigned int>::max();
313  }
314 
315  return std::tuple<unsigned int, unsigned int>(nextRow, nextColumn);
316  }
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:250

References ASSERTL1.

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

◆ CalculateIndex()

unsigned int Nektar::SymmetricMatrixFuncs::CalculateIndex ( unsigned int  curRow,
unsigned int  curColumn 
)
static

Definition at line 269 of file MatrixFuncs.cpp.

270  {
271  if( curRow <= curColumn )
272  {
273  return curRow + curColumn*(curColumn+1)/2;
274  }
275  else
276  {
277  return curColumn + curRow*(curRow + 1)/2;
278  }
279  }

Referenced by Nektar::ConstMatrix< NekMatrix< DataType, InnerMatrixType >::NumberType >::v_GetTransposeFlag().

◆ GetRequiredStorageSize()

unsigned int Nektar::TriangularMatrixFuncs::GetRequiredStorageSize
static

Definition at line 187 of file MatrixFuncs.cpp.

145  {
146  ASSERTL0(rows==columns, "Triangular matrices must be square.");
147  return rows*(rows+1)/2;
148  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216

Referenced by Nektar::ConstMatrix< DataType >::GetRequiredStorageSize().

◆ Invert()

template<typename DataType >
static void Nektar::SymmetricMatrixFuncs::Invert ( unsigned int  rows,
unsigned int  columns,
Array< OneD, DataType > &  data 
)
inlinestatic

Definition at line 219 of file MatrixFuncs.h.

221  {
222  ASSERTL0(rows==columns, "Only square matrices can be inverted.");
223 
224  int n = columns;
225  int info = 0;
226  Array<OneD, int> ipivot(n);
227  Array<OneD, DataType> work(n);
228 
229  Lapack::DoSsptrf('U', n, data.get(), ipivot.get(), info);
230 
231  if( info < 0 )
232  {
233  std::string message = "ERROR: The " + std::to_string(-info) + "th parameter had an illegal parameter for dsptrf";
234  ASSERTL0(false, message.c_str());
235  }
236  else if( info > 0 )
237  {
238  std::string message = "ERROR: Element u_" + std::to_string(info) + std::to_string(info) + " is 0 from dsptrf";
239  ASSERTL0(false, message.c_str());
240  }
241 
242  Lapack::DoSsptri('U', n, data.get(), ipivot.get(),
243  work.get(), info);
244 
245  if( info < 0 )
246  {
247  std::string message = "ERROR: The " + std::to_string(-info) + "th parameter had an illegal parameter for dsptri";
248  ASSERTL0(false, message.c_str());
249  }
250  else if( info > 0 )
251  {
252  std::string message = "ERROR: Element u_" + std::to_string(info) + std::to_string(info) + " is 0 from dsptri";
253  ASSERTL0(false, message.c_str());
254  }
255  }
static void DoSsptrf(const char &uplo, const int &n, double *ap, int *ipiv, int &info)
factor a real packed-symmetric matrix using Bunch-Kaufman pivoting.
Definition: Lapack.hpp:167
static void DoSsptri(const char &uplo, const int &n, const double *ap, const int *ipiv, double *work, int &info)
Invert a real symmetric matrix problem.
Definition: Lapack.hpp:217

References ASSERTL0, Lapack::DoSsptrf(), Lapack::DoSsptri(), and Nektar::Array< OneD, DataType >::get().

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