Use m_ prefix consistently for private/protected member variables

libeigen/eigen!2168

Co-authored-by: Rasmus Munk Larsen <rmlarsen@gmail.com>
This commit is contained in:
Rasmus Munk Larsen
2026-02-20 20:35:58 -08:00
parent 270ea539fa
commit a87ecfb179
6 changed files with 101 additions and 101 deletions

View File

@@ -34,7 +34,7 @@ class TupleImpl<N, T1, Ts...> {
template <typename U1 = T1, template <typename U1 = T1,
typename EnableIf = std::enable_if_t<std::is_default_constructible<U1>::value && typename EnableIf = std::enable_if_t<std::is_default_constructible<U1>::value &&
reduce_all<std::is_default_constructible<Ts>::value...>::value>> reduce_all<std::is_default_constructible<Ts>::value...>::value>>
constexpr EIGEN_DEVICE_FUNC TupleImpl() : head_{}, tail_{} {} constexpr EIGEN_DEVICE_FUNC TupleImpl() : m_head{}, m_tail{} {}
// Element constructor. // Element constructor.
template <typename U1, typename... Us, template <typename U1, typename... Us,
@@ -45,45 +45,45 @@ class TupleImpl<N, T1, Ts...> {
// this does not look like a copy/move constructor. // this does not look like a copy/move constructor.
N > 1 || std::is_convertible<U1, T1>::value)>> N > 1 || std::is_convertible<U1, T1>::value)>>
constexpr EIGEN_DEVICE_FUNC TupleImpl(U1&& arg1, Us&&... args) constexpr EIGEN_DEVICE_FUNC TupleImpl(U1&& arg1, Us&&... args)
: head_(std::forward<U1>(arg1)), tail_(std::forward<Us>(args)...) {} : m_head(std::forward<U1>(arg1)), m_tail(std::forward<Us>(args)...) {}
// The first stored value. // The first stored value.
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T1& head() { return head_; } EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T1& head() { return m_head; }
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE const T1& head() const { return head_; } EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE const T1& head() const { return m_head; }
// The tail values. // The tail values.
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE TupleImpl<N - 1, Ts...>& tail() { return tail_; } EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE TupleImpl<N - 1, Ts...>& tail() { return m_tail; }
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE const TupleImpl<N - 1, Ts...>& tail() const { return tail_; } EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE const TupleImpl<N - 1, Ts...>& tail() const { return m_tail; }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void swap(TupleImpl& other) { EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void swap(TupleImpl& other) {
using numext::swap; using numext::swap;
swap(head_, other.head_); swap(m_head, other.m_head);
swap(tail_, other.tail_); swap(m_tail, other.m_tail);
} }
template <typename... UTypes> template <typename... UTypes>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TupleImpl& operator=(const TupleImpl<N, UTypes...>& other) { EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TupleImpl& operator=(const TupleImpl<N, UTypes...>& other) {
head_ = other.head_; m_head = other.m_head;
tail_ = other.tail_; m_tail = other.m_tail;
return *this; return *this;
} }
template <typename... UTypes> template <typename... UTypes>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TupleImpl& operator=(TupleImpl<N, UTypes...>&& other) { EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TupleImpl& operator=(TupleImpl<N, UTypes...>&& other) {
head_ = std::move(other.head_); m_head = std::move(other.m_head);
tail_ = std::move(other.tail_); m_tail = std::move(other.m_tail);
return *this; return *this;
} }
private: private:
// Allow related tuples to reference head_/tail_. // Allow related tuples to reference m_head/m_tail.
template <size_t M, typename... UTypes> template <size_t M, typename... UTypes>
friend class TupleImpl; friend class TupleImpl;
T1 head_; T1 m_head;
TupleImpl<N - 1, Ts...> tail_; TupleImpl<N - 1, Ts...> m_tail;
}; };
// Empty tuple specialization. // Empty tuple specialization.

View File

@@ -155,16 +155,16 @@ class ArithmeticSequenceRange {
static constexpr Index SizeAtCompileTime = SizeAtCompileTime_; static constexpr Index SizeAtCompileTime = SizeAtCompileTime_;
static constexpr Index IncrAtCompileTime = IncrAtCompileTime_; static constexpr Index IncrAtCompileTime = IncrAtCompileTime_;
constexpr ArithmeticSequenceRange(Index first, Index size, Index incr) : first_{first}, size_{size}, incr_{incr} {} constexpr ArithmeticSequenceRange(Index first, Index size, Index incr) : m_first{first}, m_size{size}, m_incr{incr} {}
constexpr Index operator[](Index i) const { return first() + i * incr(); } constexpr Index operator[](Index i) const { return first() + i * incr(); }
constexpr Index first() const noexcept { return first_.value(); } constexpr Index first() const noexcept { return m_first.value(); }
constexpr Index size() const noexcept { return size_.value(); } constexpr Index size() const noexcept { return m_size.value(); }
constexpr Index incr() const noexcept { return incr_.value(); } constexpr Index incr() const noexcept { return m_incr.value(); }
private: private:
variable_if_dynamicindex<Index, int(FirstAtCompileTime)> first_; variable_if_dynamicindex<Index, int(FirstAtCompileTime)> m_first;
variable_if_dynamic<Index, int(SizeAtCompileTime)> size_; variable_if_dynamic<Index, int(SizeAtCompileTime)> m_size;
variable_if_dynamicindex<Index, int(IncrAtCompileTime)> incr_; variable_if_dynamicindex<Index, int(IncrAtCompileTime)> m_incr;
}; };
template <typename FirstType, typename SizeType, typename IncrType, int NestedSizeAtCompileTime> template <typename FirstType, typename SizeType, typename IncrType, int NestedSizeAtCompileTime>
@@ -221,14 +221,14 @@ class SingleRange {
static constexpr Index SizeAtCompileTime = Index(1); static constexpr Index SizeAtCompileTime = Index(1);
static constexpr Index IncrAtCompileTime = Index(1); // Needs to be 1 to be treated as block-like. static constexpr Index IncrAtCompileTime = Index(1); // Needs to be 1 to be treated as block-like.
constexpr SingleRange(Index v) noexcept : value_(v) {} constexpr SingleRange(Index v) noexcept : m_value(v) {}
constexpr Index operator[](Index) const noexcept { return first(); } constexpr Index operator[](Index) const noexcept { return first(); }
constexpr Index first() const noexcept { return value_.value(); } constexpr Index first() const noexcept { return m_value.value(); }
constexpr Index size() const noexcept { return SizeAtCompileTime; } constexpr Index size() const noexcept { return SizeAtCompileTime; }
constexpr Index incr() const noexcept { return IncrAtCompileTime; } constexpr Index incr() const noexcept { return IncrAtCompileTime; }
private: private:
variable_if_dynamicindex<Index, int(ValueAtCompileTime)> value_; variable_if_dynamicindex<Index, int(ValueAtCompileTime)> m_value;
}; };
template <typename T> template <typename T>
@@ -280,14 +280,14 @@ class AllRange {
static constexpr Index FirstAtCompileTime = Index(0); static constexpr Index FirstAtCompileTime = Index(0);
static constexpr Index SizeAtCompileTime = SizeAtCompileTime_; static constexpr Index SizeAtCompileTime = SizeAtCompileTime_;
static constexpr Index IncrAtCompileTime = Index(1); static constexpr Index IncrAtCompileTime = Index(1);
constexpr AllRange(Index size) : size_(size) {} constexpr AllRange(Index size) : m_size(size) {}
constexpr Index operator[](Index i) const noexcept { return i; } constexpr Index operator[](Index i) const noexcept { return i; }
constexpr Index first() const noexcept { return FirstAtCompileTime; } constexpr Index first() const noexcept { return FirstAtCompileTime; }
constexpr Index size() const noexcept { return size_.value(); } constexpr Index size() const noexcept { return m_size.value(); }
constexpr Index incr() const noexcept { return IncrAtCompileTime; } constexpr Index incr() const noexcept { return IncrAtCompileTime; }
private: private:
variable_if_dynamic<Index, int(SizeAtCompileTime)> size_; variable_if_dynamic<Index, int(SizeAtCompileTime)> m_size;
}; };
template <int NestedSizeAtCompileTime> template <int NestedSizeAtCompileTime>

View File

@@ -34,104 +34,104 @@ class MaxSizeVector {
public: public:
// Construct a new MaxSizeVector, reserve n elements. // Construct a new MaxSizeVector, reserve n elements.
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit MaxSizeVector(size_t n) EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit MaxSizeVector(size_t n)
: reserve_(n), size_(0), data_(static_cast<T*>(internal::handmade_aligned_malloc(n * sizeof(T), alignment))) {} : m_reserve(n), m_size(0), m_data(static_cast<T*>(internal::handmade_aligned_malloc(n * sizeof(T), alignment))) {}
// Construct a new MaxSizeVector, reserve and resize to n. // Construct a new MaxSizeVector, reserve and resize to n.
// Copy the init value to all elements. // Copy the init value to all elements.
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE MaxSizeVector(size_t n, const T& init) EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE MaxSizeVector(size_t n, const T& init)
: reserve_(n), size_(n), data_(static_cast<T*>(internal::handmade_aligned_malloc(n * sizeof(T), alignment))) { : m_reserve(n), m_size(n), m_data(static_cast<T*>(internal::handmade_aligned_malloc(n * sizeof(T), alignment))) {
size_t i = 0; size_t i = 0;
EIGEN_TRY { EIGEN_TRY {
for (; i < size_; ++i) { for (; i < m_size; ++i) {
new (&data_[i]) T(init); new (&m_data[i]) T(init);
} }
} }
EIGEN_CATCH(...) { EIGEN_CATCH(...) {
// Construction failed, destruct in reverse order: // Construction failed, destruct in reverse order:
for (; (i + 1) > 0; --i) { for (; (i + 1) > 0; --i) {
data_[i - 1].~T(); m_data[i - 1].~T();
} }
internal::handmade_aligned_free(data_); internal::handmade_aligned_free(m_data);
EIGEN_THROW; EIGEN_THROW;
} }
} }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ~MaxSizeVector() { EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ~MaxSizeVector() {
for (size_t i = size_; i > 0; --i) { for (size_t i = m_size; i > 0; --i) {
data_[i - 1].~T(); m_data[i - 1].~T();
} }
internal::handmade_aligned_free(data_); internal::handmade_aligned_free(m_data);
} }
void resize(size_t n) { void resize(size_t n) {
eigen_assert(n <= reserve_); eigen_assert(n <= m_reserve);
for (; size_ < n; ++size_) { for (; m_size < n; ++m_size) {
new (&data_[size_]) T; new (&m_data[m_size]) T;
} }
for (; size_ > n; --size_) { for (; m_size > n; --m_size) {
data_[size_ - 1].~T(); m_data[m_size - 1].~T();
} }
eigen_assert(size_ == n); eigen_assert(m_size == n);
} }
// Append new elements (up to reserved size). // Append new elements (up to reserved size).
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void push_back(const T& t) { EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void push_back(const T& t) {
eigen_assert(size_ < reserve_); eigen_assert(m_size < m_reserve);
new (&data_[size_++]) T(t); new (&m_data[m_size++]) T(t);
} }
// For C++03 compatibility this only takes one argument // For C++03 compatibility this only takes one argument
template <class X> template <class X>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void emplace_back(const X& x) { EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void emplace_back(const X& x) {
eigen_assert(size_ < reserve_); eigen_assert(m_size < m_reserve);
new (&data_[size_++]) T(x); new (&m_data[m_size++]) T(x);
} }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const T& operator[](size_t i) const { EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const T& operator[](size_t i) const {
eigen_assert(i < size_); eigen_assert(i < m_size);
return data_[i]; return m_data[i];
} }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T& operator[](size_t i) { EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T& operator[](size_t i) {
eigen_assert(i < size_); eigen_assert(i < m_size);
return data_[i]; return m_data[i];
} }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T& back() { EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T& back() {
eigen_assert(size_ > 0); eigen_assert(m_size > 0);
return data_[size_ - 1]; return m_data[m_size - 1];
} }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const T& back() const { EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const T& back() const {
eigen_assert(size_ > 0); eigen_assert(m_size > 0);
return data_[size_ - 1]; return m_data[m_size - 1];
} }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void pop_back() { EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void pop_back() {
eigen_assert(size_ > 0); eigen_assert(m_size > 0);
data_[--size_].~T(); m_data[--m_size].~T();
} }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE size_t size() const { return size_; } EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE size_t size() const { return m_size; }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool empty() const { return size_ == 0; } EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool empty() const { return m_size == 0; }
EIGEN_DEVICE_FUNC constexpr T* data() { return data_; } EIGEN_DEVICE_FUNC constexpr T* data() { return m_data; }
EIGEN_DEVICE_FUNC constexpr const T* data() const { return data_; } EIGEN_DEVICE_FUNC constexpr const T* data() const { return m_data; }
EIGEN_DEVICE_FUNC constexpr T* begin() { return data_; } EIGEN_DEVICE_FUNC constexpr T* begin() { return m_data; }
EIGEN_DEVICE_FUNC constexpr T* end() { return data_ + size_; } EIGEN_DEVICE_FUNC constexpr T* end() { return m_data + m_size; }
EIGEN_DEVICE_FUNC constexpr const T* begin() const { return data_; } EIGEN_DEVICE_FUNC constexpr const T* begin() const { return m_data; }
EIGEN_DEVICE_FUNC constexpr const T* end() const { return data_ + size_; } EIGEN_DEVICE_FUNC constexpr const T* end() const { return m_data + m_size; }
private: private:
size_t reserve_; size_t m_reserve;
size_t size_; size_t m_size;
T* data_; T* m_data;
}; };
} // namespace Eigen } // namespace Eigen

View File

@@ -188,10 +188,10 @@ template <typename IndexType>
class ValueExpr : BaseExpr<ValueExpr<IndexType>> { class ValueExpr : BaseExpr<ValueExpr<IndexType>> {
public: public:
constexpr ValueExpr() = default; constexpr ValueExpr() = default;
constexpr ValueExpr(IndexType val) : value_(val) {} constexpr ValueExpr(IndexType val) : m_value(val) {}
template <typename... Tags, typename... Types> template <typename... Tags, typename... Types>
constexpr IndexType eval_impl(const SymbolValue<Tags, Types>&...) const { constexpr IndexType eval_impl(const SymbolValue<Tags, Types>&...) const {
return value_; return m_value;
} }
template <typename... Tags, typename... Types> template <typename... Tags, typename... Types>
static constexpr IndexType eval_at_compile_time_impl(const SymbolValue<Tags, Types>&...) { static constexpr IndexType eval_at_compile_time_impl(const SymbolValue<Tags, Types>&...) {
@@ -199,7 +199,7 @@ class ValueExpr : BaseExpr<ValueExpr<IndexType>> {
} }
protected: protected:
IndexType value_; IndexType m_value;
}; };
// Specialization for compile-time value, // Specialization for compile-time value,
@@ -232,10 +232,10 @@ class SymbolValue<Tag, Index> : public BaseExpr<SymbolValue<Tag, Index>> {
constexpr SymbolValue() = default; constexpr SymbolValue() = default;
/** Default constructor from the value \a val */ /** Default constructor from the value \a val */
constexpr SymbolValue(Index val) : value_(val) {} constexpr SymbolValue(Index val) : m_value(val) {}
/** \returns the stored value of the symbol */ /** \returns the stored value of the symbol */
constexpr Index value() const { return value_; } constexpr Index value() const { return m_value; }
/** \returns the stored value of the symbol at compile time, or Undefined if not known. */ /** \returns the stored value of the symbol at compile time, or Undefined if not known. */
static constexpr Index value_at_compile_time() { return Index(Undefined); } static constexpr Index value_at_compile_time() { return Index(Undefined); }
@@ -251,7 +251,7 @@ class SymbolValue<Tag, Index> : public BaseExpr<SymbolValue<Tag, Index>> {
} }
protected: protected:
Index value_; Index m_value;
}; };
template <typename Tag, int N> template <typename Tag, int N>

View File

@@ -50,13 +50,13 @@ struct CoherentPadOp : public dense_xpr_base<CoherentPadOp<XprType, SizeAtCompil
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoherentPadOp(const CoherentPadOp&) = default; EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoherentPadOp(const CoherentPadOp&) = default;
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoherentPadOp(CoherentPadOp&& other) = default; EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoherentPadOp(CoherentPadOp&& other) = default;
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoherentPadOp(const XprType& xpr, Index size) : xpr_(xpr), size_(size) { EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoherentPadOp(const XprType& xpr, Index size) : m_xpr(xpr), m_size(size) {
static_assert(XprNested_::IsVectorAtCompileTime, "input type must be a vector"); static_assert(XprNested_::IsVectorAtCompileTime, "input type must be a vector");
} }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const XprNested_& nestedExpression() const { return xpr_; } EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const XprNested_& nestedExpression() const { return m_xpr; }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index size() const { return size_.value(); } EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index size() const { return m_size.value(); }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index rows() const { EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index rows() const {
return traits<CoherentPadOp>::IsRowMajor ? Index(1) : size(); return traits<CoherentPadOp>::IsRowMajor ? Index(1) : size();
@@ -67,8 +67,8 @@ struct CoherentPadOp : public dense_xpr_base<CoherentPadOp<XprType, SizeAtCompil
} }
private: private:
XprNested xpr_; XprNested m_xpr;
const internal::variable_if_dynamic<Index, SizeAtCompileTime> size_; const internal::variable_if_dynamic<Index, SizeAtCompileTime> m_size;
}; };
// Adapted from the Replicate evaluator. // Adapted from the Replicate evaluator.

View File

@@ -177,7 +177,7 @@ class RandomSetter {
* a sparse matrix from scratch, then you must set it to zero first using the * a sparse matrix from scratch, then you must set it to zero first using the
* setZero() function. * setZero() function.
*/ */
inline RandomSetter(SparseMatrixType& target) : mp_target(&target) { inline RandomSetter(SparseMatrixType& target) : m_target(&target) {
const Index outerSize = SwapStorage ? target.innerSize() : target.outerSize(); const Index outerSize = SwapStorage ? target.innerSize() : target.outerSize();
const Index innerSize = SwapStorage ? target.outerSize() : target.innerSize(); const Index innerSize = SwapStorage ? target.outerSize() : target.innerSize();
m_outerPackets = outerSize >> OuterPacketBits; m_outerPackets = outerSize >> OuterPacketBits;
@@ -194,8 +194,8 @@ class RandomSetter {
for (Index k = 0; k < m_outerPackets; ++k) MapTraits<ScalarWrapper>::setInvalidKey(m_hashmaps[k], ik); for (Index k = 0; k < m_outerPackets; ++k) MapTraits<ScalarWrapper>::setInvalidKey(m_hashmaps[k], ik);
// insert current coeffs // insert current coeffs
for (Index j = 0; j < mp_target->outerSize(); ++j) for (Index j = 0; j < m_target->outerSize(); ++j)
for (typename SparseMatrixType::InnerIterator it(*mp_target, j); it; ++it) for (typename SparseMatrixType::InnerIterator it(*m_target, j); it; ++it)
(*this)(TargetRowMajor ? j : it.index(), TargetRowMajor ? it.index() : j) = it.value(); (*this)(TargetRowMajor ? j : it.index(), TargetRowMajor ? it.index() : j) = it.value();
} }
@@ -204,9 +204,9 @@ class RandomSetter {
KeyType keyBitsMask = (1 << m_keyBitsOffset) - 1; KeyType keyBitsMask = (1 << m_keyBitsOffset) - 1;
if (!SwapStorage) // also means the map is sorted if (!SwapStorage) // also means the map is sorted
{ {
mp_target->setZero(); m_target->setZero();
mp_target->makeCompressed(); m_target->makeCompressed();
mp_target->reserve(nonZeros()); m_target->reserve(nonZeros());
Index prevOuter = -1; Index prevOuter = -1;
for (Index k = 0; k < m_outerPackets; ++k) { for (Index k = 0; k < m_outerPackets; ++k) {
const Index outerOffset = (1 << OuterPacketBits) * k; const Index outerOffset = (1 << OuterPacketBits) * k;
@@ -215,15 +215,15 @@ class RandomSetter {
const Index outer = (it->first >> m_keyBitsOffset) + outerOffset; const Index outer = (it->first >> m_keyBitsOffset) + outerOffset;
const Index inner = it->first & keyBitsMask; const Index inner = it->first & keyBitsMask;
if (prevOuter != outer) { if (prevOuter != outer) {
for (Index j = prevOuter + 1; j <= outer; ++j) mp_target->startVec(j); for (Index j = prevOuter + 1; j <= outer; ++j) m_target->startVec(j);
prevOuter = outer; prevOuter = outer;
} }
mp_target->insertBackByOuterInner(outer, inner) = it->second.value; m_target->insertBackByOuterInner(outer, inner) = it->second.value;
} }
} }
mp_target->finalize(); m_target->finalize();
} else { } else {
VectorXi positions(mp_target->outerSize()); VectorXi positions(m_target->outerSize());
positions.setZero(); positions.setZero();
// pass 1 // pass 1
for (Index k = 0; k < m_outerPackets; ++k) { for (Index k = 0; k < m_outerPackets; ++k) {
@@ -235,15 +235,15 @@ class RandomSetter {
} }
// prefix sum // prefix sum
StorageIndex count = 0; StorageIndex count = 0;
for (Index j = 0; j < mp_target->outerSize(); ++j) { for (Index j = 0; j < m_target->outerSize(); ++j) {
StorageIndex tmp = positions[j]; StorageIndex tmp = positions[j];
mp_target->outerIndexPtr()[j] = count; m_target->outerIndexPtr()[j] = count;
positions[j] = count; positions[j] = count;
count += tmp; count += tmp;
} }
mp_target->makeCompressed(); m_target->makeCompressed();
mp_target->outerIndexPtr()[mp_target->outerSize()] = count; m_target->outerIndexPtr()[m_target->outerSize()] = count;
mp_target->resizeNonZeros(count); m_target->resizeNonZeros(count);
// pass 2 // pass 2
for (Index k = 0; k < m_outerPackets; ++k) { for (Index k = 0; k < m_outerPackets; ++k) {
const Index outerOffset = (1 << OuterPacketBits) * k; const Index outerOffset = (1 << OuterPacketBits) * k;
@@ -255,15 +255,15 @@ class RandomSetter {
// Note that we have to deal with at most 2^OuterPacketBits unsorted coefficients, // Note that we have to deal with at most 2^OuterPacketBits unsorted coefficients,
// moreover those 2^OuterPacketBits coeffs are likely to be sparse, an so only a // moreover those 2^OuterPacketBits coeffs are likely to be sparse, an so only a
// small fraction of them have to be sorted, whence the following simple procedure: // small fraction of them have to be sorted, whence the following simple procedure:
Index posStart = mp_target->outerIndexPtr()[outer]; Index posStart = m_target->outerIndexPtr()[outer];
Index i = (positions[outer]++) - 1; Index i = (positions[outer]++) - 1;
while ((i >= posStart) && (mp_target->innerIndexPtr()[i] > inner)) { while ((i >= posStart) && (m_target->innerIndexPtr()[i] > inner)) {
mp_target->valuePtr()[i + 1] = mp_target->valuePtr()[i]; m_target->valuePtr()[i + 1] = m_target->valuePtr()[i];
mp_target->innerIndexPtr()[i + 1] = mp_target->innerIndexPtr()[i]; m_target->innerIndexPtr()[i + 1] = m_target->innerIndexPtr()[i];
--i; --i;
} }
mp_target->innerIndexPtr()[i + 1] = internal::convert_index<StorageIndex>(inner); m_target->innerIndexPtr()[i + 1] = internal::convert_index<StorageIndex>(inner);
mp_target->valuePtr()[i + 1] = it->second.value; m_target->valuePtr()[i + 1] = it->second.value;
} }
} }
} }
@@ -298,7 +298,7 @@ class RandomSetter {
protected: protected:
HashMapType* m_hashmaps; HashMapType* m_hashmaps;
SparseMatrixType* mp_target; SparseMatrixType* m_target;
Index m_outerPackets; Index m_outerPackets;
unsigned char m_keyBitsOffset; unsigned char m_keyBitsOffset;
}; };