Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
Nektar::StorageSmvBsr< T >::const_iterator Class Reference

#include <StorageSmvBsr.hpp>

Collaboration diagram for Nektar::StorageSmvBsr< T >::const_iterator:
Collaboration graph
[legend]

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

Constructor & Destructor Documentation

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 57 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().

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

Definition at line 139 of file StorageSmvBsr.cpp.

139  :
140  m_matType(src.m_matType),
141  m_iter(src.m_iter),
142  m_begin(src.m_begin),
143  m_end(src.m_end),
144  m_val(src.m_val),
145  m_indx(src.m_indx),
146  m_pntr(src.m_pntr)
147  {
148  }
template<typename DataType >
Nektar::StorageSmvBsr< DataType >::const_iterator::~const_iterator ( )

Definition at line 151 of file StorageSmvBsr.cpp.

152  {
153  }

Member Function Documentation

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

Definition at line 195 of file StorageSmvBsr.cpp.

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

196  {
197  while((m_iter.storageindex+1 < m_val.num_elements()) &&
199 
200  m_iter.nnzindex++;
201 
203  {
205  return;
206  }
207 
209 
211  m_iter.first.first = c.first;
212  m_iter.first.second = c.second;
213  }
size_type num_elements() const
Returns the array's size.
CoordType storageIndexToFullCoord(IndexType storageIndex)
static const NekDouble kNekSparseNonZeroTol
std::pair< IndexType, IndexType > CoordType
template<typename DataType >
bool Nektar::StorageSmvBsr< DataType >::const_iterator::operator!= ( const const_iterator rhs)
template<typename DataType >
const StorageSmvBsr< DataType >::const_iterator::IterType & Nektar::StorageSmvBsr< DataType >::const_iterator::operator* ( )

Definition at line 171 of file StorageSmvBsr.cpp.

172  {
173  return m_iter;
174  }
template<typename DataType >
StorageSmvBsr< DataType >::const_iterator Nektar::StorageSmvBsr< DataType >::const_iterator::operator++ ( int  )

Definition at line 156 of file StorageSmvBsr.cpp.

157  {
158  const_iterator out = *this;
159  forward();
160  return out;
161  }
const_iterator(MatrixStorage matType, IndexType begin, IndexType end, IndexType blkDim, const DataVectorType &val, const IndexVectorType &indx, const IndexVectorType &pntr)
template<typename DataType >
StorageSmvBsr< DataType >::const_iterator & Nektar::StorageSmvBsr< DataType >::const_iterator::operator++ ( )

Definition at line 164 of file StorageSmvBsr.cpp.

165  {
166  forward();
167  return *this;
168  }
template<typename DataType >
const StorageSmvBsr< DataType >::const_iterator::IterType * Nektar::StorageSmvBsr< DataType >::const_iterator::operator-> ( )

Definition at line 177 of file StorageSmvBsr.cpp.

178  {
179  return &m_iter;
180  }
template<typename DataType >
bool Nektar::StorageSmvBsr< DataType >::const_iterator::operator== ( const const_iterator rhs)
template<typename DataType >
CoordType Nektar::StorageSmvBsr< DataType >::const_iterator::storageIndexToFullCoord ( IndexType  storageIndex)
private

Definition at line 110 of file StorageSmvBsr.cpp.

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().

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

Member Data Documentation

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

Definition at line 122 of file StorageSmvBsr.hpp.

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

Definition at line 124 of file StorageSmvBsr.hpp.

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

Definition at line 123 of file StorageSmvBsr.hpp.

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

Definition at line 126 of file StorageSmvBsr.hpp.

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

Definition at line 120 of file StorageSmvBsr.hpp.

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

Definition at line 127 of file StorageSmvBsr.hpp.

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