42 #ifndef SLAP_MATRIX_COOR_TMPL_ITFC_H
43 #define SLAP_MATRIX_COOR_TMPL_ITFC_H
47 #include "AbstractLinAlgPack_Types.hpp"
48 #include "Teuchos_Assert.hpp"
50 namespace AbstractLinAlgPack {
52 template<
class T_Scalar,
class T_Index>
55 template<
class T_Scalar,
class T_Index>
61 template<
class T_Scalar,
class T_Index>
64 typedef T_Index size_type;
65 typedef ptrdiff_t difference_type;
67 typedef T_Scalar value_type;
68 typedef T_Index index_type;
71 size_type rows, size_type cols, size_type nz
72 ,difference_type row_offset, difference_type col_offset
73 ,
const T_Scalar *values,
const T_Index* row_i,
const T_Index* col_j
75 :rows_(rows), cols_(cols), nz_(nz), row_offset_(row_offset), col_offset_(col_offset)
76 ,values_(values), row_i_(row_i), col_j_(col_j)
78 size_type rows()
const {
return rows_; }
79 size_type cols()
const {
return cols_; }
80 size_type nz()
const {
return nz_; }
81 difference_type row_offset()
const {
return row_offset_; }
82 difference_type col_offset()
const {
return col_offset_; }
89 difference_type row_offset_;
90 difference_type col_offset_;
91 const T_Scalar *values_;
92 const T_Index *row_i_;
93 const T_Index *col_j_;
105 template<
class T_Scalar,
class T_Index>
108 typedef T_Scalar value_type;
109 typedef T_Index index_type;
111 const T_Scalar* value,
const T_Index* row_i,
const T_Index* col_j
113 : value_(value), row_i_(row_i), col_j_(col_j)
115 void increment() { ++value_; ++row_i_; ++col_j_; }
116 bool operator!=(
const MatrixCOORTmplItfcItrEleView<T_Scalar,T_Index>& ele)
const
117 {
return value_ != ele.value_ || row_i_ != ele.row_i_ || col_j_ != ele.col_j_; }
118 T_Scalar value()
const {
return *value_; }
119 T_Index row_i()
const {
return *row_i_; }
120 T_Index col_j()
const {
return *col_j_; }
122 const T_Scalar *value_;
123 const T_Index *row_i_;
124 const T_Index *col_j_;
126 MatrixCOORTmplItfcItrEleView();
132 template<
class T_Scalar,
class T_Index>
133 class MatrixCOORTmplItfcItr {
135 MatrixCOORTmplItfcItr(
const T_Scalar* value,
const T_Index* row_i,
const T_Index* col_j, T_Index nz )
136 : ele_(value,row_i,col_j)
147 bool operator!=(
const MatrixCOORTmplItfcItr<T_Scalar,T_Index>& itr)
const
148 {
return ele_ != itr.ele_; }
149 const MatrixCOORTmplItfcItrEleView<T_Scalar,T_Index>* operator->()
const
150 { assert_nz();
return &ele_; }
152 MatrixCOORTmplItfcItrEleView<T_Scalar,T_Index> ele_;
155 void assert_nz()
const
158 nz_left_ <= 0, std::logic_error
159 ,
"MatrixCOORTmplItfcItr<>::assert_nz: Error, trying to access past storage!" );
162 void assert_nz()
const {}
165 MatrixCOORTmplItfcItr();
173 template<
class T_Scalar,
class T_Index>
175 typename MatrixCOORTmplItfc<T_Scalar,T_Index>::const_iterator
176 MatrixCOORTmplItfc<T_Scalar,T_Index>::begin()
const
178 return MatrixCOORTmplItfcItr<T_Scalar,T_Index>(values_,row_i_,col_j_,nz_);
181 template<
class T_Scalar,
class T_Index>
183 typename MatrixCOORTmplItfc<T_Scalar,T_Index>::const_iterator
184 MatrixCOORTmplItfc<T_Scalar,T_Index>::end()
const
186 return MatrixCOORTmplItfcItr<T_Scalar,T_Index>(values_+nz_,row_i_+nz_,col_j_+nz_,0);
191 #endif // SLAP_MATRIX_COOR_TMPL_ITFC_H
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Templated class that supports the COOMatrixTemplateInterface template interface.
Templated class for objects that support the SparseCOOElementTemplatInterface specification.
Templated class for iterator returning objects that support the SparseCOOElementTemplatInterface spec...