Nektar++
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)
 

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

References ASSERTL1.

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

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

◆ CalculateIndex()

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

Definition at line 269 of file MatrixFuncs.cpp.

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

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  }

◆ Invert()

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

Definition at line 198 of file MatrixFuncs.h.

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

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

200  {
201  ASSERTL0(rows==columns, "Only square matrices can be inverted.");
202 
203  int n = columns;
204  int info = 0;
205  Array<OneD, int> ipivot(n);
206  Array<OneD, DataType> work(n);
207 
208  Lapack::Dsptrf('U', n, data.get(), ipivot.get(), info);
209 
210  if( info < 0 )
211  {
212  std::string message = "ERROR: The " + std::to_string(-info) + "th parameter had an illegal parameter for dsptrf";
213  ASSERTL0(false, message.c_str());
214  }
215  else if( info > 0 )
216  {
217  std::string message = "ERROR: Element u_" + std::to_string(info) + std::to_string(info) + " is 0 from dsptrf";
218  ASSERTL0(false, message.c_str());
219  }
220 
221  Lapack::Dsptri('U', n, data.get(), ipivot.get(),
222  work.get(), info);
223 
224  if( info < 0 )
225  {
226  std::string message = "ERROR: The " + std::to_string(-info) + "th parameter had an illegal parameter for dsptri";
227  ASSERTL0(false, message.c_str());
228  }
229  else if( info > 0 )
230  {
231  std::string message = "ERROR: Element u_" + std::to_string(info) + std::to_string(info) + " is 0 from dsptri";
232  ASSERTL0(false, message.c_str());
233  }
234  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
static void Dsptri(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:123
static void Dsptrf(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:107