1 #ifndef VIENNACL_TOOLS_ADAPTER_HPP_
2 #define VIENNACL_TOOLS_ADAPTER_HPP_
47 template<
typename NumericT,
typename SizeT,
bool is_iterator1,
bool is_forward>
58 : mat_(mat), i_(static_cast<size_type>(i)), j_(static_cast<size_type>(j))
72 if (i_ < mat_.size() && mat_[
static_cast<vcl_size_t>(i)].
size() > 0 )
75 if (static_cast<int>(mat_[static_cast<vcl_size_t>(i)].rbegin()->first) < j)
80 else if (i_ < mat_.size() && mat_[
static_cast<vcl_size_t>(i)].
size() == 0)
81 iter2 = mat_[static_cast<vcl_size_t>(i)].end();
83 iter2 = mat_.back().end();
90 bool flag_iterator1 = is_iterator1;
93 typedef typename std::map<SizeT, NumericT>::const_iterator col_iterator;
95 col_iterator colit = mat_[i_].find(static_cast<unsigned int>(j_));
97 if (colit != mat_[i_].
end())
102 return iter2->second;
107 bool flag_iterator1 = is_iterator1;
108 bool flag_forward = is_forward;
120 self_type
operator++(
int) { self_type tmp = *
this; ++(*this);
return tmp; }
124 bool flag_iterator1 = is_iterator1;
125 bool flag_forward = is_forward;
135 for (SizeT k=0; k<offset; ++k)
143 bool flag_iterator1 = is_iterator1;
144 return flag_iterator1 ? (i_ == other.i_) : (iter2 == other.iter2);
147 bool operator!=(self_type
const & other)
const {
return !(*
this == other); }
152 bool flag_iterator1 = is_iterator1;
165 int end_ =
static_cast<int>(mat_[i_].size());
167 end_ =
static_cast<int>(mat_[i_].rbegin()->first);
172 std::vector<std::map<SizeT, NumericT> >
const & mat_;
173 typename std::map<SizeT, NumericT>::const_iterator iter2;
182 template<
typename NumericT,
typename SizeT =
unsigned int>
194 : mat_(mat), size1_(mat_.
size()), size2_(mat_.
size()) {}
197 : mat_(mat), size1_(num_rows), size2_(num_cols) {}
199 size_type
size1()
const {
return size1_; }
200 size_type
size2()
const {
return size2_; }
213 typedef typename std::map<SizeT, NumericT>::const_iterator col_iterator;
215 col_iterator colit = mat_[i].find(j);
217 if (colit != mat_[i].end())
218 return colit->second;
223 std::vector<std::map<SizeT, NumericT> >
const & mat_;
236 template<
typename NumericT,
typename SizeT,
bool is_iterator1>
247 : mat_(mat), i_(static_cast<size_type>(i)), j_(static_cast<size_type>(j))
261 if (i_ < mat_.size() && mat_[i_].size() > 0 )
264 if (static_cast<int>(mat_[i_].rbegin()->first) < j)
265 iter2 = mat_[i_].
end();
267 iter2 = mat_[i_].begin();
269 else if (i_ < mat_.size() && mat_[i_].size() == 0)
270 iter2 = mat_[i_].
end();
272 iter2 = mat_.back().end();
279 bool flag_iterator1 = is_iterator1;
282 return mat_[i_][
static_cast<SizeT
>(j_)];
285 return iter2->second;
290 bool flag_iterator1 = is_iterator1;
297 self_type
operator++(
int) { self_type tmp = *
this; ++(*this);
return tmp; }
301 bool flag_iterator1 = is_iterator1;
306 for (size_type k=0; k<offset; ++k)
314 bool flag_iterator1 = is_iterator1;
316 return (i_ == other.i_);
317 return (iter2 == other.iter2);
319 bool operator!=(self_type
const & other)
const {
return !(*
this == other); }
324 bool flag_iterator1 = is_iterator1;
337 int end_ =
static_cast<int>(mat_[i_].size());
339 end_ =
static_cast<int>(mat_[i_].rbegin()->first);
344 std::vector<std::map<SizeT, NumericT> > & mat_;
345 typename std::map<SizeT, NumericT>::iterator iter2;
356 template<
typename NumericT,
typename SizeT =
unsigned int>
368 : BaseType(mat), mat_(mat), size1_(static_cast<SizeT>(mat_.
size())), size2_(static_cast<SizeT>(mat_.
size())) {}
373 : BaseType(mat, num_rows, num_cols), mat_(mat), size1_(static_cast<size_type>(num_rows)), size2_(static_cast<size_type>(num_cols)) {}
376 iterator1
end1() {
return iterator1(mat_, static_cast<int>(mat_.size()), static_cast<int>(mat_.back().size())); }
382 iterator2
end2() {
return iterator2(mat_, mat_.size(), mat_.back().size()); }
396 size1_ =
static_cast<size_type
>(i);
397 size2_ =
static_cast<size_type
>(j);
402 for (size_type i=0; i<mat_.size(); ++i)
406 size_type
size1() {
return size1_; }
407 size_type
size1()
const {
return size1_; }
410 size_type
size2() {
return size2_; }
411 size_type
size2()
const {
return size2_; }
414 std::vector<std::map<SizeT, NumericT> > & mat_;
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.
vcl_size_t size(VectorType const &vec)
Generic routine for obtaining the size of a vector (ViennaCL, uBLAS, etc.)