Nektar++
Static Public Member Functions | List of all members
Nektar::DiagonalMatrixFuncs Struct Reference

#include <MatrixFuncs.h>

Static Public Member Functions

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

Detailed Description

Definition at line 278 of file MatrixFuncs.h.

Member Function Documentation

◆ Advance()

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

Definition at line 328 of file MatrixFuncs.cpp.

332{
333 ASSERTL0(
334 curRow == curColumn,
335 "Iteration of a diagonal matrix is only valid along the diagonal.");
336
337 unsigned int nextRow = curRow;
338 unsigned int nextColumn = curColumn;
339
340 if (nextRow < totalRows)
341 {
342 ++nextRow;
343 ++nextColumn;
344 }
345
346 if (nextRow >= totalRows)
347 {
348 nextRow = std::numeric_limits<unsigned int>::max();
349 nextColumn = std::numeric_limits<unsigned int>::max();
350 }
351
352 return std::tuple<unsigned int, unsigned int>(nextRow, nextColumn);
353}
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:208

References ASSERTL0.

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

◆ CalculateIndex()

unsigned int Nektar::DiagonalMatrixFuncs::CalculateIndex ( unsigned int  row,
unsigned int  col 
)
static

Definition at line 362 of file MatrixFuncs.cpp.

364{
365 if (row == col)
366 {
367 return row;
368 }
369 else
370 {
371 return std::numeric_limits<unsigned int>::max();
372 }
373}

◆ GetRequiredStorageSize()

unsigned int Nektar::DiagonalMatrixFuncs::GetRequiredStorageSize ( unsigned int  rows,
unsigned int  columns 
)
static

Definition at line 355 of file MatrixFuncs.cpp.

357{
358 ASSERTL0(rows == columns, "Diagonal matrices must be square.");
359 return rows;
360}

References ASSERTL0.

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

◆ Invert()

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

Definition at line 285 of file MatrixFuncs.h.

287 {
288 ASSERTL0(rows == columns, "Only square matrices can be inverted.");
289 for (unsigned int i = 0; i < rows; ++i)
290 {
291 data[i] = 1.0 / data[i];
292 }
293 }

References ASSERTL0.

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