Nektar++
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
Nektar::NekMatrix< DataType, StandardMatrixTag > Class Template Reference

Standard Matrix. More...

#include <StandardMatrix.hpp>

Inheritance diagram for Nektar::NekMatrix< DataType, StandardMatrixTag >:
[legend]

Classes

class  iterator_impl
 
class  Proxy
 

Public Types

typedef Matrix< DataType > BaseType
 
typedef NekMatrix< DataType, StandardMatrixTag > ThisType
 
typedef DataType NumberType
 
typedef const DataType & ConstGetValueType
 
typedef DataType GetValueType
 
typedef iterator_impl< const DataType, const ThisTypeconst_iterator
 
typedef iterator_impl< DataType, ThisTypeiterator
 

Public Member Functions

 NekMatrix ()
 Creates an empty matrix. More...
 
 NekMatrix (unsigned int rows, unsigned int columns, MatrixStorage policy=eFULL, unsigned int subDiagonals=std::numeric_limits< unsigned int >::max(), unsigned int superDiagonals=std::numeric_limits< unsigned int >::max())
 Creates a rows by columns matrix. More...
 
 NekMatrix (unsigned int rows, unsigned int columns, MatrixStorage policy, unsigned int subDiagonals, unsigned int superDiagonals, unsigned int capacity)
 
 NekMatrix (unsigned int rows, unsigned int columns, typename boost::call_traits< DataType >::const_reference initValue, MatrixStorage policy=eFULL, unsigned int subDiagonals=std::numeric_limits< unsigned int >::max(), unsigned int superDiagonals=std::numeric_limits< unsigned int >::max())
 Creates a rows by columns matrix. More...
 
 NekMatrix (unsigned int rows, unsigned int columns, const DataType *data, MatrixStorage policy=eFULL, unsigned int subDiagonals=std::numeric_limits< unsigned int >::max(), unsigned int superDiagonals=std::numeric_limits< unsigned int >::max())
 Creates a rows by columns matrix. More...
 
 NekMatrix (unsigned int rows, unsigned int columns, const Array< OneD, const DataType > &d, MatrixStorage policy=eFULL, unsigned int subDiagonals=std::numeric_limits< unsigned int >::max(), unsigned int superDiagonals=std::numeric_limits< unsigned int >::max())
 Creates a rows by columns matrix. More...
 
 NekMatrix (unsigned int rows, unsigned int columns, const Array< OneD, DataType > &d, PointerWrapper wrapperType=eCopy, MatrixStorage policy=eFULL, unsigned int subDiagonals=std::numeric_limits< unsigned int >::max(), unsigned int superDiagonals=std::numeric_limits< unsigned int >::max())
 Creates a rows by columns matrix. More...
 
 NekMatrix (const ThisType &rhs)
 
ThisTypeoperator= (const ThisType &rhs)
 
ThisTypeoperator= (const DataType &rhs)
 Fill matrix with scalar. More...
 
template<typename InnerMatrixType >
ThisTypeoperator= (const NekMatrix< InnerMatrixType, ScaledMatrixTag > &rhs)
 
ConstGetValueType operator() (unsigned int row, unsigned int column) const
 Returns the element value at the given row and column. More...
 
ConstGetValueType operator() (unsigned int row, unsigned int column, char transpose) const
 Returns the element value at the given row and column. More...
 
unsigned int GetRequiredStorageSize () const
 
unsigned int CalculateIndex (unsigned int row, unsigned int col, const char transpose) const
 
boost::call_traits< DataType >::const_reference GetValue (unsigned int row, unsigned int column) const
 Returns the element value at the given row and column. More...
 
ConstGetValueType GetValue (unsigned int row, unsigned int column, char transpose) const
 Returns the element value at the given row and column. More...
 
const Array< OneD, const DataType > & GetPtr () const
 
DataType Scale () const
 Returns the scaling used by this matrix. More...
 
const DataType * GetRawPtr () const
 
iterator begin ()
 
iterator begin (char transpose)
 
iterator end ()
 
iterator end (char transpose)
 
const_iterator begin () const
 
const_iterator begin (char transpose) const
 
const_iterator end () const
 
const_iterator end (char transpose) const
 
unsigned int GetStorageSize () const
 
unsigned int GetNumberOfSubDiagonals () const
 
unsigned int GetNumberOfSuperDiagonals () const
 
unsigned int CalculateNumberOfRows () const
 
bool operator== (const NekMatrix< DataType, StandardMatrixTag > &rhs) const
 Returns true if the this matrix and rhs are equivalent. More...
 
PointerWrapper GetWrapperType () const
 
std::tuple< unsigned int, unsigned int > Advance (unsigned int curRow, unsigned int curColumn) const
 
std::tuple< unsigned int, unsigned int > Advance (unsigned int curRow, unsigned int curColumn, char transpose) const
 
void SetSize (unsigned int rows, unsigned int cols)
 
Proxy operator() (unsigned int row, unsigned int column)
 
Proxy operator() (unsigned int row, unsigned int column, char transpose)
 
void SetValue (unsigned int row, unsigned int column, typename boost::call_traits< DataType >::const_reference d)
 
void SetValue (unsigned int row, unsigned int column, typename boost::call_traits< DataType >::const_reference d, char transpose)
 
Array< OneD, DataType > & GetPtr ()
 
DataType * GetRawPtr ()
 
DataType AbsMaxtoMinEigenValueRatio (void)
 
void EigenSolve (Array< OneD, DataType > &EigValReal, Array< OneD, DataType > &EigValImag, Array< OneD, DataType > &EigVecs)
 
void Invert ()
 
Array< OneD, DataType > & GetTempSpace ()
 
void SwapTempAndDataBuffers ()
 
ThisTypeoperator*= (const NumberType &s)
 
NekMatrix< DataType, StandardMatrixTag > operator- () const
 
- Public Member Functions inherited from Nektar::Matrix< DataType >
 ~Matrix () override
 
void SetValue (unsigned int row, unsigned int column, typename boost::call_traits< DataType >::const_reference d)
 
- Public Member Functions inherited from Nektar::ConstMatrix< DataType >
virtual ~ConstMatrix ()=default
 
boost::call_traits< DataType >::value_type operator() (unsigned int row, unsigned int column) const
 
unsigned int GetStorageSize () const
 
MatrixStorage GetType () const
 
MatrixStorage GetStorageType () const
 
unsigned int GetRows () const
 
unsigned int GetTransposedRows (char transpose) const
 
unsigned int GetColumns () const
 
unsigned int GetTransposedColumns (char transpose) const
 
const unsigned int * GetSize () const
 
void Transpose ()
 
char GetTransposeFlag () const
 

Static Public Member Functions

static ThisType CreateWrapper (const ThisType &rhs)
 
static std::shared_ptr< ThisTypeCreateWrapper (const std::shared_ptr< ThisType > &rhs)
 
- Static Public Member Functions inherited from Nektar::ConstMatrix< DataType >
static unsigned int CalculateIndex (MatrixStorage type, unsigned int row, unsigned int col, unsigned int numRows, unsigned int numColumns, const char transpose='N', unsigned int numSubDiags=0, unsigned int numSuperDiags=0)
 
static unsigned int GetRequiredStorageSize (MatrixStorage type, unsigned int rows, unsigned int columns, unsigned int subDiags=0, unsigned int superDiags=0)
 

Protected Member Functions

 NekMatrix (const ThisType &rhs, PointerWrapper wrapperType)
 
Array< OneD, DataType > & GetData ()
 
void RemoveExcessCapacity ()
 
void ResizeDataArrayIfNeeded (unsigned int requiredStorageSize)
 
void ResizeDataArrayIfNeeded ()
 
boost::call_traits< DataType >::value_type v_GetValue (unsigned int row, unsigned int column) const override
 
unsigned int v_GetStorageSize () const override
 
void v_SetValue (unsigned int row, unsigned int column, typename boost::call_traits< DataType >::const_reference d) override
 
- Protected Member Functions inherited from Nektar::Matrix< DataType >
 Matrix (unsigned int rows, unsigned int columns, MatrixStorage policy=eFULL)
 
 Matrix (const Matrix< DataType > &rhs)
 
Matrix< DataType > & operator= (const Matrix< DataType > &rhs)
 
Matrix< DataType > & operator= (const ConstMatrix< DataType > &rhs)
 
- Protected Member Functions inherited from Nektar::ConstMatrix< DataType >
 ConstMatrix (unsigned int rows, unsigned int columns, MatrixStorage policy=eFULL)
 
 ConstMatrix (const ConstMatrix< DataType > &rhs)
 
ConstMatrix< DataType > & operator= (const ConstMatrix< DataType > &rhs)
 
void Resize (unsigned int rows, unsigned int columns)
 Resets the rows and columns in the array. This method does not update the data storage to match the new row and column counts. More...
 
void SetTransposeFlag (char newValue)
 
char GetRawTransposeFlag () const
 
virtual boost::call_traits< DataType >::value_type v_GetValue (unsigned int row, unsigned int column) const =0
 
virtual unsigned int v_GetStorageSize () const =0
 
virtual void v_Transpose ()
 
virtual char v_GetTransposeFlag () const
 

Private Member Functions

void PerformCopyConstruction (const ThisType &rhs)
 

Private Attributes

Array< OneD, DataType > m_data
 
PointerWrapper m_wrapperType
 
unsigned int m_numberOfSuperDiagonals
 
unsigned int m_numberOfSubDiagonals
 
Array< OneD, DataType > m_tempSpace
 

Detailed Description

template<typename DataType>
class Nektar::NekMatrix< DataType, StandardMatrixTag >

Standard Matrix.

Parameters
DataTypeThe type stored in each element.

Matrices are stored in column major order to make it easier to interoperate with Blas and Lapack.

Definition at line 55 of file StandardMatrix.hpp.

Member Typedef Documentation

◆ BaseType

template<typename DataType >
typedef Matrix<DataType> Nektar::NekMatrix< DataType, StandardMatrixTag >::BaseType

Definition at line 58 of file StandardMatrix.hpp.

◆ const_iterator

template<typename DataType >
typedef iterator_impl<const DataType, const ThisType> Nektar::NekMatrix< DataType, StandardMatrixTag >::const_iterator

Definition at line 425 of file StandardMatrix.hpp.

◆ ConstGetValueType

template<typename DataType >
typedef const DataType& Nektar::NekMatrix< DataType, StandardMatrixTag >::ConstGetValueType

Definition at line 61 of file StandardMatrix.hpp.

◆ GetValueType

template<typename DataType >
typedef DataType Nektar::NekMatrix< DataType, StandardMatrixTag >::GetValueType

Definition at line 62 of file StandardMatrix.hpp.

◆ iterator

template<typename DataType >
typedef iterator_impl<DataType, ThisType> Nektar::NekMatrix< DataType, StandardMatrixTag >::iterator

Definition at line 426 of file StandardMatrix.hpp.

◆ NumberType

template<typename DataType >
typedef DataType Nektar::NekMatrix< DataType, StandardMatrixTag >::NumberType

Definition at line 60 of file StandardMatrix.hpp.

◆ ThisType

template<typename DataType >
typedef NekMatrix<DataType, StandardMatrixTag> Nektar::NekMatrix< DataType, StandardMatrixTag >::ThisType

Definition at line 59 of file StandardMatrix.hpp.

Constructor & Destructor Documentation

◆ NekMatrix() [1/9]

template<typename DataType >
Nektar::NekMatrix< DataType, StandardMatrixTag >::NekMatrix

Creates an empty matrix.

Definition at line 41 of file StandardMatrix.cpp.

42 : Matrix<DataType>(0, 0, eFULL), m_data(), m_wrapperType(eCopy),
43 m_numberOfSuperDiagonals(std::numeric_limits<unsigned int>::max()),
44 m_numberOfSubDiagonals(std::numeric_limits<unsigned int>::max()),
46{
47 m_data = Array<OneD, DataType>(GetRequiredStorageSize());
48}

◆ NekMatrix() [2/9]

template<typename DataType >
Nektar::NekMatrix< DataType, StandardMatrixTag >::NekMatrix ( unsigned int  rows,
unsigned int  columns,
MatrixStorage  policy = eFULL,
unsigned int  subDiagonals = std::numeric_limits<unsigned int>::max(),
unsigned int  superDiagonals = std::numeric_limits<unsigned int>::max() 
)

Creates a rows by columns matrix.

rows The number of rows in the matrix.

columns The number of columns in the matrix.

Definition at line 51 of file StandardMatrix.cpp.

56 : Matrix<DataType>(rows, columns, policy), m_data(), m_wrapperType(eCopy),
57 m_numberOfSuperDiagonals(superDiagonals),
58 m_numberOfSubDiagonals(subDiagonals), m_tempSpace()
59{
60 m_data = Array<OneD, DataType>(GetRequiredStorageSize());
61}

◆ NekMatrix() [3/9]

template<typename DataType >
Nektar::NekMatrix< DataType, StandardMatrixTag >::NekMatrix ( unsigned int  rows,
unsigned int  columns,
MatrixStorage  policy,
unsigned int  subDiagonals,
unsigned int  superDiagonals,
unsigned int  capacity 
)

Definition at line 64 of file StandardMatrix.cpp.

70 : Matrix<DataType>(rows, columns, policy), m_data(), m_wrapperType(eCopy),
71 m_numberOfSuperDiagonals(superDiagonals),
72 m_numberOfSubDiagonals(subDiagonals), m_tempSpace()
73{
74 unsigned int requiredStorage = this->GetRequiredStorageSize();
75 unsigned int actualSize = std::max(requiredStorage, capacity);
76 m_data = Array<OneD, DataType>(actualSize);
77}

◆ NekMatrix() [4/9]

template<typename DataType >
Nektar::NekMatrix< DataType, StandardMatrixTag >::NekMatrix ( unsigned int  rows,
unsigned int  columns,
typename boost::call_traits< DataType >::const_reference  initValue,
MatrixStorage  policy = eFULL,
unsigned int  subDiagonals = std::numeric_limits<unsigned int>::max(),
unsigned int  superDiagonals = std::numeric_limits<unsigned int>::max() 
)

Creates a rows by columns matrix.

rows The number of rows in the matrix.

columns The number of columns in the matrix.

initValue The value used to initialize each element.

policySpecificData Data the is specific to the storage type assigned to this matrix. Check MatrixStoragePolicy<StorageType> to see if the StoragePolicy for this matrix has policy specific data.

Definition at line 80 of file StandardMatrix.cpp.

85 : Matrix<DataType>(rows, columns, policy), m_data(), m_wrapperType(eCopy),
86 m_numberOfSuperDiagonals(superDiagonals),
87 m_numberOfSubDiagonals(subDiagonals), m_tempSpace()
88{
89 m_data = Array<OneD, DataType>(GetRequiredStorageSize());
90 std::fill(m_data.begin(), m_data.end(), initValue);
91}
Array< OneD, constDataType >::const_iterator begin() const

◆ NekMatrix() [5/9]

template<typename DataType >
Nektar::NekMatrix< DataType, StandardMatrixTag >::NekMatrix ( unsigned int  rows,
unsigned int  columns,
const DataType *  data,
MatrixStorage  policy = eFULL,
unsigned int  subDiagonals = std::numeric_limits<unsigned int>::max(),
unsigned int  superDiagonals = std::numeric_limits<unsigned int>::max() 
)

Creates a rows by columns matrix.

rows The number of rows in the matrix.

columns The number of columns in the matrix.

data An array of data use to initialize the matrix.

policySpecificData Data the is specific to the storage type assigned to this matrix. Check MatrixStoragePolicy<StorageType> to see if the StoragePolicy for this matrix has policy specific data.

Definition at line 94 of file StandardMatrix.cpp.

100 : Matrix<DataType>(rows, columns, policy), m_data(), m_wrapperType(eCopy),
101 m_numberOfSuperDiagonals(superDiagonals),
102 m_numberOfSubDiagonals(subDiagonals), m_tempSpace()
103{
104 unsigned int size = GetRequiredStorageSize();
105 m_data = Array<OneD, DataType>(size);
106 std::copy(data, data + size, m_data.begin());
107}
def copy(self)
Definition: pycml.py:2663

References CellMLToNektar.pycml::copy().

◆ NekMatrix() [6/9]

template<typename DataType >
Nektar::NekMatrix< DataType, StandardMatrixTag >::NekMatrix ( unsigned int  rows,
unsigned int  columns,
const Array< OneD, const DataType > &  d,
MatrixStorage  policy = eFULL,
unsigned int  subDiagonals = std::numeric_limits<unsigned int>::max(),
unsigned int  superDiagonals = std::numeric_limits<unsigned int>::max() 
)

Creates a rows by columns matrix.

rows The number of rows in the matrix.

columns The number of columns in the matrix.

d An array of data used to initialize the matrix. Values from d are copied into the matrix. policySpecificData Data the is specific to the storage type assigned to this matrix. Check MatrixStoragePolicy<StorageType> to see if the StoragePolicy for this matrix has policy specific data.

Definition at line 110 of file StandardMatrix.cpp.

114 : Matrix<DataType>(rows, columns, policy), m_data(), m_wrapperType(eCopy),
115 m_numberOfSuperDiagonals(superDiagonals),
116 m_numberOfSubDiagonals(subDiagonals), m_tempSpace()
117{
118 m_data = Array<OneD, DataType>(GetRequiredStorageSize());
120}
size_type size() const
Returns the array's size.
std::vector< double > d(NPUPPER *NPUPPER)
void CopyArrayN(const Array< OneD, ConstDataType > &source, Array< OneD, DataType > &dest, typename Array< OneD, DataType >::size_type n)

References Nektar::CopyArrayN(), and Nektar::UnitTests::d().

◆ NekMatrix() [7/9]

template<typename DataType >
Nektar::NekMatrix< DataType, StandardMatrixTag >::NekMatrix ( unsigned int  rows,
unsigned int  columns,
const Array< OneD, DataType > &  d,
PointerWrapper  wrapperType = eCopy,
MatrixStorage  policy = eFULL,
unsigned int  subDiagonals = std::numeric_limits<unsigned int>::max(),
unsigned int  superDiagonals = std::numeric_limits<unsigned int>::max() 
)

Creates a rows by columns matrix.

rows The number of rows in the matrix.

columns The number of columns in the matrix.

d An array of data used to initialize the matrix. If wrapperType is eCopy, then each element is copied from d to the matrix. If wrapperType is eWrapper, then the matrix uses d directly as its matrix data and no copies are made.

policySpecificData Data the is specific to the storage type assigned to this matrix. Check MatrixStoragePolicy<StorageType> to see if the StoragePolicy for this matrix has policy specific data.

Definition at line 123 of file StandardMatrix.cpp.

127 : Matrix<DataType>(rows, columns, policy), m_data(),
128 m_wrapperType(wrapperType), m_numberOfSuperDiagonals(superDiagonals),
129 m_numberOfSubDiagonals(subDiagonals), m_tempSpace()
130{
131 if (wrapperType == eWrapper)
132 {
133 m_data = Array<OneD, DataType>(d);
134 }
135 else
136 {
137 m_data = Array<OneD, DataType>(GetRequiredStorageSize());
139 }
140}

References Nektar::CopyArrayN(), Nektar::UnitTests::d(), and Nektar::eWrapper.

◆ NekMatrix() [8/9]

template<typename DataType >
Nektar::NekMatrix< DataType, StandardMatrixTag >::NekMatrix ( const ThisType rhs)

Definition at line 143 of file StandardMatrix.cpp.

145 : Matrix<DataType>(rhs), m_data(), m_wrapperType(rhs.m_wrapperType),
146 m_numberOfSuperDiagonals(rhs.m_numberOfSuperDiagonals),
147 m_numberOfSubDiagonals(rhs.m_numberOfSubDiagonals), m_tempSpace()
148{
150}

◆ NekMatrix() [9/9]

template<typename DataType >
Nektar::NekMatrix< DataType, StandardMatrixTag >::NekMatrix ( const ThisType rhs,
PointerWrapper  wrapperType 
)
protected

Definition at line 498 of file StandardMatrix.cpp.

501 : BaseType(rhs), m_data(), m_wrapperType(wrapperType),
502 m_numberOfSuperDiagonals(rhs.m_numberOfSuperDiagonals),
503 m_numberOfSubDiagonals(rhs.m_numberOfSubDiagonals)
504{
506}

Member Function Documentation

◆ AbsMaxtoMinEigenValueRatio()

template<typename DataType >
DataType Nektar::NekMatrix< DataType, StandardMatrixTag >::AbsMaxtoMinEigenValueRatio ( void  )

Definition at line 742 of file StandardMatrix.cpp.

744{
745 DataType returnval;
746 int nvals = this->GetColumns();
747 Array<OneD, DataType> EigValReal(nvals);
748 Array<OneD, DataType> EigValImag(nvals);
749 Array<OneD, DataType> Evecs;
750
751 EigenSolve(EigValReal, EigValImag, Evecs);
752
753 Vmath::Vmul(nvals, EigValReal, 1, EigValReal, 1, EigValReal, 1);
754 Vmath::Vmul(nvals, EigValImag, 1, EigValImag, 1, EigValImag, 1);
755 Vmath::Vadd(nvals, EigValReal, 1, EigValImag, 1, EigValReal, 1);
756
757 returnval = sqrt(Vmath::Vmax(nvals, EigValReal, 1) /
758 Vmath::Vmin(nvals, EigValReal, 1));
759
760 return returnval;
761}
unsigned int GetColumns() const
Definition: MatrixBase.cpp:73
void EigenSolve(Array< OneD, DataType > &EigValReal, Array< OneD, DataType > &EigValImag, Array< OneD, DataType > &EigVecs)
void Vmul(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x*y.
Definition: Vmath.hpp:72
T Vmin(int n, const T *x, const int incx)
Return the minimum element in x - called vmin to avoid conflict with min.
Definition: Vmath.hpp:725
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
Definition: Vmath.hpp:180
T Vmax(int n, const T *x, const int incx)
Return the maximum element in x – called vmax to avoid conflict with max.
Definition: Vmath.hpp:644
scalarT< T > sqrt(scalarT< T > in)
Definition: scalar.hpp:285

References tinysimd::sqrt(), Vmath::Vadd(), Vmath::Vmax(), Vmath::Vmin(), and Vmath::Vmul().

◆ Advance() [1/2]

template<typename DataType >
std::tuple< unsigned int, unsigned int > Nektar::NekMatrix< DataType, StandardMatrixTag >::Advance ( unsigned int  curRow,
unsigned int  curColumn 
) const

Definition at line 419 of file StandardMatrix.cpp.

421{
422 return Advance(curRow, curColumn, this->GetTransposeFlag());
423}
char GetTransposeFlag() const
Definition: MatrixBase.cpp:104
std::tuple< unsigned int, unsigned int > Advance(unsigned int curRow, unsigned int curColumn) const

◆ Advance() [2/2]

template<typename DataType >
std::tuple< unsigned int, unsigned int > Nektar::NekMatrix< DataType, StandardMatrixTag >::Advance ( unsigned int  curRow,
unsigned int  curColumn,
char  transpose 
) const

Definition at line 427 of file StandardMatrix.cpp.

430{
431 unsigned int numRows = this->GetTransposedRows(transpose);
432 unsigned int numColumns = this->GetTransposedColumns(transpose);
433
434 switch (this->GetStorageType())
435 {
436 case eFULL:
437 return FullMatrixFuncs::Advance(numRows, numColumns, curRow,
438 curColumn);
439 break;
440 case eDIAGONAL:
441 return DiagonalMatrixFuncs::Advance(numRows, numColumns, curRow,
442 curColumn);
443 break;
445 return UpperTriangularMatrixFuncs::Advance(numRows, numColumns,
446 curRow, curColumn);
447 break;
448
450 return LowerTriangularMatrixFuncs::Advance(numRows, numColumns,
451 curRow, curColumn);
452 break;
453
454 case eSYMMETRIC:
456 return SymmetricMatrixFuncs::Advance(numRows, numColumns, curRow,
457 curColumn);
458 break;
459 case eBANDED:
460 return BandedMatrixFuncs::Advance(numRows, numColumns, curRow,
461 curColumn);
462 break;
465 NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
466 break;
468 NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
469 break;
471 NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
472 break;
473
474 default:
475 NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
476 }
477 return std::tuple<unsigned int, unsigned int>(curRow, curColumn);
478}
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
Definition: ErrorUtil.hpp:202
MatrixStorage GetStorageType() const
Definition: MatrixBase.hpp:69
unsigned int GetTransposedColumns(char transpose) const
Definition: MatrixBase.cpp:79
unsigned int GetTransposedRows(char transpose) const
Definition: MatrixBase.cpp:67
@ eLOWER_TRIANGULAR_BANDED
@ ePOSITIVE_DEFINITE_SYMMETRIC_BANDED
@ ePOSITIVE_DEFINITE_SYMMETRIC
@ eUPPER_TRIANGULAR_BANDED
static std::tuple< unsigned int, unsigned int > Advance(const unsigned int totalRows, const unsigned int totalColumns, const unsigned int curRow, const unsigned int curColumn)
Definition: MatrixFuncs.cpp:97
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 std::tuple< unsigned int, unsigned int > Advance(const unsigned int totalRows, const unsigned int totalColumns, const unsigned int curRow, const unsigned int curColumn)
static std::tuple< unsigned int, unsigned int > Advance(const unsigned int totalRows, const unsigned int totalColumns, const unsigned int curRow, const unsigned int curColumn, char transpose='N')
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 std::tuple< unsigned int, unsigned int > Advance(const unsigned int totalRows, const unsigned int totalColumns, const unsigned int curRow, const unsigned int curColumn)

References Nektar::BandedMatrixFuncs::Advance(), Nektar::FullMatrixFuncs::Advance(), Nektar::UpperTriangularMatrixFuncs::Advance(), Nektar::SymmetricMatrixFuncs::Advance(), Nektar::DiagonalMatrixFuncs::Advance(), Nektar::LowerTriangularMatrixFuncs::Advance(), Nektar::eBANDED, Nektar::eDIAGONAL, Nektar::ErrorUtil::efatal, Nektar::eFULL, Nektar::eLOWER_TRIANGULAR, Nektar::eLOWER_TRIANGULAR_BANDED, Nektar::ePOSITIVE_DEFINITE_SYMMETRIC, Nektar::ePOSITIVE_DEFINITE_SYMMETRIC_BANDED, Nektar::eSYMMETRIC, Nektar::eSYMMETRIC_BANDED, Nektar::eUPPER_TRIANGULAR, Nektar::eUPPER_TRIANGULAR_BANDED, and NEKERROR.

◆ begin() [1/4]

template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::iterator Nektar::NekMatrix< DataType, StandardMatrixTag >::begin

Definition at line 699 of file StandardMatrix.cpp.

Referenced by operator==().

◆ begin() [2/4]

template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::const_iterator Nektar::NekMatrix< DataType, StandardMatrixTag >::begin

Definition at line 290 of file StandardMatrix.cpp.

291{
292 return begin(this->GetTransposeFlag());
293}

◆ begin() [3/4]

template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::iterator Nektar::NekMatrix< DataType, StandardMatrixTag >::begin ( char  transpose)

Definition at line 706 of file StandardMatrix.cpp.

707{
708 if (transpose == 'N')
709 {
710 return iterator(this->GetData().data(),
711 this->GetData().data() + this->GetData().size());
712 }
713 else
714 {
715 return iterator(this, transpose);
716 }
717}
iterator_impl< DataType, ThisType > iterator

◆ begin() [4/4]

template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::const_iterator Nektar::NekMatrix< DataType, StandardMatrixTag >::begin ( char  transpose) const

Definition at line 297 of file StandardMatrix.cpp.

298{
299 if (transpose == 'N')
300 {
302 }
303 else
304 {
305 return const_iterator(this, transpose);
306 }
307}
iterator_impl< const DataType, const ThisType > const_iterator

◆ CalculateIndex()

template<typename DataType >
unsigned int Nektar::NekMatrix< DataType, StandardMatrixTag >::CalculateIndex ( unsigned int  row,
unsigned int  col,
const char  transpose 
) const

Definition at line 224 of file StandardMatrix.cpp.

226{
227 unsigned int numRows = this->GetSize()[0];
228 unsigned int numColumns = this->GetSize()[1];
230 this->GetStorageType(), row, col, numRows, numColumns, transpose,
232}
static unsigned int CalculateIndex(MatrixStorage type, unsigned int row, unsigned int col, unsigned int numRows, unsigned int numColumns, const char transpose='N', unsigned int numSubDiags=0, unsigned int numSuperDiags=0)
Definition: MatrixBase.cpp:110
const unsigned int * GetSize() const
Definition: MatrixBase.cpp:85

References Nektar::ConstMatrix< DataType >::CalculateIndex().

◆ CalculateNumberOfRows()

template<typename DataType >
unsigned int Nektar::NekMatrix< DataType, StandardMatrixTag >::CalculateNumberOfRows

Definition at line 374 of file StandardMatrix.cpp.

◆ CreateWrapper() [1/2]

template<typename DataType >
std::shared_ptr< NekMatrix< DataType, StandardMatrixTag > > Nektar::NekMatrix< DataType, StandardMatrixTag >::CreateWrapper ( const std::shared_ptr< ThisType > &  rhs)
static

Definition at line 489 of file StandardMatrix.cpp.

492{
493 return std::shared_ptr<NekMatrix<DataType, StandardMatrixTag>>(
494 new NekMatrix<DataType, StandardMatrixTag>(*rhs, eWrapper));
495}

References Nektar::eWrapper.

◆ CreateWrapper() [2/2]

template<typename DataType >
NekMatrix< DataType, StandardMatrixTag > Nektar::NekMatrix< DataType, StandardMatrixTag >::CreateWrapper ( const ThisType rhs)
static

Definition at line 481 of file StandardMatrix.cpp.

483{
484 return NekMatrix<DataType, StandardMatrixTag>(rhs, eWrapper);
485}

References Nektar::eWrapper.

◆ EigenSolve()

template<typename DataType >
void Nektar::NekMatrix< DataType, StandardMatrixTag >::EigenSolve ( Array< OneD, DataType > &  EigValReal,
Array< OneD, DataType > &  EigValImag,
Array< OneD, DataType > &  EigVecs 
)

Definition at line 764 of file StandardMatrix.cpp.

767{
768 ASSERTL0(this->GetRows() == this->GetColumns(),
769 "Only square matrices can be called");
770
771 switch (this->GetType())
772 {
773 case eFULL:
775 EigValReal, EigValImag, EigVecs);
776 break;
777 case eDIAGONAL:
778 Vmath::Vcopy(this->GetRows(), &(this->GetData())[0], 1,
779 &EigValReal[0], 1);
780 Vmath::Zero(this->GetRows(), &EigValImag[0], 1);
781 break;
784 case eSYMMETRIC:
785 case eBANDED:
789 NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
790 break;
791
792 default:
793 NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
794 }
795}
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:208
MatrixStorage GetType() const
Definition: MatrixBase.hpp:64
unsigned int GetRows() const
Definition: MatrixBase.cpp:61
void Zero(int n, T *x, const int incx)
Zero vector.
Definition: Vmath.hpp:273
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.hpp:825
static void EigenSolve(unsigned int n, const Array< OneD, const DataType > &A, Array< OneD, DataType > &EigValReal, Array< OneD, DataType > &EigValImag, Array< OneD, DataType > &EigVecs)
Definition: MatrixFuncs.h:160

References ASSERTL0, Nektar::eBANDED, Nektar::eDIAGONAL, Nektar::ErrorUtil::efatal, Nektar::eFULL, Nektar::FullMatrixFuncs::EigenSolve(), Nektar::eLOWER_TRIANGULAR, Nektar::eLOWER_TRIANGULAR_BANDED, Nektar::eSYMMETRIC, Nektar::eSYMMETRIC_BANDED, Nektar::eUPPER_TRIANGULAR, Nektar::eUPPER_TRIANGULAR_BANDED, NEKERROR, Vmath::Vcopy(), and Vmath::Zero().

◆ end() [1/4]

template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::iterator Nektar::NekMatrix< DataType, StandardMatrixTag >::end

Definition at line 721 of file StandardMatrix.cpp.

◆ end() [2/4]

template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::const_iterator Nektar::NekMatrix< DataType, StandardMatrixTag >::end

Definition at line 311 of file StandardMatrix.cpp.

312{
313 return end(this->GetTransposeFlag());
314}

◆ end() [3/4]

template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::iterator Nektar::NekMatrix< DataType, StandardMatrixTag >::end ( char  transpose)

Definition at line 728 of file StandardMatrix.cpp.

729{
730 if (transpose == 'N')
731 {
732 return iterator(this->GetData().data(),
733 this->GetData().data() + this->GetData().size(), true);
734 }
735 else
736 {
737 return iterator(this, transpose, true);
738 }
739}

◆ end() [4/4]

template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::const_iterator Nektar::NekMatrix< DataType, StandardMatrixTag >::end ( char  transpose) const

Definition at line 318 of file StandardMatrix.cpp.

319{
320 if (transpose == 'N')
321 {
323 true);
324 }
325 else
326 {
327 return const_iterator(this, transpose, true);
328 }
329}

◆ GetData()

template<typename DataType >
Array< OneD, DataType > & Nektar::NekMatrix< DataType, StandardMatrixTag >::GetData
protected

Definition at line 509 of file StandardMatrix.cpp.

510{
511 return m_data;
512}

◆ GetNumberOfSubDiagonals()

template<typename DataType >
unsigned int Nektar::NekMatrix< DataType, StandardMatrixTag >::GetNumberOfSubDiagonals

Definition at line 338 of file StandardMatrix.cpp.

340{
341 if (m_numberOfSubDiagonals != std::numeric_limits<unsigned int>::max())
342 {
344 }
345 else if (this->GetRows() > 0)
346 {
347 return this->GetRows() - 1;
348 }
349 else
350 {
351 return 0;
352 }
353}

Referenced by Nektar::Transpose().

◆ GetNumberOfSuperDiagonals()

template<typename DataType >
unsigned int Nektar::NekMatrix< DataType, StandardMatrixTag >::GetNumberOfSuperDiagonals

Definition at line 356 of file StandardMatrix.cpp.

358{
359 if (m_numberOfSuperDiagonals != std::numeric_limits<unsigned int>::max())
360 {
362 }
363 else if (this->GetRows() > 0)
364 {
365 return this->GetRows() - 1;
366 }
367 else
368 {
369 return 0;
370 }
371}

Referenced by Nektar::Transpose().

◆ GetPtr() [1/2]

template<typename DataType >
Array< OneD, DataType > & Nektar::NekMatrix< DataType, StandardMatrixTag >::GetPtr

Definition at line 686 of file StandardMatrix.cpp.

687{
688 return this->GetData();
689}

◆ GetPtr() [2/2]

template<typename DataType >
const Array< OneD, const DataType > & Nektar::NekMatrix< DataType, StandardMatrixTag >::GetPtr

Definition at line 271 of file StandardMatrix.cpp.

272{
273 return m_data;
274}

Referenced by Nektar::Transpose().

◆ GetRawPtr() [1/2]

template<typename DataType >
DataType * Nektar::NekMatrix< DataType, StandardMatrixTag >::GetRawPtr

Definition at line 692 of file StandardMatrix.cpp.

693{
694 return this->GetData().data();
695}

◆ GetRawPtr() [2/2]

template<typename DataType >
const DataType * Nektar::NekMatrix< DataType, StandardMatrixTag >::GetRawPtr

Definition at line 283 of file StandardMatrix.cpp.

284{
285 return m_data.data();
286}

Referenced by Nektar::NekMultiplyLowerTriangularMatrix(), and Nektar::NekMultiplyUpperTriangularMatrix().

◆ GetRequiredStorageSize()

template<typename DataType >
unsigned int Nektar::NekMatrix< DataType, StandardMatrixTag >::GetRequiredStorageSize

Definition at line 215 of file StandardMatrix.cpp.

217{
219 this->GetStorageType(), this->GetRows(), this->GetColumns(),
221}
static unsigned int GetRequiredStorageSize(MatrixStorage type, unsigned int rows, unsigned int columns, unsigned int subDiags=0, unsigned int superDiags=0)
Definition: MatrixBase.cpp:168

References Nektar::ConstMatrix< DataType >::GetRequiredStorageSize().

◆ GetStorageSize()

template<typename DataType >
unsigned int Nektar::NekMatrix< DataType, StandardMatrixTag >::GetStorageSize

Definition at line 332 of file StandardMatrix.cpp.

333{
334 return m_data.size();
335}

◆ GetTempSpace()

template<typename DataType >
Array< OneD, DataType > & Nektar::NekMatrix< DataType, StandardMatrixTag >::GetTempSpace

Definition at line 840 of file StandardMatrix.cpp.

841{
842 if (m_tempSpace.capacity() == 0)
843 {
844 m_tempSpace = Array<OneD, DataType>(this->GetData().capacity());
845 }
846 return m_tempSpace;
847}
size_type capacity() const
Returns the array's capacity.

◆ GetValue() [1/2]

template<typename DataType >
boost::call_traits< DataType >::const_reference Nektar::NekMatrix< DataType, StandardMatrixTag >::GetValue ( unsigned int  row,
unsigned int  column 
) const

Returns the element value at the given row and column.

Definition at line 236 of file StandardMatrix.cpp.

238{
239 ASSERTL2(row < this->GetRows(),
240 std::string("Row ") + std::to_string(row) +
241 std::string(" requested in a matrix with a maximum of ") +
242 std::to_string(this->GetRows()) + std::string(" rows"));
243 ASSERTL2(column < this->GetColumns(),
244 std::string("Column ") + std::to_string(column) +
245 std::string(" requested in a matrix with a maximum of ") +
246 std::to_string(this->GetColumns()) + std::string(" columns"));
247
248 return GetValue(row, column, this->GetTransposeFlag());
249}
#define ASSERTL2(condition, msg)
Assert Level 2 – Debugging which is used FULLDEBUG compilation mode. This level assert is designed to...
Definition: ErrorUtil.hpp:265
boost::call_traits< DataType >::const_reference GetValue(unsigned int row, unsigned int column) const
Returns the element value at the given row and column.

References ASSERTL2.

◆ GetValue() [2/2]

template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::ConstGetValueType Nektar::NekMatrix< DataType, StandardMatrixTag >::GetValue ( unsigned int  row,
unsigned int  column,
char  transpose 
) const

Returns the element value at the given row and column.

row The element's row.

column The element's column.

transpose If transpose = 'N', then the return value is element [row, column]. If transpose = 'T', then the return value is element [column, row].

Definition at line 253 of file StandardMatrix.cpp.

256{
257 static DataType defaultReturnValue;
258 unsigned int index = CalculateIndex(row, column, transpose);
259 if (index != std::numeric_limits<unsigned int>::max())
260 {
261 return m_data[index];
262 }
263 else
264 {
265 return defaultReturnValue;
266 }
267}
unsigned int CalculateIndex(unsigned int row, unsigned int col, const char transpose) const

◆ GetWrapperType()

template<typename DataType >
PointerWrapper Nektar::NekMatrix< DataType, StandardMatrixTag >::GetWrapperType

Definition at line 412 of file StandardMatrix.cpp.

413{
414 return m_wrapperType;
415}

◆ Invert()

template<typename DataType >
void Nektar::NekMatrix< DataType, StandardMatrixTag >::Invert

Definition at line 798 of file StandardMatrix.cpp.

799{
800 ASSERTL0(this->GetRows() == this->GetColumns(),
801 "Only square matrices can be inverted.");
802 ASSERTL0(this->GetTransposeFlag() == 'N',
803 "Only untransposed matrices may be inverted.");
804
805 switch (this->GetType())
806 {
807 case eFULL:
809 this->GetData(), this->GetTransposeFlag());
810 break;
811 case eDIAGONAL:
813 this->GetData());
814 break;
815 case eSYMMETRIC:
817 this->GetData());
818 break;
821 case eBANDED:
822 NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
823 break;
825 NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
826 break;
828 NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
829 break;
831 NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
832 break;
833
834 default:
835 NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
836 }
837}
static void Invert(unsigned int rows, unsigned int columns, Array< OneD, DataType > &data)
Definition: MatrixFuncs.h:286
static void Invert(unsigned int rows, unsigned int columns, Array< OneD, DataType > &data, const char transpose)
Definition: MatrixFuncs.h:91
static void Invert(unsigned int rows, unsigned int columns, Array< OneD, DataType > &data)
Definition: MatrixFuncs.h:231

References ASSERTL0, Nektar::eBANDED, Nektar::eDIAGONAL, Nektar::ErrorUtil::efatal, Nektar::eFULL, Nektar::eLOWER_TRIANGULAR, Nektar::eLOWER_TRIANGULAR_BANDED, Nektar::eSYMMETRIC, Nektar::eSYMMETRIC_BANDED, Nektar::eUPPER_TRIANGULAR, Nektar::eUPPER_TRIANGULAR_BANDED, Nektar::SymmetricMatrixFuncs::Invert(), Nektar::DiagonalMatrixFuncs::Invert(), Nektar::FullMatrixFuncs::Invert(), and NEKERROR.

◆ operator()() [1/4]

template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::Proxy Nektar::NekMatrix< DataType, StandardMatrixTag >::operator() ( unsigned int  row,
unsigned int  column 
)

Definition at line 619 of file StandardMatrix.cpp.

621{
622 ASSERTL2(row < this->GetRows(),
623 std::string("Row ") + std::to_string(row) +
624 std::string(" requested in a matrix with a maximum of ") +
625 std::to_string(this->GetRows()) + std::string(" rows"));
626 ASSERTL2(column < this->GetColumns(),
627 std::string("Column ") + std::to_string(column) +
628 std::string(" requested in a matrix with a maximum of ") +
629 std::to_string(this->GetColumns()) + std::string(" columns"));
630
631 return (*this)(row, column, this->GetTransposeFlag());
632}

References ASSERTL2.

◆ operator()() [2/4]

template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::ConstGetValueType Nektar::NekMatrix< DataType, StandardMatrixTag >::operator() ( unsigned int  row,
unsigned int  column 
) const

Returns the element value at the given row and column.

Definition at line 190 of file StandardMatrix.cpp.

192{
193 ASSERTL2(row < this->GetRows(),
194 std::string("Row ") + std::to_string(row) +
195 std::string(" requested in a matrix with a maximum of ") +
196 std::to_string(this->GetRows()) + std::string(" rows"));
197 ASSERTL2(column < this->GetColumns(),
198 std::string("Column ") + std::to_string(column) +
199 std::string(" requested in a matrix with a maximum of ") +
200 std::to_string(this->GetColumns()) + std::string(" columns"));
201
202 return this->GetValue(row, column, this->GetTransposeFlag());
203}

References ASSERTL2.

◆ operator()() [3/4]

template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::Proxy Nektar::NekMatrix< DataType, StandardMatrixTag >::operator() ( unsigned int  row,
unsigned int  column,
char  transpose 
)

Definition at line 636 of file StandardMatrix.cpp.

639{
640 unsigned int index = this->CalculateIndex(row, column, transpose);
641 if (index != std::numeric_limits<unsigned int>::max())
642 {
643 return Proxy(this->GetData()[index]);
644 }
645 else
646 {
647 return Proxy();
648 }
649}

◆ operator()() [4/4]

template<typename DataType >
NekMatrix< DataType, StandardMatrixTag >::ConstGetValueType Nektar::NekMatrix< DataType, StandardMatrixTag >::operator() ( unsigned int  row,
unsigned int  column,
char  transpose 
) const

Returns the element value at the given row and column.

row The element's row.

column The element's column.

transpose If transpose = 'N', then the return value is element [row, column]. If transpose = 'T', then the return value is element [column, row].

Definition at line 207 of file StandardMatrix.cpp.

210{
211 return this->GetValue(row, column, transpose);
212}

◆ operator*=()

template<typename DataType >
NekMatrix< DataType, StandardMatrixTag > & Nektar::NekMatrix< DataType, StandardMatrixTag >::operator*= ( const NumberType s)

Definition at line 866 of file StandardMatrix.cpp.

867{
868 for (unsigned int i = 0; i < this->GetPtr().size(); ++i)
869 {
870 this->GetPtr()[i] *= s;
871 }
872 return *this;
873}
const Array< OneD, const DataType > & GetPtr() const

◆ operator-()

template<typename DataType >
NekMatrix< DataType, StandardMatrixTag > Nektar::NekMatrix< DataType, StandardMatrixTag >::operator-

Definition at line 857 of file StandardMatrix.cpp.

858{
859 NekMatrix<DataType, StandardMatrixTag> result(*this);
860 NegateInPlace(result);
861 return result;
862}
void NegateInPlace(NekVector< DataType > &v)
Definition: NekVector.cpp:1160

References Nektar::NegateInPlace().

◆ operator=() [1/3]

template<typename DataType >
NekMatrix< DataType, StandardMatrixTag > & Nektar::NekMatrix< DataType, StandardMatrixTag >::operator= ( const DataType &  rhs)

Fill matrix with scalar.

Definition at line 177 of file StandardMatrix.cpp.

178{
179 unsigned int requiredStorageSize = GetRequiredStorageSize();
180
181 DataType *lhs_array = m_data.data();
182
183 Vmath::Fill(requiredStorageSize, rhs, lhs_array, 1);
184
185 return *this;
186}
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
Definition: Vmath.hpp:54

References Vmath::Fill().

◆ operator=() [2/3]

template<typename DataType >
template<typename InnerMatrixType >
ThisType & Nektar::NekMatrix< DataType, StandardMatrixTag >::operator= ( const NekMatrix< InnerMatrixType, ScaledMatrixTag > &  rhs)
inline

Definition at line 312 of file StandardMatrix.hpp.

313 {
314 BaseType::operator=(rhs);
315 m_numberOfSubDiagonals = rhs.GetNumberOfSubDiagonals();
316 m_numberOfSuperDiagonals = rhs.GetNumberOfSuperDiagonals();
317
319
320 unsigned int requiredStorageSize = GetRequiredStorageSize();
321 DataType scale = rhs.Scale();
322
323 DataType *lhs_array = m_data.data();
324 const DataType *rhs_array = rhs.GetRawPtr();
325
326 for (unsigned int i = 0; i < requiredStorageSize; ++i)
327 {
328 lhs_array[i] = scale * rhs_array[i];
329 }
330
331 return *this;
332 }

◆ operator=() [3/3]

template<typename DataType >
NekMatrix< DataType, StandardMatrixTag > & Nektar::NekMatrix< DataType, StandardMatrixTag >::operator= ( const ThisType rhs)

Definition at line 153 of file StandardMatrix.cpp.

155{
156 if (this == &rhs)
157 {
158 return *this;
159 }
160
162 m_numberOfSubDiagonals = rhs.m_numberOfSubDiagonals;
163 m_numberOfSuperDiagonals = rhs.m_numberOfSuperDiagonals;
164
166
167 unsigned int requiredStorageSize = GetRequiredStorageSize();
168 std::copy(rhs.m_data.data(), rhs.m_data.data() + requiredStorageSize,
169 m_data.data());
170
171 return *this;
172}
Matrix< DataType > & operator=(const Matrix< DataType > &rhs)
Definition: MatrixBase.cpp:305

References CellMLToNektar.pycml::copy(), Nektar::Array< OneD, DataType >::data(), m_data, m_numberOfSubDiagonals, m_numberOfSuperDiagonals, and Nektar::Matrix< DataType >::operator=().

◆ operator==()

template<typename DataType >
bool Nektar::NekMatrix< DataType, StandardMatrixTag >::operator== ( const NekMatrix< DataType, StandardMatrixTag > &  rhs) const

Returns true if the this matrix and rhs are equivalent.

Two matrices are equivalent if they have the same size and each element is the same.

Definition at line 381 of file StandardMatrix.cpp.

383{
384 if (this->GetRows() != rhs.GetRows() ||
385 this->GetColumns() != rhs.GetColumns())
386 {
387 return false;
388 }
389
390 if (this->GetTransposeFlag() == rhs.GetTransposeFlag())
391 {
392 return std::equal(begin(), end(), rhs.begin());
393 }
394 else
395 {
396 for (unsigned int i = 0; i < this->GetRows(); ++i)
397 {
398 for (unsigned int j = 0; j < this->GetColumns(); ++j)
399 {
400 if ((*this)(i, j) != rhs(i, j))
401 {
402 return false;
403 }
404 }
405 }
406 }
407
408 return true;
409}

References begin(), Nektar::ConstMatrix< DataType >::GetColumns(), Nektar::ConstMatrix< DataType >::GetRows(), and Nektar::ConstMatrix< DataType >::GetTransposeFlag().

◆ PerformCopyConstruction()

template<typename DataType >
void Nektar::NekMatrix< DataType, StandardMatrixTag >::PerformCopyConstruction ( const ThisType rhs)
private

Definition at line 565 of file StandardMatrix.cpp.

567{
568 if (m_wrapperType == eWrapper)
569 {
570 m_data = rhs.m_data;
571 }
572 else
573 {
574 m_data = Array<OneD, DataType>(GetRequiredStorageSize());
575 CopyArrayN(rhs.m_data, m_data, m_data.size());
576 }
577}

References Nektar::CopyArrayN(), Nektar::eWrapper, m_data, and Nektar::Array< OneD, const DataType >::size().

◆ RemoveExcessCapacity()

template<typename DataType >
void Nektar::NekMatrix< DataType, StandardMatrixTag >::RemoveExcessCapacity
protected

Definition at line 515 of file StandardMatrix.cpp.

516{
517 if (m_wrapperType == eCopy)
518 {
519 unsigned int requiredStorageSize = GetRequiredStorageSize();
520 if (m_data.size() > requiredStorageSize)
521 {
522 Array<OneD, DataType> newArray(requiredStorageSize);
523 CopyArrayN(m_data, newArray, requiredStorageSize);
524 m_data = newArray;
525 }
526 }
527 else if (m_wrapperType == eWrapper)
528 {
529 ASSERTL0(true, "Can't call RemoveExcessCapacity on a wrapped matrix.");
530 }
531}

References ASSERTL0, Nektar::CopyArrayN(), Nektar::eCopy, and Nektar::eWrapper.

◆ ResizeDataArrayIfNeeded() [1/2]

template<typename DataType >
void Nektar::NekMatrix< DataType, StandardMatrixTag >::ResizeDataArrayIfNeeded
protected

Definition at line 558 of file StandardMatrix.cpp.

559{
560 unsigned int requiredStorageSize = GetRequiredStorageSize();
561 ResizeDataArrayIfNeeded(requiredStorageSize);
562}

◆ ResizeDataArrayIfNeeded() [2/2]

template<typename DataType >
void Nektar::NekMatrix< DataType, StandardMatrixTag >::ResizeDataArrayIfNeeded ( unsigned int  requiredStorageSize)
protected

Definition at line 534 of file StandardMatrix.cpp.

536{
537 if (m_wrapperType == eCopy)
538 {
539 if (m_data.size() < requiredStorageSize)
540 {
541 Array<OneD, DataType> newData(requiredStorageSize);
543 newData.data());
544 m_data = newData;
545 }
546 }
547 else if (m_wrapperType == eWrapper)
548 {
549 // If the current matrix is wrapped, then just copy over the top,
550 // but the sizes of the two matrices must be the same.
551 ASSERTL0(
552 m_data.size() >= requiredStorageSize,
553 "Wrapped NekMatrices must have the same dimension in operator=");
554 }
555}

References ASSERTL0, CellMLToNektar.pycml::copy(), Nektar::Array< OneD, DataType >::data(), Nektar::eCopy, and Nektar::eWrapper.

◆ Scale()

template<typename DataType >
DataType Nektar::NekMatrix< DataType, StandardMatrixTag >::Scale

Returns the scaling used by this matrix.

Since this matrix is not a scaled matrix, this method always returns 1.

Definition at line 277 of file StandardMatrix.cpp.

278{
279 return DataType(1);
280}

◆ SetSize()

template<typename DataType >
void Nektar::NekMatrix< DataType, StandardMatrixTag >::SetSize ( unsigned int  rows,
unsigned int  cols 
)

Definition at line 602 of file StandardMatrix.cpp.

604{
605 this->Resize(rows, cols);
606
607 // Some places in Nektar++ access the matrix data array and
608 // use size() to see how big it is. When using
609 // expression templates, the data array's capacity is often larger
610 // than the actual number of elements, so this statement is
611 // required to report the correct number of elements.
613 ASSERTL0(this->GetRequiredStorageSize() <= this->GetData().size(),
614 "Can't resize matrices if there is not enough capacity.");
615}
void Resize(unsigned int rows, unsigned int columns)
Resets the rows and columns in the array. This method does not update the data storage to match the n...
Definition: MatrixBase.cpp:249

References ASSERTL0.

Referenced by Nektar::Multiply().

◆ SetValue() [1/2]

template<typename DataType >
void Nektar::NekMatrix< DataType, StandardMatrixTag >::SetValue ( unsigned int  row,
unsigned int  column,
typename boost::call_traits< DataType >::const_reference  d 
)

Definition at line 652 of file StandardMatrix.cpp.

655{
656 ASSERTL2(row < this->GetRows(),
657 std::string("Row ") + std::to_string(row) +
658 std::string(" requested in a matrix with a maximum of ") +
659 std::to_string(this->GetRows()) + std::string(" rows"));
660 ASSERTL2(column < this->GetColumns(),
661 std::string("Column ") + std::to_string(column) +
662 std::string(" requested in a matrix with a maximum of ") +
663 std::to_string(this->GetColumns()) + std::string(" columns"));
664 SetValue(row, column, d, this->GetTransposeFlag());
665}
void SetValue(unsigned int row, unsigned int column, typename boost::call_traits< DataType >::const_reference d)

References ASSERTL2, and Nektar::UnitTests::d().

◆ SetValue() [2/2]

template<typename DataType >
void Nektar::NekMatrix< DataType, StandardMatrixTag >::SetValue ( unsigned int  row,
unsigned int  column,
typename boost::call_traits< DataType >::const_reference  d,
char  transpose 
)

Definition at line 668 of file StandardMatrix.cpp.

671{
672 unsigned int index = this->CalculateIndex(row, column, transpose);
673 if (index != std::numeric_limits<unsigned int>::max())
674 {
675 this->GetData()[index] = d;
676 }
677 else
678 {
679 NEKERROR(
681 "Can't assign values into zeroed elements of a special array.");
682 }
683}

References Nektar::UnitTests::d(), Nektar::ErrorUtil::efatal, and NEKERROR.

◆ SwapTempAndDataBuffers()

template<typename DataType >
void Nektar::NekMatrix< DataType, StandardMatrixTag >::SwapTempAndDataBuffers

Definition at line 850 of file StandardMatrix.cpp.

851{
852 std::swap(m_tempSpace, this->GetData());
853}

◆ v_GetStorageSize()

template<typename DataType >
unsigned int Nektar::NekMatrix< DataType, StandardMatrixTag >::v_GetStorageSize
overrideprotectedvirtual

◆ v_GetValue()

template<typename DataType >
boost::call_traits< DataType >::value_type Nektar::NekMatrix< DataType, StandardMatrixTag >::v_GetValue ( unsigned int  row,
unsigned int  column 
) const
overrideprotectedvirtual

Implements Nektar::ConstMatrix< DataType >.

Definition at line 581 of file StandardMatrix.cpp.

583{
585}
ConstGetValueType operator()(unsigned int row, unsigned int column) const
Returns the element value at the given row and column.

◆ v_SetValue()

template<typename DataType >
void Nektar::NekMatrix< DataType, StandardMatrixTag >::v_SetValue ( unsigned int  row,
unsigned int  column,
typename boost::call_traits< DataType >::const_reference  d 
)
overrideprotectedvirtual

Implements Nektar::Matrix< DataType >.

Definition at line 594 of file StandardMatrix.cpp.

597{
599}

References Nektar::UnitTests::d().

Member Data Documentation

◆ m_data

template<typename DataType >
Array<OneD, DataType> Nektar::NekMatrix< DataType, StandardMatrixTag >::m_data
private

Definition at line 540 of file StandardMatrix.hpp.

Referenced by operator=(), and PerformCopyConstruction().

◆ m_numberOfSubDiagonals

template<typename DataType >
unsigned int Nektar::NekMatrix< DataType, StandardMatrixTag >::m_numberOfSubDiagonals
private

Definition at line 545 of file StandardMatrix.hpp.

Referenced by operator=().

◆ m_numberOfSuperDiagonals

template<typename DataType >
unsigned int Nektar::NekMatrix< DataType, StandardMatrixTag >::m_numberOfSuperDiagonals
private

Definition at line 544 of file StandardMatrix.hpp.

Referenced by operator=().

◆ m_tempSpace

template<typename DataType >
Array<OneD, DataType> Nektar::NekMatrix< DataType, StandardMatrixTag >::m_tempSpace
private

Definition at line 548 of file StandardMatrix.hpp.

◆ m_wrapperType

template<typename DataType >
PointerWrapper Nektar::NekMatrix< DataType, StandardMatrixTag >::m_wrapperType
private

Definition at line 541 of file StandardMatrix.hpp.