10 #ifndef EIGEN_RANDOMSETTER_H
11 #define EIGEN_RANDOMSETTER_H
22 typedef std::map<KeyType,Scalar>
Type;
30 #ifdef EIGEN_UNORDERED_MAP_SUPPORT
47 template<
typename Scalar>
struct StdUnorderedMapTraits
50 typedef std::unordered_map<KeyType,Scalar>
Type;
55 static void setInvalidKey(
Type&,
const KeyType&) {}
57 #endif // EIGEN_UNORDERED_MAP_SUPPORT
59 #ifdef _DENSE_HASH_MAP_H_
64 template<
typename Scalar>
struct GoogleDenseHashMapTraits
67 typedef google::dense_hash_map<KeyType,Scalar>
Type;
72 static void setInvalidKey(
Type& map,
const KeyType& k)
73 { map.set_empty_key(k); }
77 #ifdef _SPARSE_HASH_MAP_H_
82 template<
typename Scalar>
struct GoogleSparseHashMapTraits
85 typedef google::sparse_hash_map<KeyType,Scalar>
Type;
90 static void setInvalidKey(
Type&,
const KeyType&) {}
144 template<
typename SparseMatrixType,
145 template <
typename T>
class MapTraits =
146 #if defined _DENSE_HASH_MAP_H_
147 GoogleDenseHashMapTraits
148 #elif defined _HASH_MAP
153 ,
int OuterPacketBits = 6>
164 typedef typename MapTraits<ScalarWrapper>::KeyType
KeyType;
184 const Index outerSize =
SwapStorage ? target.innerSize() : target.outerSize();
185 const Index innerSize =
SwapStorage ? target.outerSize() : target.innerSize();
191 Index aux = innerSize - 1;
200 MapTraits<ScalarWrapper>::setInvalidKey(
m_hashmaps[k],ik);
204 for (
typename SparseMatrixType::InnerIterator it(*
mp_target,j); it; ++it)
217 Index prevOuter = -1;
220 const Index outerOffset = (1<<OuterPacketBits) * k;
221 typename HashMapType::iterator end =
m_hashmaps[k].end();
222 for (
typename HashMapType::iterator it =
m_hashmaps[k].begin(); it!=end; ++it)
225 const Index inner = it->first & keyBitsMask;
226 if (prevOuter!=outer)
228 for (
Index j=prevOuter+1;j<=outer;++j)
232 mp_target->insertBackByOuterInner(outer, inner) = it->second.value;
239 VectorXi positions(
mp_target->outerSize());
244 typename HashMapType::iterator end =
m_hashmaps[k].end();
245 for (
typename HashMapType::iterator it =
m_hashmaps[k].begin(); it!=end; ++it)
247 const Index outer = it->first & keyBitsMask;
255 Index tmp = positions[j];
257 positions[j] = count;
266 const Index outerOffset = (1<<OuterPacketBits) * k;
267 typename HashMapType::iterator end =
m_hashmaps[k].end();
268 for (
typename HashMapType::iterator it =
m_hashmaps[k].begin(); it!=end; ++it)
271 const Index outer = it->first & keyBitsMask;
277 Index i = (positions[outer]++) - 1;
278 while ( (i >= posStart) && (
mp_target->innerIndexPtr()[i] > inner) )
285 mp_target->valuePtr()[i+1] = it->second.value;
297 const Index outerMajor = outer >> OuterPacketBits;
327 #endif // EIGEN_RANDOMSETTER_H