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 ()
 
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, eVECTOR_WRAPPER);
134 }
135 else
136 {
137 m_data = Array<OneD, DataType>(GetRequiredStorageSize());
139 }
140}
@ eVECTOR_WRAPPER

References Nektar::CopyArrayN(), Nektar::UnitTests::d(), Nektar::eVECTOR_WRAPPER, 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 499 of file StandardMatrix.cpp.

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

Member Function Documentation

◆ AbsMaxtoMinEigenValueRatio()

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

Definition at line 743 of file StandardMatrix.cpp.

745{
746 DataType returnval;
747 int nvals = this->GetColumns();
748 Array<OneD, DataType> EigValReal(nvals);
749 Array<OneD, DataType> EigValImag(nvals);
750 Array<OneD, DataType> Evecs;
751
752 EigenSolve(EigValReal, EigValImag, Evecs);
753
754 Vmath::Vmul(nvals, EigValReal, 1, EigValReal, 1, EigValReal, 1);
755 Vmath::Vmul(nvals, EigValImag, 1, EigValImag, 1, EigValImag, 1);
756 Vmath::Vadd(nvals, EigValReal, 1, EigValImag, 1, EigValReal, 1);
757
758 returnval = sqrt(Vmath::Vmax(nvals, EigValReal, 1) /
759 Vmath::Vmin(nvals, EigValReal, 1));
760
761 return returnval;
762}
unsigned int GetColumns() const
Definition: MatrixBase.cpp:84
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:294

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 420 of file StandardMatrix.cpp.

422{
423 return Advance(curRow, curColumn, this->GetTransposeFlag());
424}
char GetTransposeFlag() const
Definition: MatrixBase.cpp:122
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 428 of file StandardMatrix.cpp.

431{
432 unsigned int numRows = this->GetTransposedRows(transpose);
433 unsigned int numColumns = this->GetTransposedColumns(transpose);
434
435 switch (this->GetStorageType())
436 {
437 case eFULL:
438 return FullMatrixFuncs::Advance(numRows, numColumns, curRow,
439 curColumn);
440 break;
441 case eDIAGONAL:
442 return DiagonalMatrixFuncs::Advance(numRows, numColumns, curRow,
443 curColumn);
444 break;
446 return UpperTriangularMatrixFuncs::Advance(numRows, numColumns,
447 curRow, curColumn);
448 break;
449
451 return LowerTriangularMatrixFuncs::Advance(numRows, numColumns,
452 curRow, curColumn);
453 break;
454
455 case eSYMMETRIC:
457 return SymmetricMatrixFuncs::Advance(numRows, numColumns, curRow,
458 curColumn);
459 break;
460 case eBANDED:
461 return BandedMatrixFuncs::Advance(numRows, numColumns, curRow,
462 curColumn);
463 break;
466 NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
467 break;
469 NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
470 break;
472 NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
473 break;
474
475 default:
476 NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
477 }
478 return std::tuple<unsigned int, unsigned int>(curRow, curColumn);
479}
#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:90
unsigned int GetTransposedRows(char transpose) const
Definition: MatrixBase.cpp:71
@ 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 700 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 291 of file StandardMatrix.cpp.

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

◆ begin() [3/4]

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

Definition at line 707 of file StandardMatrix.cpp.

708{
709 if (transpose == 'N')
710 {
711 return iterator(this->GetData().data(),
712 this->GetData().data() + this->GetData().size());
713 }
714 else
715 {
716 return iterator(this, transpose);
717 }
718}
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 298 of file StandardMatrix.cpp.

299{
300 if (transpose == 'N')
301 {
303 }
304 else
305 {
306 return const_iterator(this, transpose);
307 }
308}
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 225 of file StandardMatrix.cpp.

227{
228 unsigned int numRows = this->GetSize()[0];
229 unsigned int numColumns = this->GetSize()[1];
231 this->GetStorageType(), row, col, numRows, numColumns, transpose,
233}
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:128
const unsigned int * GetSize() const
Definition: MatrixBase.cpp:103

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

◆ CalculateNumberOfRows()

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

Definition at line 375 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 490 of file StandardMatrix.cpp.

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

References Nektar::eWrapper.

◆ CreateWrapper() [2/2]

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

Definition at line 482 of file StandardMatrix.cpp.

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

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 765 of file StandardMatrix.cpp.

768{
769 ASSERTL0(this->GetRows() == this->GetColumns(),
770 "Only square matrices can be called");
771
772 switch (this->GetType())
773 {
774 case eFULL:
776 EigValReal, EigValImag, EigVecs);
777 break;
778 case eDIAGONAL:
779 Vmath::Vcopy(this->GetRows(), &(this->GetData())[0], 1,
780 &EigValReal[0], 1);
781 Vmath::Zero(this->GetRows(), &EigValImag[0], 1);
782 break;
785 case eSYMMETRIC:
786 case eBANDED:
790 NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
791 break;
792
793 default:
794 NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
795 }
796}
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:208
MatrixStorage GetType() const
Definition: MatrixBase.hpp:64
unsigned int GetRows() const
Definition: MatrixBase.cpp:65
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:159

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 722 of file StandardMatrix.cpp.

◆ end() [2/4]

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

Definition at line 312 of file StandardMatrix.cpp.

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

◆ end() [3/4]

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

Definition at line 729 of file StandardMatrix.cpp.

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

◆ end() [4/4]

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

Definition at line 319 of file StandardMatrix.cpp.

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

◆ GetData()

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

Definition at line 510 of file StandardMatrix.cpp.

511{
512 return m_data;
513}

◆ GetNumberOfSubDiagonals()

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

Definition at line 339 of file StandardMatrix.cpp.

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

Referenced by Nektar::Transpose().

◆ GetNumberOfSuperDiagonals()

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

Definition at line 357 of file StandardMatrix.cpp.

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

Referenced by Nektar::Transpose().

◆ GetPtr() [1/2]

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

Definition at line 687 of file StandardMatrix.cpp.

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

◆ GetPtr() [2/2]

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

Definition at line 272 of file StandardMatrix.cpp.

273{
274 return m_data;
275}

Referenced by Nektar::Transpose().

◆ GetRawPtr() [1/2]

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

Definition at line 693 of file StandardMatrix.cpp.

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

◆ GetRawPtr() [2/2]

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

Definition at line 284 of file StandardMatrix.cpp.

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

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

◆ GetRequiredStorageSize()

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

Definition at line 216 of file StandardMatrix.cpp.

218{
220 this->GetStorageType(), this->GetRows(), this->GetColumns(),
222}
static unsigned int GetRequiredStorageSize(MatrixStorage type, unsigned int rows, unsigned int columns, unsigned int subDiags=0, unsigned int superDiags=0)
Definition: MatrixBase.cpp:186

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

◆ GetStorageSize()

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

Definition at line 333 of file StandardMatrix.cpp.

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

◆ GetTempSpace()

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

Definition at line 841 of file StandardMatrix.cpp.

842{
843 if (m_tempSpace.capacity() == 0)
844 {
845 m_tempSpace = Array<OneD, DataType>(this->GetData().capacity());
846 }
847 return m_tempSpace;
848}
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 237 of file StandardMatrix.cpp.

239{
240 ASSERTL2(row < this->GetRows(),
241 std::string("Row ") + std::to_string(row) +
242 std::string(" requested in a matrix with a maximum of ") +
243 std::to_string(this->GetRows()) + std::string(" rows"));
244 ASSERTL2(column < this->GetColumns(),
245 std::string("Column ") + std::to_string(column) +
246 std::string(" requested in a matrix with a maximum of ") +
247 std::to_string(this->GetColumns()) + std::string(" columns"));
248
249 return GetValue(row, column, this->GetTransposeFlag());
250}
#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 254 of file StandardMatrix.cpp.

257{
258 static DataType defaultReturnValue;
259 unsigned int index = CalculateIndex(row, column, transpose);
260 if (index != std::numeric_limits<unsigned int>::max())
261 {
262 return m_data[index];
263 }
264 else
265 {
266 return defaultReturnValue;
267 }
268}
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 413 of file StandardMatrix.cpp.

414{
415 return m_wrapperType;
416}

◆ Invert()

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

Definition at line 799 of file StandardMatrix.cpp.

800{
801 ASSERTL0(this->GetRows() == this->GetColumns(),
802 "Only square matrices can be inverted.");
803 ASSERTL0(this->GetTransposeFlag() == 'N',
804 "Only untransposed matrices may be inverted.");
805
806 switch (this->GetType())
807 {
808 case eFULL:
810 this->GetData(), this->GetTransposeFlag());
811 break;
812 case eDIAGONAL:
814 this->GetData());
815 break;
816 case eSYMMETRIC:
818 this->GetData());
819 break;
822 case eBANDED:
823 NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
824 break;
826 NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
827 break;
829 NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
830 break;
832 NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
833 break;
834
835 default:
836 NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
837 }
838}
static void Invert(unsigned int rows, unsigned int columns, Array< OneD, DataType > &data)
Definition: MatrixFuncs.h:285
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:230

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 620 of file StandardMatrix.cpp.

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

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 191 of file StandardMatrix.cpp.

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

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 637 of file StandardMatrix.cpp.

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

◆ 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 208 of file StandardMatrix.cpp.

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

◆ operator*=()

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

Definition at line 867 of file StandardMatrix.cpp.

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

◆ operator-()

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

Definition at line 858 of file StandardMatrix.cpp.

859{
860 NekMatrix<DataType, StandardMatrixTag> result(*this);
861 NegateInPlace(result);
862 return result;
863}
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 178 of file StandardMatrix.cpp.

179{
180 unsigned int requiredStorageSize = GetRequiredStorageSize();
181
182 DataType *lhs_array = m_data.data();
183
184 Vmath::Fill(requiredStorageSize, rhs, lhs_array, 1);
185
186 return *this;
187}
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 154 of file StandardMatrix.cpp.

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

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 382 of file StandardMatrix.cpp.

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

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 566 of file StandardMatrix.cpp.

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

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 516 of file StandardMatrix.cpp.

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

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 559 of file StandardMatrix.cpp.

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

◆ ResizeDataArrayIfNeeded() [2/2]

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

Definition at line 535 of file StandardMatrix.cpp.

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

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 278 of file StandardMatrix.cpp.

279{
280 return DataType(1);
281}

◆ SetSize()

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

Definition at line 603 of file StandardMatrix.cpp.

605{
606 this->Resize(rows, cols);
607
608 // Some places in Nektar++ access the matrix data array and
609 // use size() to see how big it is. When using
610 // expression templates, the data array's capacity is often larger
611 // than the actual number of elements, so this statement is
612 // required to report the correct number of elements.
614 ASSERTL0(this->GetRequiredStorageSize() <= this->GetData().size(),
615 "Can't resize matrices if there is not enough capacity.");
616}
void ChangeSize(size_type newSize)
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:267

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 653 of file StandardMatrix.cpp.

656{
657 ASSERTL2(row < this->GetRows(),
658 std::string("Row ") + std::to_string(row) +
659 std::string(" requested in a matrix with a maximum of ") +
660 std::to_string(this->GetRows()) + std::string(" rows"));
661 ASSERTL2(column < this->GetColumns(),
662 std::string("Column ") + std::to_string(column) +
663 std::string(" requested in a matrix with a maximum of ") +
664 std::to_string(this->GetColumns()) + std::string(" columns"));
665 SetValue(row, column, d, this->GetTransposeFlag());
666}
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 669 of file StandardMatrix.cpp.

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

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

◆ SwapTempAndDataBuffers()

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

Definition at line 851 of file StandardMatrix.cpp.

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

◆ 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 582 of file StandardMatrix.cpp.

584{
586}
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 595 of file StandardMatrix.cpp.

598{
600}

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.