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 222 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 295 of file MatrixFuncs.cpp.

298 {
299  ASSERTL1(totalRows == totalColumns, "Symmetric matrices must be square.");
300  ASSERTL1(curRow < totalRows,
301  "Attemping to iterate through an element on row " +
302  std::to_string(curRow) + " of a (" +
303  std::to_string(totalRows) + ", " +
304  std::to_string(totalColumns) + " symmetric matrix.");
305  ASSERTL1(curColumn < totalColumns,
306  "Attemping to iterate through an element on row " +
307  std::to_string(curColumn) + " of a (" +
308  std::to_string(totalRows) + ", " +
309  std::to_string(totalColumns) + " symmetric matrix.");
310 
311  unsigned int nextRow = curRow;
312  unsigned int nextColumn = curColumn;
313 
314  if (nextRow < totalRows)
315  {
316  ++nextRow;
317  }
318 
319  if (nextRow >= totalRows)
320  {
321  nextRow = 0;
322  ++nextColumn;
323  }
324 
325  if (nextColumn >= totalColumns)
326  {
327  nextRow = std::numeric_limits<unsigned int>::max();
328  nextColumn = std::numeric_limits<unsigned int>::max();
329  }
330 
331  return std::tuple<unsigned int, unsigned int>(nextRow, nextColumn);
332 }
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:249

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 282 of file MatrixFuncs.cpp.

284 {
285  if (curRow <= curColumn)
286  {
287  return curRow + curColumn * (curColumn + 1) / 2;
288  }
289  else
290  {
291  return curColumn + curRow * (curRow + 1) / 2;
292  }
293 }

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

◆ GetRequiredStorageSize()

unsigned int Nektar::TriangularMatrixFuncs::GetRequiredStorageSize
static

Definition at line 192 of file MatrixFuncs.cpp.

155 {
156  ASSERTL0(rows == columns, "Triangular matrices must be square.");
157  return rows * (rows + 1) / 2;
158 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:215

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 230 of file MatrixFuncs.h.

232  {
233  ASSERTL0(rows == columns, "Only square matrices can be inverted.");
234 
235  int n = columns;
236  int info = 0;
237  Array<OneD, int> ipivot(n);
238  Array<OneD, DataType> work(n);
239 
240  Lapack::DoSsptrf('U', n, data.get(), ipivot.get(), info);
241 
242  if (info < 0)
243  {
244  std::string message =
245  "ERROR: The " + std::to_string(-info) +
246  "th parameter had an illegal parameter for dsptrf";
247  ASSERTL0(false, message.c_str());
248  }
249  else if (info > 0)
250  {
251  std::string message = "ERROR: Element u_" + std::to_string(info) +
252  std::to_string(info) + " is 0 from dsptrf";
253  ASSERTL0(false, message.c_str());
254  }
255 
256  Lapack::DoSsptri('U', n, data.get(), ipivot.get(), work.get(), info);
257 
258  if (info < 0)
259  {
260  std::string message =
261  "ERROR: The " + std::to_string(-info) +
262  "th parameter had an illegal parameter for dsptri";
263  ASSERTL0(false, message.c_str());
264  }
265  else if (info > 0)
266  {
267  std::string message = "ERROR: Element u_" + std::to_string(info) +
268  std::to_string(info) + " is 0 from dsptri";
269  ASSERTL0(false, message.c_str());
270  }
271  }
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:150
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:199

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

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