35 #ifndef NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_STANDARD_MATRIX_HPP
36 #define NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_STANDARD_MATRIX_HPP
55 template <
typename DataType>
66 template <
typename T,
typename MatrixType>
class iterator_impl
71 template <
typename Z>
struct TagType
73 typedef std::forward_iterator_tag
type;
76 template <
typename Z>
struct TagType<const Z>
78 typedef std::input_iterator_tag
type;
83 typedef typename boost::call_traits<value_type>::reference
reference;
84 typedef typename boost::call_traits<value_type>::const_reference
86 typedef typename std::remove_reference<value_type>::type *
pointer;
90 : m_data(d), m_end(e),
91 m_curRow(std::numeric_limits<unsigned int>::max()),
92 m_curColumn(std::numeric_limits<unsigned int>::max()),
94 m_curIndex(std::numeric_limits<unsigned int>::max()),
104 : m_data(NULL), m_end(NULL), m_curRow(0), m_curColumn(0),
105 m_matrix(m), m_curIndex(0), m_transpose(transpose)
109 m_curRow = std::numeric_limits<unsigned int>::max();
110 m_curColumn = std::numeric_limits<unsigned int>::max();
111 m_curIndex = std::numeric_limits<unsigned int>::max();
116 : m_data(rhs.m_data), m_end(rhs.m_end), m_curRow(rhs.m_curRow),
117 m_curColumn(rhs.m_curColumn), m_matrix(rhs.m_matrix),
118 m_curIndex(rhs.m_curIndex), m_transpose(rhs.m_transpose)
123 const iterator_impl<T, MatrixType> &rhs)
127 m_curRow = rhs.m_curRow;
128 m_curColumn = rhs.m_curColumn;
129 m_matrix = rhs.m_matrix;
130 m_curIndex = rhs.m_curIndex;
131 m_transpose = rhs.m_transpose;
141 "Attempt to dereference matrix iterator after its end.");
146 return m_matrix->GetPtr()[m_curIndex];
156 "Attempt to dereference matrix iterator after its end.");
161 return m_matrix->GetPtr()[m_curIndex];
174 std::tie(m_curRow, m_curColumn) =
175 m_matrix->Advance(m_curRow, m_curColumn, m_transpose);
176 if (m_curRow == std::numeric_limits<unsigned int>::max())
178 m_curIndex = m_curRow;
182 m_curIndex = m_matrix->CalculateIndex(m_curRow, m_curColumn,
192 iterator_impl<T, MatrixType> result = *
this;
199 return m_data == rhs.m_data && m_end == rhs.m_end &&
200 m_curRow == rhs.m_curRow && m_curColumn == rhs.m_curColumn &&
201 m_matrix == rhs.m_matrix && m_curIndex == rhs.m_curIndex &&
202 m_transpose == rhs.m_transpose;
207 return !(*
this == rhs);
232 unsigned int subDiagonals = std::numeric_limits<unsigned int>::max(),
233 unsigned int superDiagonals = std::numeric_limits<unsigned int>::max());
237 unsigned int subDiagonals,
238 unsigned int superDiagonals,
239 unsigned int capacity);
251 unsigned int rows,
unsigned int columns,
252 typename boost::call_traits<DataType>::const_reference initValue,
254 unsigned int subDiagonals = std::numeric_limits<unsigned int>::max(),
255 unsigned int superDiagonals = std::numeric_limits<unsigned int>::max());
267 unsigned int rows,
unsigned int columns,
const DataType *data,
269 unsigned int subDiagonals = std::numeric_limits<unsigned int>::max(),
270 unsigned int superDiagonals = std::numeric_limits<unsigned int>::max());
282 unsigned int rows,
unsigned int columns,
284 unsigned int subDiagonals = std::numeric_limits<unsigned int>::max(),
285 unsigned int superDiagonals = std::numeric_limits<unsigned int>::max());
303 unsigned int subDiagonals = std::numeric_limits<unsigned int>::max(),
304 unsigned int superDiagonals = std::numeric_limits<unsigned int>::max());
312 template <
typename InnerMatrixType>
315 BaseType::operator =(rhs);
316 m_numberOfSubDiagonals = rhs.GetNumberOfSubDiagonals();
317 m_numberOfSuperDiagonals = rhs.GetNumberOfSuperDiagonals();
319 ResizeDataArrayIfNeeded();
321 unsigned int requiredStorageSize = GetRequiredStorageSize();
322 DataType scale = rhs.Scale();
324 DataType *lhs_array = m_data.data();
325 const DataType *rhs_array = rhs.GetRawPtr();
327 for (
unsigned int i = 0; i < requiredStorageSize; ++i)
329 lhs_array[i] = scale * rhs_array[i];
337 operator()(
unsigned int row,
unsigned int column)
const;
342 Proxy() : m_value(defaultReturnValue)
345 explicit Proxy(DataType &value) : m_value(value)
348 Proxy(
const Proxy &rhs) : m_value(rhs.m_value)
353 m_value = rhs.m_value;
365 operator DataType &()
369 operator const DataType &()
const
375 if (&m_value != &defaultReturnValue)
395 char transpose)
const;
400 unsigned int row,
unsigned int col,
const char transpose)
const;
404 GetValue(
unsigned int row,
unsigned int column)
const;
415 char transpose)
const;
427 typedef iterator_impl<DataType, ThisType>
iterator;
465 unsigned int curRow,
unsigned int curColumn)
const;
468 unsigned int curRow,
unsigned int curColumn,
char transpose)
const;
473 const std::shared_ptr<ThisType> &rhs);
478 unsigned int column);
484 unsigned int row,
unsigned int column,
485 typename boost::call_traits<DataType>::const_reference d);
488 unsigned int row,
unsigned int column,
489 typename boost::call_traits<DataType>::const_reference d,
522 unsigned int requiredStorageSize);
527 typename boost::call_traits<DataType>::value_type
528 v_GetValue(
unsigned int row,
unsigned int column)
const override;
535 unsigned int row,
unsigned int column,
536 typename boost::call_traits<DataType>::const_reference d)
override;
552 template <
typename DataType>
555 template <
typename DataType>
559 template <
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)
Proxy & operator=(const Proxy &rhs)
const DataType & operator*() const
static DataType defaultReturnValue
boost::call_traits< value_type >::const_reference const_reference
iterator_impl(pointer d, pointer e, bool isEnd=false)
TagType< T >::type iterator_category
bool operator!=(const iterator_impl< T, MatrixType > &rhs)
const_reference operator*() const
std::remove_reference< value_type >::type * pointer
boost::call_traits< value_type >::reference reference
iterator_impl< T, MatrixType > operator++(int)
\postfix increment operator.
iterator_impl< T, MatrixType > & operator++()
Prefix increment operator.
iterator_impl< T, MatrixType > & operator=(const iterator_impl< T, MatrixType > &rhs)
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
static std::shared_ptr< ThisType > CreateWrapper(const std::shared_ptr< ThisType > &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
ThisType & operator=(const NekMatrix< InnerMatrixType, ScaledMatrixTag > &rhs)
Array< OneD, DataType > m_data
Matrix< DataType > BaseType
const DataType & ConstGetValueType
The above copyright notice and this permission notice shall be included.
bool operator==(const Array< OneD, T1 > &lhs, const Array< OneD, T2 > &rhs)
NekMatrix< InnerMatrixType, BlockMatrixTag > Transpose(NekMatrix< InnerMatrixType, BlockMatrixTag > &rhs)
void NegateInPlace(NekVector< DataType > &v)
NekMatrix< typename NekMatrix< LhsDataType, LhsMatrixType >::NumberType, StandardMatrixTag > operator-(const NekMatrix< LhsDataType, LhsMatrixType > &lhs, const NekMatrix< RhsDataType, RhsMatrixType > &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