Xped
Loading...
Searching...
No Matches
VecOfMatIterator.hpp
Go to the documentation of this file.
1#ifndef XPED_VECOFMAT_ITERATOR_HPP_
2#define XPED_VECOFMAT_ITERATOR_HPP_
3
4#include <boost/iterator/iterator_facade.hpp>
5
8
9namespace Xped {
10
11namespace internal {
12template <typename Element>
13class VecOfMatIterator : public boost::iterator_facade<VecOfMatIterator<Element>, Element*, boost::forward_traversal_tag, Element>
14{
15public:
17 : data(nullptr)
18 {}
19
20 VecOfMatIterator(std::vector<PlainInterface::MType<Element>>* o_val, std::size_t block_num = 0, std::size_t elem_num = 0)
21 : data(o_val)
22 , block_num(block_num)
23 , elem_num(elem_num)
24 {}
25
26private:
28
29 void increment()
30 {
31 if(block_num == data->size() - 1 and elem_num == data->at(block_num).size() - 1) {
32 block_num = data->size();
33 elem_num = 0;
34 return;
35 }
36 if(elem_num < data->at(block_num).size() - 1)
37 ++elem_num;
38 else {
39 ++block_num;
40 elem_num = 0;
41 }
42 }
43
44 bool equal(VecOfMatIterator<Element> const& other) const { return (this->block_num == other.block_num and this->elem_num == other.elem_num); }
45
46 Element dereference() const { return *(PlainInterface::get_raw_data(data->at(block_num)) + elem_num); }
47
48 std::vector<PlainInterface::MType<Element>>* data;
49 std::size_t block_num = 0;
50 std::size_t elem_num = 0;
51};
52
53} // namespace internal
54
55template <typename Scalar>
57// template <typename Scalar>
58// using const_VecOfMatIterator = internal::VecOfMatIterator<const Scalar>;
59
60} // namespace Xped
61#endif
Definition: VecOfMatIterator.hpp:14
VecOfMatIterator()
Definition: VecOfMatIterator.hpp:16
friend class boost::iterator_core_access
Definition: VecOfMatIterator.hpp:27
VecOfMatIterator(std::vector< PlainInterface::MType< Element > > *o_val, std::size_t block_num=0, std::size_t elem_num=0)
Definition: VecOfMatIterator.hpp:20
Definition: bench.cpp:62
Definition: MatrixMultiplication.hpp:4
CTF::Matrix< Scalar > MType
Definition: MatrixInterface_Cyclops_impl.hpp:40
static const Scalar * get_raw_data(const Eigen::Matrix< Scalar, -1, -1 > &M)
Definition: MatrixInterface_Eigen_impl.hpp:81