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());
304 template<
typename InnerMatrixType>
307 BaseType::operator=(rhs);
308 m_numberOfSubDiagonals = rhs.GetNumberOfSubDiagonals();
309 m_numberOfSuperDiagonals = rhs.GetNumberOfSuperDiagonals();
311 ResizeDataArrayIfNeeded();
313 unsigned int requiredStorageSize = GetRequiredStorageSize();
314 DataType scale = rhs.Scale();
316 DataType* lhs_array = m_data.data();
317 const DataType* rhs_array = rhs.GetRawPtr();
319 for(
unsigned int i = 0; i < requiredStorageSize; ++i)
321 lhs_array[i] = scale*rhs_array[i];
335 Proxy() : m_value(defaultReturnValue) {}
336 explicit Proxy(DataType& value) : m_value(value) {}
340 m_value = rhs.m_value;
346 operator DataType&() {
return m_value; }
347 operator const DataType&()
const {
return m_value; }
350 if( &m_value != &defaultReturnValue )
366 LIB_UTILITIES_EXPORT ConstGetValueType operator()(
unsigned int row,
unsigned int column,
char transpose)
const;
370 LIB_UTILITIES_EXPORT unsigned int CalculateIndex(
unsigned int row,
unsigned int col,
const char transpose)
const;
373 LIB_UTILITIES_EXPORT typename boost::call_traits<DataType>::const_reference GetValue(
unsigned int row,
unsigned int column)
const;
380 LIB_UTILITIES_EXPORT ConstGetValueType GetValue(
unsigned int row,
unsigned int column,
char transpose)
const;
392 typedef iterator_impl<DataType, ThisType>
iterator;
430 Advance(
unsigned int curRow,
unsigned int curColumn)
const;
433 Advance(
unsigned int curRow,
unsigned int curColumn,
char transpose)
const;
446 LIB_UTILITIES_EXPORT void SetValue(
unsigned int row,
unsigned int column,
typename boost::call_traits<DataType>::const_reference d);
448 LIB_UTILITIES_EXPORT void SetValue(
unsigned int row,
unsigned int column,
typename boost::call_traits<DataType>::const_reference d,
char transpose);
487 LIB_UTILITIES_EXPORT virtual typename boost::call_traits<DataType>::value_type v_GetValue(
unsigned int row,
unsigned int column)
const;
492 LIB_UTILITIES_EXPORT virtual void v_SetValue(
unsigned int row,
unsigned int column,
typename boost::call_traits<DataType>::const_reference d);
506 template<
typename DataType>
509 template<
typename DataType>
513 template<
typename DataType>
517 #endif //NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_STANDARD_MATRIX_HPP
iterator_impl(pointer d, pointer e, bool isEnd=false)
iterator_impl< const DataType, const ThisType > const_iterator
unsigned int difference_type
static Array< OneD, NekDouble > NullNekDouble1DArray
TagType< T >::type iterator_category
bool operator!=(const iterator_impl< T, MatrixType > &rhs)
unsigned int m_numberOfSubDiagonals
Matrix< DataType > BaseType
bool operator==(const Array< OneD, NekDouble > &lhs, const Array< OneD, NekDouble > &rhs)
const_reference operator*() const
std::input_iterator_tag type
PointerWrapper m_wrapperType
Array< OneD, DataType > m_data
boost::call_traits< value_type >::const_reference const_reference
static DataType defaultReturnValue
boost::call_traits< value_type >::reference reference
NekMatrix< DataType, StandardMatrixTag > ThisType
ThisType & operator=(const NekMatrix< InnerMatrixType, ScaledMatrixTag > &rhs)
const DataType & operator*() const
iterator_impl< T, MatrixType > operator++(int)
increment operator.
#define LIB_UTILITIES_EXPORT
NekMatrix< InnerMatrixType, BlockMatrixTag > Transpose(NekMatrix< InnerMatrixType, BlockMatrixTag > &rhs)
void operator=(const DataType &newValue)
unsigned int m_numberOfSuperDiagonals
std::forward_iterator_tag type
PointerWrapper
Specifies if the pointer passed to a NekMatrix or NekVector is copied into an internal representation...
const DataType & ConstGetValueType
iterator_impl(MatrixType *m, char transpose, bool isEnd=false)
NekMatrix< typename NekMatrix< LhsDataType, LhsMatrixType >::NumberType, StandardMatrixTag > operator-(const NekMatrix< LhsDataType, LhsMatrixType > &lhs, const NekMatrix< RhsDataType, RhsMatrixType > &rhs)
Array< OneD, DataType > m_tempSpace
iterator_impl< DataType, ThisType > iterator
std::remove_reference< value_type >::type * pointer
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs
iterator_impl< T, MatrixType > & operator++()
Prefix increment operator.
1D Array of constant elements with garbage collection and bounds checking.
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
void NegateInPlace(NekVector< DataType > &v)
iterator_impl(const iterator_impl< T, MatrixType > &rhs)
iterator_impl< T, MatrixType > & operator=(const iterator_impl< T, MatrixType > &rhs)
Proxy & operator=(const Proxy &rhs)
bool operator==(const iterator_impl< T, MatrixType > &rhs)