Nektar++
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
Nektar::StorageSmvBsr< T >::const_iterator Class Reference

#include <StorageSmvBsr.hpp>

Classes

struct  IterType
 

Public Member Functions

 const_iterator (MatrixStorage matType, IndexType begin, IndexType end, IndexType blkDim, const DataVectorType &val, const IndexVectorType &indx, const IndexVectorType &pntr)
 
 const_iterator (const const_iterator &src)
 
 ~const_iterator ()
 
const_iterator operator++ (int)
 
const_iteratoroperator++ ()
 
const IterTypeoperator* ()
 
const IterTypeoperator-> ()
 
bool operator== (const const_iterator &rhs)
 
bool operator!= (const const_iterator &rhs)
 

Private Member Functions

void forward ()
 
CoordType storageIndexToFullCoord (IndexType storageIndex)
 

Private Attributes

MatrixStorage m_matType
 
IterType m_iter
 
IndexType m_begin
 
IndexType m_end
 
IndexType m_blkDim
 
const DataVectorTypem_val
 
const IndexVectorTypem_indx
 
const IndexVectorTypem_pntr
 

Detailed Description

template<typename T>
class Nektar::StorageSmvBsr< T >::const_iterator

Definition at line 78 of file StorageSmvBsr.hpp.

Constructor & Destructor Documentation

◆ const_iterator() [1/2]

template<typename DataType >
Nektar::StorageSmvBsr< DataType >::const_iterator::const_iterator ( MatrixStorage  matType,
IndexType  begin,
IndexType  end,
IndexType  blkDim,
const DataVectorType val,
const IndexVectorType indx,
const IndexVectorType pntr 
)

Definition at line 51 of file StorageSmvBsr.cpp.

References Nektar::StorageSmvBsr< T >::begin(), Nektar::StorageSmvBsr< T >::const_iterator::IterType::first, Nektar::NekConstants::kNekSparseNonZeroTol, Nektar::StorageSmvBsr< T >::const_iterator::m_iter, Nektar::StorageSmvBsr< T >::const_iterator::m_val, Nektar::StorageSmvBsr< T >::const_iterator::IterType::nnzindex, Nektar::Array< OneD, const DataType >::num_elements(), Nektar::StorageSmvBsr< T >::const_iterator::IterType::second, Nektar::StorageSmvBsr< T >::const_iterator::IterType::storageindex, and Nektar::StorageSmvBsr< T >::const_iterator::storageIndexToFullCoord().

58  :
59  m_matType(matType),
60  m_iter(),
61  m_begin(begin),
62  m_end(end),
63  m_blkDim(blkDim),
64  m_val(val),
65  m_indx(indx),
66  m_pntr(pntr)
67  {
69 
70  // Here we rewind the iterator to the 'begin'-th
71  // nonzero double value. Consecutive nonzeros are
72  // to lie within dense block and when it's done,
73  // jump to the next dense block.
74  // NB: m_val stores some explicit zeros that need to be skept.
75  if (begin < end)
76  {
77  // determine offset of 'begin'-th nonzero value
78 
79  m_iter.storageindex = 0;
80  m_iter.nnzindex = 0;
81  while(m_iter.nnzindex < begin)
82  {
83  // explicit zero?
85  {
86  m_iter.nnzindex++;
87  }
90  {
91  std::cout << "const_iterator: 'begin' out stored values bounds" << std::endl;
92  throw 1;
93  }
94  }
96 
98  m_iter.first.first = c.first;
99  m_iter.first.second = c.second;
100  }
101  }
const_iterator begin() const
CoordType storageIndexToFullCoord(IndexType storageIndex)
static const NekDouble kNekSparseNonZeroTol
size_t num_elements() const
Returns the array&#39;s size.
const_iterator end() const
std::pair< IndexType, IndexType > CoordType

◆ const_iterator() [2/2]

template<typename DataType >
Nektar::StorageSmvBsr< DataType >::const_iterator::const_iterator ( const const_iterator src)

Definition at line 133 of file StorageSmvBsr.cpp.

133  :
134  m_matType(src.m_matType),
135  m_iter(src.m_iter),
136  m_begin(src.m_begin),
137  m_end(src.m_end),
138  m_val(src.m_val),
139  m_indx(src.m_indx),
140  m_pntr(src.m_pntr)
141  {
142  }

◆ ~const_iterator()

template<typename DataType >
Nektar::StorageSmvBsr< DataType >::const_iterator::~const_iterator ( )

Definition at line 145 of file StorageSmvBsr.cpp.

146  {
147  }

Member Function Documentation

◆ forward()

template<typename DataType >
void Nektar::StorageSmvBsr< DataType >::const_iterator::forward ( )
private

Definition at line 189 of file StorageSmvBsr.cpp.

References Nektar::StorageSmvBsr< T >::const_iterator::IterType::first, Nektar::NekConstants::kNekSparseNonZeroTol, Nektar::StorageSmvBsr< T >::const_iterator::m_end, Nektar::StorageSmvBsr< T >::const_iterator::m_iter, Nektar::StorageSmvBsr< T >::const_iterator::m_val, Nektar::StorageSmvBsr< T >::const_iterator::IterType::nnzindex, Nektar::Array< OneD, const DataType >::num_elements(), Nektar::StorageSmvBsr< T >::const_iterator::IterType::second, Nektar::StorageSmvBsr< T >::const_iterator::IterType::storageindex, and Nektar::StorageSmvBsr< T >::const_iterator::storageIndexToFullCoord().

Referenced by Nektar::StorageSmvBsr< T >::const_iterator::operator++().

190  {
191  while((m_iter.storageindex+1 < m_val.num_elements()) &&
193 
194  m_iter.nnzindex++;
195 
197  {
199  return;
200  }
201 
203 
205  m_iter.first.first = c.first;
206  m_iter.first.second = c.second;
207  }
CoordType storageIndexToFullCoord(IndexType storageIndex)
static const NekDouble kNekSparseNonZeroTol
size_t num_elements() const
Returns the array&#39;s size.
std::pair< IndexType, IndexType > CoordType

◆ operator!=()

template<typename DataType >
bool Nektar::StorageSmvBsr< DataType >::const_iterator::operator!= ( const const_iterator rhs)

Definition at line 183 of file StorageSmvBsr.cpp.

References Nektar::StorageSmvBsr< T >::const_iterator::m_iter, and Nektar::StorageSmvBsr< T >::const_iterator::IterType::nnzindex.

184  {
185  return !(m_iter.nnzindex == rhs.m_iter.nnzindex);
186  }
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs

◆ operator*()

template<typename DataType >
const StorageSmvBsr< DataType >::const_iterator::IterType & Nektar::StorageSmvBsr< DataType >::const_iterator::operator* ( )

Definition at line 165 of file StorageSmvBsr.cpp.

References Nektar::StorageSmvBsr< T >::const_iterator::m_iter.

166  {
167  return m_iter;
168  }

◆ operator++() [1/2]

template<typename DataType >
StorageSmvBsr< DataType >::const_iterator Nektar::StorageSmvBsr< DataType >::const_iterator::operator++ ( int  )

Definition at line 150 of file StorageSmvBsr.cpp.

References Nektar::StorageSmvBsr< T >::const_iterator::forward().

151  {
152  const_iterator out = *this;
153  forward();
154  return out;
155  }
const_iterator(MatrixStorage matType, IndexType begin, IndexType end, IndexType blkDim, const DataVectorType &val, const IndexVectorType &indx, const IndexVectorType &pntr)

◆ operator++() [2/2]

template<typename DataType >
StorageSmvBsr< DataType >::const_iterator & Nektar::StorageSmvBsr< DataType >::const_iterator::operator++ ( )

Definition at line 158 of file StorageSmvBsr.cpp.

References Nektar::StorageSmvBsr< T >::const_iterator::forward().

159  {
160  forward();
161  return *this;
162  }

◆ operator->()

template<typename DataType >
const StorageSmvBsr< DataType >::const_iterator::IterType * Nektar::StorageSmvBsr< DataType >::const_iterator::operator-> ( )

Definition at line 171 of file StorageSmvBsr.cpp.

References Nektar::StorageSmvBsr< T >::const_iterator::m_iter.

172  {
173  return &m_iter;
174  }

◆ operator==()

template<typename DataType >
bool Nektar::StorageSmvBsr< DataType >::const_iterator::operator== ( const const_iterator rhs)

Definition at line 177 of file StorageSmvBsr.cpp.

References Nektar::StorageSmvBsr< T >::const_iterator::m_iter, and Nektar::StorageSmvBsr< T >::const_iterator::IterType::nnzindex.

178  {
179  return m_iter.nnzindex == rhs.m_iter.nnzindex;
180  }
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs

◆ storageIndexToFullCoord()

template<typename DataType >
CoordType Nektar::StorageSmvBsr< DataType >::const_iterator::storageIndexToFullCoord ( IndexType  storageIndex)
private

Definition at line 104 of file StorageSmvBsr.cpp.

References Nektar::StorageSmvBsr< T >::const_iterator::m_blkDim, Nektar::StorageSmvBsr< T >::const_iterator::m_indx, and Nektar::StorageSmvBsr< T >::const_iterator::m_pntr.

Referenced by Nektar::StorageSmvBsr< T >::const_iterator::const_iterator(), and Nektar::StorageSmvBsr< T >::const_iterator::forward().

105  {
106  // find local row and column indices within this block
107 
108  const IndexType elms = m_blkDim*m_blkDim;
109  const IndexType block = storageIndex / elms;
110  const IndexType loc_offset = storageIndex % elms;
111  const IndexType loc_row = loc_offset % m_blkDim;
112  const IndexType loc_col = loc_offset / m_blkDim;
113 
114  // find block row and block column
115 
116  IndexType block_col = m_indx[block];
117  IndexType block_row = 0;
118  while(block >= m_pntr[block_row+1])
119  {
120  block_row++;
121  }
122 
123  // full matrix coordinates of this nonzero entry
124 
125  CoordType coord;
126  coord.first = block_row*m_blkDim + loc_row;
127  coord.second = block_col*m_blkDim + loc_col;
128  return coord;
129  }
unsigned int IndexType
std::pair< IndexType, IndexType > CoordType

Member Data Documentation

◆ m_begin

template<typename T >
IndexType Nektar::StorageSmvBsr< T >::const_iterator::m_begin
private

Definition at line 115 of file StorageSmvBsr.hpp.

◆ m_blkDim

template<typename T >
IndexType Nektar::StorageSmvBsr< T >::const_iterator::m_blkDim
private

◆ m_end

template<typename T >
IndexType Nektar::StorageSmvBsr< T >::const_iterator::m_end
private

◆ m_indx

template<typename T >
const IndexVectorType& Nektar::StorageSmvBsr< T >::const_iterator::m_indx
private

◆ m_iter

template<typename T >
IterType Nektar::StorageSmvBsr< T >::const_iterator::m_iter
private

◆ m_matType

template<typename T >
MatrixStorage Nektar::StorageSmvBsr< T >::const_iterator::m_matType
private

Definition at line 113 of file StorageSmvBsr.hpp.

◆ m_pntr

template<typename T >
const IndexVectorType& Nektar::StorageSmvBsr< T >::const_iterator::m_pntr
private

◆ m_val

template<typename T >
const DataVectorType& Nektar::StorageSmvBsr< T >::const_iterator::m_val
private