/usr/include/vmmlib/tensor3_iterator.hpp is in libvmmlib-dev 1.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | /*
* VMMLib - Tensor Classes
*
* @author Jonas Boesch
* @author Susanne Suter
*
*
*/
#ifndef __VMML__TENSOR3_ITERATOR__HPP__
#define __VMML__TENSOR3_ITERATOR__HPP__
#include <vmmlib/matrix.hpp>
namespace vmml
{
template< typename T >
class tensor3_iterator
{
public:
typedef typename T::value_type value_type;
typedef typename T::pointer pointer;
typedef typename T::reference reference;
typedef typename std::forward_iterator_tag iterator_category;
typedef size_t difference_type;
typedef typename matrix< T::ROWS, T::COLS, typename T::value_type >::iterator matrix_iterator;
typedef typename T::front_slice_type slice_type;
tensor3_iterator() : _tensor3( 0 ), _matrix_index( 0 ) {};
tensor3_iterator( T& t_, bool begin_ ) : _tensor3( &t_ ), _matrix_index( 0 )
{
if ( begin_ )
{
_matrix_index = 0;
slice_type& slice_ = _tensor3->get_frontal_slice_fwd( _matrix_index );
_matrix_it = slice_.begin();
_matrix_it_end = slice_.end();
}
else
{
_matrix_index = T::SLICES - 1;
slice_type& slice_ = _tensor3->get_frontal_slice_fwd( _matrix_index );
_matrix_it = slice_.end();
_matrix_it_end = slice_.begin();
}
}
value_type& operator*()
{
return *_matrix_it;
}
const value_type& operator*() const
{
return *_matrix_it;
}
bool operator==( const tensor3_iterator& it_ ) const
{
return it_._tensor3 == _tensor3
// && it_._matrix_index == _matrix_index
&& it_._matrix_it == _matrix_it;
}
bool operator!=( const tensor3_iterator& it_ ) const
{
return ! operator==(it_);
}
void operator++()
{
if ( _tensor3 == 0 )
{
VMMLIB_ERROR( "attempt to increase singular iterator", VMMLIB_HERE );
}
if ( _matrix_it != _matrix_it_end )
++_matrix_it;
if ( _matrix_it == _matrix_it_end && _matrix_index < T::SLICES - 1 )
{
++_matrix_index;
//slice_type& slice_ = _tensor3->get_frontal_slice( _matrix_index );
_matrix_it = _tensor3->get_frontal_slice_fwd( _matrix_index ).begin();
_matrix_it_end = _tensor3->get_frontal_slice_fwd( _matrix_index ).end();
}
}
protected:
matrix_iterator _matrix_it;
matrix_iterator _matrix_it_end;
T* _tensor3;
size_t _matrix_index;
}; //end tensor3_iterator class
template< typename T >
class tensor3_const_iterator
{
public:
typedef typename T::value_type value_type;
typedef typename T::pointer pointer;
typedef typename T::reference reference;
typedef typename std::forward_iterator_tag iterator_category;
typedef size_t difference_type;
typedef typename matrix< T::ROWS, T::COLS, typename T::value_type >::const_iterator matrix_iterator;
typedef typename T::front_slice_type slice_type;
tensor3_const_iterator() : _tensor3( 0 ), _matrix_index( 0 ) {};
tensor3_const_iterator( const T& t_, bool begin_ ) : _tensor3( &t_ ), _matrix_index( 0 )
{
if ( begin_ )
{
_matrix_index = 0;
const slice_type& slice_ = _tensor3->get_frontal_slice_fwd( _matrix_index );
_matrix_it = slice_.begin();
_matrix_it_end = slice_.end();
}
else
{
_matrix_index = T::SLICES - 1;
const slice_type& slice_ = _tensor3->get_frontal_slice_fwd( _matrix_index );
_matrix_it = slice_.end();
_matrix_it_end = slice_.begin();
}
}
const value_type& operator*() const
{
return *_matrix_it;
}
bool operator==( const tensor3_const_iterator& it_ ) const
{
return it_._matrix_it == _matrix_it;
}
bool operator!=( const tensor3_const_iterator& it_ ) const
{
return it_._matrix_it != _matrix_it;
}
void operator++()
{
if ( _tensor3 == 0 )
{
VMMLIB_ERROR( "attempt to increase singular iterator", VMMLIB_HERE );
}
if ( _matrix_it != _matrix_it_end )
++_matrix_it;
if ( _matrix_it == _matrix_it_end && _matrix_index < T::SLICES - 1 )
{
++_matrix_index;
//const slice_type& slice_ = _tensor3->get_frontal_slice( _matrix_index );
_matrix_it = _tensor3->get_frontal_slice_fwd( _matrix_index ).begin();
_matrix_it_end = _tensor3->get_frontal_slice_fwd( _matrix_index ).end();
}
}
protected:
matrix_iterator _matrix_it;
matrix_iterator _matrix_it_end;
const T* _tensor3;
size_t _matrix_index;
}; //end tensor3_const_iterator class
}// end vmml namespace
#endif
|