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 77 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.

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

References Nektar::StorageSmvBsr< T >::begin(), Nektar::StorageSmvBsr< T >::end(), 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::StorageSmvBsr< T >::const_iterator::IterType::second, Nektar::Array< OneD, const DataType >::size(), Nektar::StorageSmvBsr< T >::const_iterator::IterType::storageindex, and Nektar::StorageSmvBsr< T >::const_iterator::storageIndexToFullCoord().

◆ const_iterator() [2/2]

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

Definition at line 124 of file StorageSmvBsr.cpp.

126  : m_matType(src.m_matType), m_iter(src.m_iter), m_begin(src.m_begin),
127  m_end(src.m_end), m_val(src.m_val), m_indx(src.m_indx), m_pntr(src.m_pntr)
128 {
129 }

◆ ~const_iterator()

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

Definition at line 132 of file StorageSmvBsr.cpp.

133 {
134 }

Member Function Documentation

◆ forward()

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

Definition at line 182 of file StorageSmvBsr.cpp.

183 {
184  while ((m_iter.storageindex + 1 < m_val.size()) &&
186  ;
187 
188  m_iter.nnzindex++;
189 
190  if (m_iter.storageindex >= m_val.size())
191  {
193  return;
194  }
195 
197 
199  m_iter.first.first = c.first;
200  m_iter.first.second = c.second;
201 }

References Nektar::NekConstants::kNekSparseNonZeroTol, Nektar::StorageSmvBsr< T >::m_val, and Nektar::Array< OneD, const DataType >::size().

◆ operator!=()

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

Definition at line 175 of file StorageSmvBsr.cpp.

177 {
178  return !(m_iter.nnzindex == rhs.m_iter.nnzindex);
179 }

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

◆ operator*()

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

Definition at line 155 of file StorageSmvBsr.cpp.

156 {
157  return m_iter;
158 }

◆ operator++() [1/2]

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

Definition at line 147 of file StorageSmvBsr.cpp.

148 {
149  forward();
150  return *this;
151 }

◆ operator++() [2/2]

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

Definition at line 138 of file StorageSmvBsr.cpp.

139 {
140  const_iterator out = *this;
141  forward();
142  return out;
143 }
const_iterator(MatrixStorage matType, IndexType begin, IndexType end, IndexType blkDim, const DataVectorType &val, const IndexVectorType &indx, const IndexVectorType &pntr)

◆ operator->()

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

Definition at line 162 of file StorageSmvBsr.cpp.

163 {
164  return &m_iter;
165 }

◆ operator==()

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

Definition at line 168 of file StorageSmvBsr.cpp.

170 {
171  return m_iter.nnzindex == rhs.m_iter.nnzindex;
172 }

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

◆ storageIndexToFullCoord()

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

Definition at line 95 of file StorageSmvBsr.cpp.

97 {
98  // find local row and column indices within this block
99 
100  const IndexType elms = m_blkDim * m_blkDim;
101  const IndexType block = storageIndex / elms;
102  const IndexType loc_offset = storageIndex % elms;
103  const IndexType loc_row = loc_offset % m_blkDim;
104  const IndexType loc_col = loc_offset / m_blkDim;
105 
106  // find block row and block column
107 
108  IndexType block_col = m_indx[block];
109  IndexType block_row = 0;
110  while (block >= m_pntr[block_row + 1])
111  {
112  block_row++;
113  }
114 
115  // full matrix coordinates of this nonzero entry
116 
117  CoordType coord;
118  coord.first = block_row * m_blkDim + loc_row;
119  coord.second = block_col * m_blkDim + loc_col;
120  return coord;
121 }
unsigned int IndexType

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

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

Member Data Documentation

◆ m_begin

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

Definition at line 111 of file StorageSmvBsr.hpp.

◆ m_blkDim

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

Definition at line 113 of file StorageSmvBsr.hpp.

◆ m_end

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

Definition at line 112 of file StorageSmvBsr.hpp.

◆ m_indx

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

Definition at line 115 of file StorageSmvBsr.hpp.

◆ 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 109 of file StorageSmvBsr.hpp.

◆ m_pntr

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

Definition at line 116 of file StorageSmvBsr.hpp.

◆ m_val

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