35 #ifndef NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_STANDARD_MATRIX_HPP
36 #define NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_STANDARD_MATRIX_HPP
55 template<
typename DataType>
67 template<
typename T,
typename MatrixType>
76 typedef std::forward_iterator_tag
type;
80 struct TagType<const Z>
82 typedef std::input_iterator_tag
type;
87 typedef typename boost::call_traits<value_type>::reference
reference;
89 typedef typename std::remove_reference<value_type>::type*
pointer;
95 m_curRow(std::numeric_limits<unsigned int>::max()),
96 m_curColumn(std::numeric_limits<unsigned int>::max()),
98 m_curIndex(std::numeric_limits<unsigned int>::max()),
114 m_transpose(transpose)
118 m_curRow = std::numeric_limits<unsigned int>::max();
119 m_curColumn = std::numeric_limits<unsigned int>::max();
120 m_curIndex = std::numeric_limits<unsigned int>::max();
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)
135 iterator_impl<T, MatrixType>&
operator=(
const iterator_impl<T, MatrixType>& rhs)
139 m_curRow = rhs.m_curRow;
140 m_curColumn = rhs.m_curColumn;
141 m_matrix = rhs.m_matrix;
142 m_curIndex = rhs.m_curIndex;
143 m_transpose = rhs.m_transpose;
151 ASSERTL1(m_data < m_end,
"Attempt to dereference matrix iterator after its end.");
156 return m_matrix->GetPtr()[m_curIndex];
164 ASSERTL1(m_data < m_end,
"Attempt to dereference matrix iterator after its end.");
169 return m_matrix->GetPtr()[m_curIndex];
182 std::tie(m_curRow, m_curColumn) =
183 m_matrix->Advance(m_curRow, m_curColumn, m_transpose);
184 if( m_curRow == std::numeric_limits<unsigned int>::max() )
186 m_curIndex = m_curRow;
190 m_curIndex = m_matrix->CalculateIndex(m_curRow, m_curColumn, m_transpose);
199 iterator_impl<T, MatrixType> result = *
this;
206 return m_data == rhs.m_data &&
207 m_end == rhs.m_end &&
208 m_curRow == rhs.m_curRow &&
209 m_curColumn == rhs.m_curColumn &&
210 m_matrix == rhs.m_matrix &&
211 m_curIndex == rhs.m_curIndex &&
212 m_transpose == rhs.m_transpose;
217 return !(*
this == rhs);
241 unsigned int subDiagonals = std::numeric_limits<unsigned int>::max(),
242 unsigned int superDiagonals = std::numeric_limits<unsigned int>::max());
246 unsigned int subDiagonals,
247 unsigned int superDiagonals,
248 unsigned int capacity);
259 unsigned int subDiagonals = std::numeric_limits<unsigned int>::max(),
260 unsigned int superDiagonals = std::numeric_limits<unsigned int>::max());
271 unsigned int subDiagonals = std::numeric_limits<unsigned int>::max(),
272 unsigned int superDiagonals = std::numeric_limits<unsigned int>::max());
283 unsigned int subDiagonals = std::numeric_limits<unsigned int>::max(),
284 unsigned int superDiagonals = std::numeric_limits<unsigned int>::max());
297 unsigned int subDiagonals = std::numeric_limits<unsigned int>::max(),
298 unsigned int superDiagonals = std::numeric_limits<unsigned int>::max());
306 template<
typename InnerMatrixType>
309 BaseType::operator=(rhs);
310 m_numberOfSubDiagonals = rhs.GetNumberOfSubDiagonals();
311 m_numberOfSuperDiagonals = rhs.GetNumberOfSuperDiagonals();
313 ResizeDataArrayIfNeeded();
315 unsigned int requiredStorageSize = GetRequiredStorageSize();
316 DataType scale = rhs.Scale();
318 DataType* lhs_array = m_data.data();
319 const DataType* rhs_array = rhs.GetRawPtr();
321 for(
unsigned int i = 0; i < requiredStorageSize; ++i)
323 lhs_array[i] = scale*rhs_array[i];
337 Proxy() : m_value(defaultReturnValue) {}
338 explicit Proxy(DataType& value) : m_value(value) {}
339 Proxy(
const Proxy& rhs) : m_value(rhs.m_value) {}
342 m_value = rhs.m_value;
348 operator DataType&() {
return m_value; }
349 operator const DataType&()
const {
return m_value; }
352 if( &m_value != &defaultReturnValue )
372 LIB_UTILITIES_EXPORT unsigned int CalculateIndex(
unsigned int row,
unsigned int col,
const char transpose)
const;
375 LIB_UTILITIES_EXPORT typename boost::call_traits<DataType>::const_reference GetValue(
unsigned int row,
unsigned int column)
const;
394 typedef iterator_impl<DataType, ThisType>
iterator;
432 Advance(
unsigned int curRow,
unsigned int curColumn)
const;
435 Advance(
unsigned int curRow,
unsigned int curColumn,
char transpose)
const;
439 LIB_UTILITIES_EXPORT static std::shared_ptr<ThisType> CreateWrapper(
const std::shared_ptr<ThisType>& rhs);
448 LIB_UTILITIES_EXPORT void SetValue(
unsigned int row,
unsigned int column,
typename boost::call_traits<DataType>::const_reference d);
450 LIB_UTILITIES_EXPORT void SetValue(
unsigned int row,
unsigned int column,
typename boost::call_traits<DataType>::const_reference d,
char transpose);
489 LIB_UTILITIES_EXPORT virtual typename boost::call_traits<DataType>::value_type v_GetValue(
unsigned int row,
unsigned int column)
const;
494 LIB_UTILITIES_EXPORT virtual void v_SetValue(
unsigned int row,
unsigned int column,
typename boost::call_traits<DataType>::const_reference d);
508 template<
typename DataType>
511 template<
typename DataType>
515 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
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