12 #ifndef BOGUS_COMPOUND_SPARSE_BLOCK_INDEX_HPP
13 #define BOGUS_COMPOUND_SPARSE_BLOCK_INDEX_HPP
17 #include "SparseBlockIndex.hpp"
22 template <
typename FirstIndexType,
typename SecondIndexType,
bool NativeOrder >
24 CompoundSparseBlockIndex< FirstIndexType, SecondIndexType, NativeOrder > >
26 typedef typename FirstIndexType::Index Index ;
27 typedef typename FirstIndexType::BlockPtr BlockPtr ;
31 typedef typename Base::InnerIterator InnerIterator ;
37 first( index1.derived() ), second( index2.derived() ),
40 assert( first.outerSize() == first.outerSize() ) ;
41 assert( second.innerSize() == second.innerSize() ) ;
44 Index outerSize()
const {
return first.outerSize() ; }
45 Index nonZeros()
const {
return first.nonZeros() + second.nonZeros() ; }
47 const InnerOffsetsType& innerOffsetsArray()
const {
return innerOffsets ; }
49 Index size( Index outerIdx )
const
51 return first.size( outerIdx ) + second.size( outerIdx ) ;
54 const FirstIndexType& first ;
55 const SecondIndexType& second ;
56 const InnerOffsetsType &innerOffsets ;
59 template <
typename FirstIndexType,
typename SecondIndexType,
bool NativeOrder >
62 typedef typename FirstIndexType::Index Index ;
63 typedef typename FirstIndexType::BlockPtr BlockPtr ;
70 : m_it1( index.first, outer ), m_it2( index.second, outer ), m_it2_begin( m_it2 )
76 return m_it1 || m_it2 ;
79 InnerIterator& operator++()
81 if( m_it1 ) ++ m_it1 ;
85 InnerIterator& operator--()
87 if( m_it2 == m_it2_begin ) --m_it1 ;
94 return m_it1 ? m_it1.inner() : m_it2.inner() ;
96 BlockPtr ptr()
const {
97 return m_it1 ? m_it1.ptr() : m_it2.ptr() ;
100 InnerIterator end()
const
102 return InnerIterator( *this ).toEnd() ;
105 InnerIterator& toEnd()
const
112 bool after( Index outer )
const
114 return NativeOrder ? ( inner() > outer ) : ( inner() < outer ) ;
118 typename FirstIndexType::InnerIterator m_it1 ;
119 typename SecondIndexType::InnerIterator m_it2 ;
120 typename SecondIndexType::InnerIterator m_it2_begin ;
Definition: SparseBlockIndex.hpp:29
const InnerOffsetsType & innerOffsetsArray() const
Definition: SparseBlockIndex.hpp:24
bool valid
Whether this index is currently valid.
Definition: SparseBlockIndex.hpp:40
std::vector< Index > InnerOffsetsType
Type of the array encoding the size of each block of the inner dimension.
Definition: SparseBlockIndex.hpp:37
Definition: CompoundSparseBlockIndex.hpp:23