35#ifndef NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_STANDARD_MATRIX_HPP
36#define NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_STANDARD_MATRIX_HPP
54template <
typename DataType>
65 template <
typename T,
typename MatrixType>
class iterator_impl
70 template <
typename Z>
struct TagType
72 typedef std::forward_iterator_tag
type;
75 template <
typename Z>
struct TagType<const Z>
77 typedef std::input_iterator_tag
type;
82 typedef typename boost::call_traits<value_type>::reference
reference;
83 typedef typename boost::call_traits<value_type>::const_reference
85 typedef typename std::remove_reference<value_type>::type *
pointer;
89 : m_data(
d), m_end(e),
90 m_curRow(
std::numeric_limits<unsigned int>::max()),
91 m_curColumn(
std::numeric_limits<unsigned int>::max()),
93 m_curIndex(
std::numeric_limits<unsigned int>::max()),
103 : m_data(nullptr), m_end(nullptr), m_curRow(0), m_curColumn(0),
104 m_matrix(m), m_curIndex(0), m_transpose(transpose)
108 m_curRow = std::numeric_limits<unsigned int>::max();
109 m_curColumn = std::numeric_limits<unsigned int>::max();
110 m_curIndex = std::numeric_limits<unsigned int>::max();
115 : m_data(rhs.m_data), m_end(rhs.m_end), m_curRow(rhs.m_curRow),
116 m_curColumn(rhs.m_curColumn), m_matrix(rhs.m_matrix),
117 m_curIndex(rhs.m_curIndex), m_transpose(rhs.m_transpose)
122 const iterator_impl<T, MatrixType> &rhs)
126 m_curRow = rhs.m_curRow;
127 m_curColumn = rhs.m_curColumn;
128 m_matrix = rhs.m_matrix;
129 m_curIndex = rhs.m_curIndex;
130 m_transpose = rhs.m_transpose;
140 "Attempt to dereference matrix iterator after its end.");
145 return m_matrix->GetPtr()[m_curIndex];
155 "Attempt to dereference matrix iterator after its end.");
160 return m_matrix->GetPtr()[m_curIndex];
173 std::tie(m_curRow, m_curColumn) =
174 m_matrix->Advance(m_curRow, m_curColumn, m_transpose);
175 if (m_curRow == std::numeric_limits<unsigned int>::max())
177 m_curIndex = m_curRow;
181 m_curIndex = m_matrix->CalculateIndex(m_curRow, m_curColumn,
191 iterator_impl<T, MatrixType> result = *
this;
198 return m_data == rhs.m_data && m_end == rhs.m_end &&
199 m_curRow == rhs.m_curRow && m_curColumn == rhs.m_curColumn &&
200 m_matrix == rhs.m_matrix && m_curIndex == rhs.m_curIndex &&
201 m_transpose == rhs.m_transpose;
206 return !(*
this == rhs);
231 unsigned int subDiagonals = std::numeric_limits<unsigned int>::max(),
232 unsigned int superDiagonals = std::numeric_limits<unsigned int>::max());
236 unsigned int subDiagonals,
237 unsigned int superDiagonals,
238 unsigned int capacity);
250 unsigned int rows,
unsigned int columns,
251 typename boost::call_traits<DataType>::const_reference initValue,
253 unsigned int subDiagonals = std::numeric_limits<unsigned int>::max(),
254 unsigned int superDiagonals = std::numeric_limits<unsigned int>::max());
266 unsigned int rows,
unsigned int columns,
const DataType *data,
268 unsigned int subDiagonals = std::numeric_limits<unsigned int>::max(),
269 unsigned int superDiagonals = std::numeric_limits<unsigned int>::max());
281 unsigned int rows,
unsigned int columns,
283 unsigned int subDiagonals = std::numeric_limits<unsigned int>::max(),
284 unsigned int superDiagonals = std::numeric_limits<unsigned int>::max());
302 unsigned int subDiagonals = std::numeric_limits<unsigned int>::max(),
303 unsigned int superDiagonals = std::numeric_limits<unsigned int>::max());
311 template <
typename InnerMatrixType>
314 BaseType::operator=(rhs);
315 m_numberOfSubDiagonals = rhs.GetNumberOfSubDiagonals();
316 m_numberOfSuperDiagonals = rhs.GetNumberOfSuperDiagonals();
318 ResizeDataArrayIfNeeded();
320 unsigned int requiredStorageSize = GetRequiredStorageSize();
321 DataType scale = rhs.Scale();
323 DataType *lhs_array = m_data.data();
324 const DataType *rhs_array = rhs.GetRawPtr();
326 for (
unsigned int i = 0; i < requiredStorageSize; ++i)
328 lhs_array[i] = scale * rhs_array[i];
336 operator()(
unsigned int row,
unsigned int column)
const;
341 Proxy() : m_value(defaultReturnValue)
344 explicit Proxy(DataType &value) : m_value(value)
347 Proxy(
const Proxy &rhs) : m_value(rhs.m_value)
352 m_value = rhs.m_value;
364 operator DataType &()
368 operator const DataType &()
const
374 if (&m_value != &defaultReturnValue)
394 char transpose)
const;
399 unsigned int row,
unsigned int col,
const char transpose)
const;
403 GetValue(
unsigned int row,
unsigned int column)
const;
414 char transpose)
const;
426 typedef iterator_impl<DataType, ThisType>
iterator;
464 unsigned int curRow,
unsigned int curColumn)
const;
467 unsigned int curRow,
unsigned int curColumn,
char transpose)
const;
472 const std::shared_ptr<ThisType> &rhs);
477 unsigned int column);
483 unsigned int row,
unsigned int column,
484 typename boost::call_traits<DataType>::const_reference
d);
487 unsigned int row,
unsigned int column,
488 typename boost::call_traits<DataType>::const_reference
d,
521 unsigned int requiredStorageSize);
526 typename boost::call_traits<DataType>::value_type v_GetValue(
527 unsigned int row,
unsigned int column)
const override;
534 unsigned int row,
unsigned int column,
535 typename boost::call_traits<DataType>::const_reference
d)
override;
551template <
typename DataType>
554template <
typename DataType>
558template <
typename DataType>
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
#define LIB_UTILITIES_EXPORT
1D Array of constant elements with garbage collection and bounds checking.
void operator=(const DataType &newValue)
const DataType & operator*() const
static DataType defaultReturnValue
Proxy & operator=(const Proxy &rhs)
boost::call_traits< value_type >::const_reference const_reference
iterator_impl(pointer d, pointer e, bool isEnd=false)
TagType< T >::type iterator_category
iterator_impl< T, MatrixType > operator++(int)
\postfix increment operator.
bool operator!=(const iterator_impl< T, MatrixType > &rhs)
const_reference operator*() const
std::remove_reference< value_type >::type * pointer
iterator_impl< T, MatrixType > & operator=(const iterator_impl< T, MatrixType > &rhs)
iterator_impl< T, MatrixType > & operator++()
Prefix increment operator.
boost::call_traits< value_type >::reference reference
unsigned int difference_type
bool operator==(const iterator_impl< T, MatrixType > &rhs)
iterator_impl(MatrixType *m, char transpose, bool isEnd=false)
iterator_impl(const iterator_impl< T, MatrixType > &rhs)
unsigned int m_numberOfSuperDiagonals
NekMatrix< DataType, StandardMatrixTag > ThisType
ThisType & operator=(const NekMatrix< InnerMatrixType, ScaledMatrixTag > &rhs)
iterator_impl< const DataType, const ThisType > const_iterator
iterator_impl< DataType, ThisType > iterator
Array< OneD, DataType > m_tempSpace
unsigned int m_numberOfSubDiagonals
PointerWrapper m_wrapperType
Array< OneD, DataType > m_data
Matrix< DataType > BaseType
const DataType & ConstGetValueType
std::vector< double > d(NPUPPER *NPUPPER)
bool operator==(const Array< OneD, T1 > &lhs, const Array< OneD, T2 > &rhs)
NekMatrix< typename NekMatrix< LhsDataType, LhsMatrixType >::NumberType, StandardMatrixTag > operator-(const NekMatrix< LhsDataType, LhsMatrixType > &lhs, const NekMatrix< RhsDataType, RhsMatrixType > &rhs)
void NegateInPlace(NekVector< DataType > &v)
NekMatrix< InnerMatrixType, BlockMatrixTag > Transpose(NekMatrix< InnerMatrixType, BlockMatrixTag > &rhs)
PointerWrapper
Specifies if the pointer passed to a NekMatrix or NekVector is copied into an internal representation...
std::input_iterator_tag type
std::forward_iterator_tag type