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

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

References ASSERTL1.

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

◆ CalculateIndex()

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

Definition at line 276 of file MatrixFuncs.cpp.

278{
279 if (curRow <= curColumn)
280 {
281 return curRow + curColumn * (curColumn + 1) / 2;
282 }
283 else
284 {
285 return curColumn + curRow * (curRow + 1) / 2;
286 }
287}

◆ GetRequiredStorageSize()

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

Definition at line 192 of file MatrixFuncs.cpp.

150{
151 ASSERTL0(rows == columns, "Triangular matrices must be square.");
152 return rows * (rows + 1) / 2;
153}
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:208

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:112
static void DoSsptri(const char &uplo, const int &n, const double *ap, const int *ipiv, double *work, int &info)
Invert a real packed-symmetric matrix problem.
Definition: Lapack.hpp:162

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

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