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

337{
338 boost::ignore_unused(totalColumns);
339
340 ASSERTL0(
341 curRow == curColumn,
342 "Iteration of a diagonal matrix is only valid along the diagonal.");
343
344 unsigned int nextRow = curRow;
345 unsigned int nextColumn = curColumn;
346
347 if (nextRow < totalRows)
348 {
349 ++nextRow;
350 ++nextColumn;
351 }
352
353 if (nextRow >= totalRows)
354 {
355 nextRow = std::numeric_limits<unsigned int>::max();
356 nextColumn = std::numeric_limits<unsigned int>::max();
357 }
358
359 return std::tuple<unsigned int, unsigned int>(nextRow, nextColumn);
360}
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:215

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

371{
372 if (row == col)
373 {
374 return row;
375 }
376 else
377 {
378 return std::numeric_limits<unsigned int>::max();
379 }
380}

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

◆ GetRequiredStorageSize()

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

Definition at line 362 of file MatrixFuncs.cpp.

364{
365 ASSERTL0(rows == columns, "Diagonal matrices must be square.");
366 return rows;
367}

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().