1 #ifndef VIENNACL_TOOLS_ADAPTER_HPP_
2 #define VIENNACL_TOOLS_ADAPTER_HPP_
47 template <
typename SCALARTYPE,
typename SizeType,
bool is_iterator1,
bool is_forward>
58 : mat_(mat), i_(i), j_(j)
72 if (i_ < mat_.size() && mat_[i].size() > 0 )
75 if (static_cast<int>(mat_[i].rbegin()->first) < j)
76 iter2 = mat_[i].
end();
78 iter2 = mat_[i].begin();
80 else if (i_ < mat_.size() && mat_[i].size() == 0)
81 iter2 = mat_[i].
end();
83 iter2 = mat_.back().end();
92 typedef typename std::map<SizeType, SCALARTYPE>::const_iterator col_iterator;
94 col_iterator colit = mat_[i_].find(static_cast<unsigned int>(j_));
96 if (colit != mat_[i_].
end())
101 return iter2->second;
117 self_type
operator++(
int) { self_type tmp = *
this; ++(*this);
return tmp; }
130 for (SizeType k=0; k<offset; ++k)
138 return is_iterator1 ? (i_ == other.i_) : (iter2 == other.iter2);
141 bool operator!=(self_type
const & other)
const {
return !(*
this == other); }
158 int end_ =
static_cast<int>(mat_[i_].size());
160 end_ = mat_[i_].rbegin()->first;
165 std::vector<std::map<SizeType, SCALARTYPE> >
const & mat_;
166 typename std::map<SizeType, SCALARTYPE>::const_iterator iter2;
175 template <
typename SCALARTYPE,
typename SizeType =
unsigned int>
187 : mat_(mat), size1_(mat_.
size()), size2_(mat_.
size()) {}
190 : mat_(mat), size1_(num_rows), size2_(num_cols) {}
192 size_type
size1()
const {
return size1_; }
193 size_type
size2()
const {
return size2_; }
206 typedef typename std::map<SizeType, SCALARTYPE>::const_iterator col_iterator;
208 col_iterator colit = mat_[i].find(j);
210 if (colit != mat_[i].end())
211 return colit->second;
216 std::vector<std::map<SizeType, SCALARTYPE> >
const & mat_;
229 template <
typename SCALARTYPE,
typename SizeType,
bool is_iterator1>
240 : mat_(mat), i_(i), j_(j)
254 if (i_ < mat_.size() && mat_[i].size() > 0 )
257 if (static_cast<int>(mat_[i].rbegin()->first) < j)
258 iter2 = mat_[i].
end();
260 iter2 = mat_[i].begin();
262 else if (i_ < mat_.size() && mat_[i].size() == 0)
263 iter2 = mat_[i].
end();
265 iter2 = mat_.back().end();
274 return mat_[i_][
static_cast<SizeType
>(j_)];
277 return iter2->second;
288 self_type
operator++(
int) { self_type tmp = *
this; ++(*this);
return tmp; }
296 for (size_type k=0; k<offset; ++k)
305 return (i_ == other.i_);
306 return (iter2 == other.iter2);
308 bool operator!=(self_type
const & other)
const {
return !(*
this == other); }
325 int end_ =
static_cast<int>(mat_[i_].size());
327 end_ = mat_[i_].rbegin()->first;
332 std::vector<std::map<SizeType, SCALARTYPE> > & mat_;
333 typename std::map<SizeType, SCALARTYPE>::iterator iter2;
344 template <
typename SCALARTYPE,
typename SizeType =
unsigned int>
356 : BaseType(mat), mat_(mat), size1_(mat_.
size()), size2_(mat_.
size()) {}
361 : BaseType(mat, num_rows, num_cols), mat_(mat), size1_(static_cast<size_type>(num_rows)), size2_(static_cast<size_type>(num_cols)) {}
364 iterator1
end1() {
return iterator1(mat_, static_cast<int>(mat_.size()), static_cast<int>(mat_.back().size())); }
370 iterator2
end2() {
return iterator2(mat_, mat_.size(), mat_.back().size()); }
384 size1_ =
static_cast<size_type
>(i);
385 size2_ =
static_cast<size_type
>(j);
390 for (size_type i=0; i<mat_.size(); ++i)
394 size_type
size1() {
return size1_; }
395 size_type
size1()
const {
return size1_; }
398 size_type
size2() {
return size2_; }
399 size_type
size2()
const {
return size2_; }
402 std::vector<std::map<SizeType, SCALARTYPE> > & mat_;
std::size_t vcl_size_t
Definition: forwards.h:58
This file provides the forward declarations for the main types used within ViennaCL.
Main namespace in ViennaCL. Holds all the basic types such as vector, matrix, etc. and defines operations upon them.
Definition: cpu_ram.hpp:29
vcl_size_t size(VectorType const &vec)
Generic routine for obtaining the size of a vector (ViennaCL, uBLAS, etc.)
Definition: size.hpp:144