From a87ecfb179699f5aa72ec572d96a1300dec535ef Mon Sep 17 00:00:00 2001 From: Rasmus Munk Larsen <4643818-rmlarsen1@users.noreply.gitlab.com> Date: Fri, 20 Feb 2026 20:35:58 -0800 Subject: [PATCH] Use m_ prefix consistently for private/protected member variables libeigen/eigen!2168 Co-authored-by: Rasmus Munk Larsen --- Eigen/src/Core/arch/GPU/Tuple.h | 30 +++---- Eigen/src/Core/util/IndexedViewHelper.h | 26 +++--- Eigen/src/Core/util/MaxSizeVector.h | 80 +++++++++---------- Eigen/src/Core/util/SymbolicIndex.h | 12 +-- .../Eigen/src/AutoDiff/CoherentPadOp.h | 10 +-- .../Eigen/src/SparseExtra/RandomSetter.h | 44 +++++----- 6 files changed, 101 insertions(+), 101 deletions(-) diff --git a/Eigen/src/Core/arch/GPU/Tuple.h b/Eigen/src/Core/arch/GPU/Tuple.h index 402d92f76..0e7448792 100644 --- a/Eigen/src/Core/arch/GPU/Tuple.h +++ b/Eigen/src/Core/arch/GPU/Tuple.h @@ -34,7 +34,7 @@ class TupleImpl { template ::value && reduce_all::value...>::value>> - constexpr EIGEN_DEVICE_FUNC TupleImpl() : head_{}, tail_{} {} + constexpr EIGEN_DEVICE_FUNC TupleImpl() : m_head{}, m_tail{} {} // Element constructor. template { // this does not look like a copy/move constructor. N > 1 || std::is_convertible::value)>> constexpr EIGEN_DEVICE_FUNC TupleImpl(U1&& arg1, Us&&... args) - : head_(std::forward(arg1)), tail_(std::forward(args)...) {} + : m_head(std::forward(arg1)), m_tail(std::forward(args)...) {} // 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. - EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE TupleImpl& tail() { return tail_; } + EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE TupleImpl& tail() { return m_tail; } - EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE const TupleImpl& tail() const { return tail_; } + EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE const TupleImpl& tail() const { return m_tail; } EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void swap(TupleImpl& other) { using numext::swap; - swap(head_, other.head_); - swap(tail_, other.tail_); + swap(m_head, other.m_head); + swap(m_tail, other.m_tail); } template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TupleImpl& operator=(const TupleImpl& other) { - head_ = other.head_; - tail_ = other.tail_; + m_head = other.m_head; + m_tail = other.m_tail; return *this; } template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TupleImpl& operator=(TupleImpl&& other) { - head_ = std::move(other.head_); - tail_ = std::move(other.tail_); + m_head = std::move(other.m_head); + m_tail = std::move(other.m_tail); return *this; } private: - // Allow related tuples to reference head_/tail_. + // Allow related tuples to reference m_head/m_tail. template friend class TupleImpl; - T1 head_; - TupleImpl tail_; + T1 m_head; + TupleImpl m_tail; }; // Empty tuple specialization. diff --git a/Eigen/src/Core/util/IndexedViewHelper.h b/Eigen/src/Core/util/IndexedViewHelper.h index abf4b1950..d18b2588b 100644 --- a/Eigen/src/Core/util/IndexedViewHelper.h +++ b/Eigen/src/Core/util/IndexedViewHelper.h @@ -155,16 +155,16 @@ class ArithmeticSequenceRange { static constexpr Index SizeAtCompileTime = SizeAtCompileTime_; 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 first() const noexcept { return first_.value(); } - constexpr Index size() const noexcept { return size_.value(); } - constexpr Index incr() const noexcept { return incr_.value(); } + constexpr Index first() const noexcept { return m_first.value(); } + constexpr Index size() const noexcept { return m_size.value(); } + constexpr Index incr() const noexcept { return m_incr.value(); } private: - variable_if_dynamicindex first_; - variable_if_dynamic size_; - variable_if_dynamicindex incr_; + variable_if_dynamicindex m_first; + variable_if_dynamic m_size; + variable_if_dynamicindex m_incr; }; template @@ -221,14 +221,14 @@ class SingleRange { static constexpr Index SizeAtCompileTime = Index(1); 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 first() const noexcept { return value_.value(); } + constexpr Index first() const noexcept { return m_value.value(); } constexpr Index size() const noexcept { return SizeAtCompileTime; } constexpr Index incr() const noexcept { return IncrAtCompileTime; } private: - variable_if_dynamicindex value_; + variable_if_dynamicindex m_value; }; template @@ -280,14 +280,14 @@ class AllRange { static constexpr Index FirstAtCompileTime = Index(0); static constexpr Index SizeAtCompileTime = SizeAtCompileTime_; 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 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; } private: - variable_if_dynamic size_; + variable_if_dynamic m_size; }; template diff --git a/Eigen/src/Core/util/MaxSizeVector.h b/Eigen/src/Core/util/MaxSizeVector.h index 3375015aa..864caf2dd 100644 --- a/Eigen/src/Core/util/MaxSizeVector.h +++ b/Eigen/src/Core/util/MaxSizeVector.h @@ -34,104 +34,104 @@ class MaxSizeVector { public: // Construct a new MaxSizeVector, reserve n elements. EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit MaxSizeVector(size_t n) - : reserve_(n), size_(0), data_(static_cast(internal::handmade_aligned_malloc(n * sizeof(T), alignment))) {} + : m_reserve(n), m_size(0), m_data(static_cast(internal::handmade_aligned_malloc(n * sizeof(T), alignment))) {} // Construct a new MaxSizeVector, reserve and resize to n. // Copy the init value to all elements. EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE MaxSizeVector(size_t n, const T& init) - : reserve_(n), size_(n), data_(static_cast(internal::handmade_aligned_malloc(n * sizeof(T), alignment))) { + : m_reserve(n), m_size(n), m_data(static_cast(internal::handmade_aligned_malloc(n * sizeof(T), alignment))) { size_t i = 0; EIGEN_TRY { - for (; i < size_; ++i) { - new (&data_[i]) T(init); + for (; i < m_size; ++i) { + new (&m_data[i]) T(init); } } EIGEN_CATCH(...) { // Construction failed, destruct in reverse order: 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_DEVICE_FUNC EIGEN_STRONG_INLINE ~MaxSizeVector() { - for (size_t i = size_; i > 0; --i) { - data_[i - 1].~T(); + for (size_t i = m_size; i > 0; --i) { + m_data[i - 1].~T(); } - internal::handmade_aligned_free(data_); + internal::handmade_aligned_free(m_data); } void resize(size_t n) { - eigen_assert(n <= reserve_); - for (; size_ < n; ++size_) { - new (&data_[size_]) T; + eigen_assert(n <= m_reserve); + for (; m_size < n; ++m_size) { + new (&m_data[m_size]) T; } - for (; size_ > n; --size_) { - data_[size_ - 1].~T(); + for (; m_size > n; --m_size) { + m_data[m_size - 1].~T(); } - eigen_assert(size_ == n); + eigen_assert(m_size == n); } // Append new elements (up to reserved size). EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void push_back(const T& t) { - eigen_assert(size_ < reserve_); - new (&data_[size_++]) T(t); + eigen_assert(m_size < m_reserve); + new (&m_data[m_size++]) T(t); } // For C++03 compatibility this only takes one argument template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void emplace_back(const X& x) { - eigen_assert(size_ < reserve_); - new (&data_[size_++]) T(x); + eigen_assert(m_size < m_reserve); + new (&m_data[m_size++]) T(x); } EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const T& operator[](size_t i) const { - eigen_assert(i < size_); - return data_[i]; + eigen_assert(i < m_size); + return m_data[i]; } EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T& operator[](size_t i) { - eigen_assert(i < size_); - return data_[i]; + eigen_assert(i < m_size); + return m_data[i]; } EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T& back() { - eigen_assert(size_ > 0); - return data_[size_ - 1]; + eigen_assert(m_size > 0); + return m_data[m_size - 1]; } EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const T& back() const { - eigen_assert(size_ > 0); - return data_[size_ - 1]; + eigen_assert(m_size > 0); + return m_data[m_size - 1]; } EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void pop_back() { - eigen_assert(size_ > 0); - data_[--size_].~T(); + eigen_assert(m_size > 0); + 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: - size_t reserve_; - size_t size_; - T* data_; + size_t m_reserve; + size_t m_size; + T* m_data; }; } // namespace Eigen diff --git a/Eigen/src/Core/util/SymbolicIndex.h b/Eigen/src/Core/util/SymbolicIndex.h index dc204af4b..a90e2bb68 100644 --- a/Eigen/src/Core/util/SymbolicIndex.h +++ b/Eigen/src/Core/util/SymbolicIndex.h @@ -188,10 +188,10 @@ template class ValueExpr : BaseExpr> { public: constexpr ValueExpr() = default; - constexpr ValueExpr(IndexType val) : value_(val) {} + constexpr ValueExpr(IndexType val) : m_value(val) {} template constexpr IndexType eval_impl(const SymbolValue&...) const { - return value_; + return m_value; } template static constexpr IndexType eval_at_compile_time_impl(const SymbolValue&...) { @@ -199,7 +199,7 @@ class ValueExpr : BaseExpr> { } protected: - IndexType value_; + IndexType m_value; }; // Specialization for compile-time value, @@ -232,10 +232,10 @@ class SymbolValue : public BaseExpr> { constexpr SymbolValue() = default; /** 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 */ - 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. */ static constexpr Index value_at_compile_time() { return Index(Undefined); } @@ -251,7 +251,7 @@ class SymbolValue : public BaseExpr> { } protected: - Index value_; + Index m_value; }; template diff --git a/unsupported/Eigen/src/AutoDiff/CoherentPadOp.h b/unsupported/Eigen/src/AutoDiff/CoherentPadOp.h index 7d3a3fb36..0659e9ae2 100644 --- a/unsupported/Eigen/src/AutoDiff/CoherentPadOp.h +++ b/unsupported/Eigen/src/AutoDiff/CoherentPadOp.h @@ -50,13 +50,13 @@ struct CoherentPadOp : public dense_xpr_base::IsRowMajor ? Index(1) : size(); @@ -67,8 +67,8 @@ struct CoherentPadOp : public dense_xpr_base size_; + XprNested m_xpr; + const internal::variable_if_dynamic m_size; }; // Adapted from the Replicate evaluator. diff --git a/unsupported/Eigen/src/SparseExtra/RandomSetter.h b/unsupported/Eigen/src/SparseExtra/RandomSetter.h index 54b26461d..fab31f286 100644 --- a/unsupported/Eigen/src/SparseExtra/RandomSetter.h +++ b/unsupported/Eigen/src/SparseExtra/RandomSetter.h @@ -177,7 +177,7 @@ class RandomSetter { * a sparse matrix from scratch, then you must set it to zero first using the * 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 innerSize = SwapStorage ? target.outerSize() : target.innerSize(); m_outerPackets = outerSize >> OuterPacketBits; @@ -194,8 +194,8 @@ class RandomSetter { for (Index k = 0; k < m_outerPackets; ++k) MapTraits::setInvalidKey(m_hashmaps[k], ik); // insert current coeffs - for (Index j = 0; j < mp_target->outerSize(); ++j) - for (typename SparseMatrixType::InnerIterator it(*mp_target, j); it; ++it) + for (Index j = 0; j < m_target->outerSize(); ++j) + for (typename SparseMatrixType::InnerIterator it(*m_target, j); it; ++it) (*this)(TargetRowMajor ? j : it.index(), TargetRowMajor ? it.index() : j) = it.value(); } @@ -204,9 +204,9 @@ class RandomSetter { KeyType keyBitsMask = (1 << m_keyBitsOffset) - 1; if (!SwapStorage) // also means the map is sorted { - mp_target->setZero(); - mp_target->makeCompressed(); - mp_target->reserve(nonZeros()); + m_target->setZero(); + m_target->makeCompressed(); + m_target->reserve(nonZeros()); Index prevOuter = -1; for (Index k = 0; k < m_outerPackets; ++k) { const Index outerOffset = (1 << OuterPacketBits) * k; @@ -215,15 +215,15 @@ class RandomSetter { const Index outer = (it->first >> m_keyBitsOffset) + outerOffset; const Index inner = it->first & keyBitsMask; 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; } - mp_target->insertBackByOuterInner(outer, inner) = it->second.value; + m_target->insertBackByOuterInner(outer, inner) = it->second.value; } } - mp_target->finalize(); + m_target->finalize(); } else { - VectorXi positions(mp_target->outerSize()); + VectorXi positions(m_target->outerSize()); positions.setZero(); // pass 1 for (Index k = 0; k < m_outerPackets; ++k) { @@ -235,15 +235,15 @@ class RandomSetter { } // prefix sum 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]; - mp_target->outerIndexPtr()[j] = count; + m_target->outerIndexPtr()[j] = count; positions[j] = count; count += tmp; } - mp_target->makeCompressed(); - mp_target->outerIndexPtr()[mp_target->outerSize()] = count; - mp_target->resizeNonZeros(count); + m_target->makeCompressed(); + m_target->outerIndexPtr()[m_target->outerSize()] = count; + m_target->resizeNonZeros(count); // pass 2 for (Index k = 0; k < m_outerPackets; ++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, // 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: - Index posStart = mp_target->outerIndexPtr()[outer]; + Index posStart = m_target->outerIndexPtr()[outer]; Index i = (positions[outer]++) - 1; - while ((i >= posStart) && (mp_target->innerIndexPtr()[i] > inner)) { - mp_target->valuePtr()[i + 1] = mp_target->valuePtr()[i]; - mp_target->innerIndexPtr()[i + 1] = mp_target->innerIndexPtr()[i]; + while ((i >= posStart) && (m_target->innerIndexPtr()[i] > inner)) { + m_target->valuePtr()[i + 1] = m_target->valuePtr()[i]; + m_target->innerIndexPtr()[i + 1] = m_target->innerIndexPtr()[i]; --i; } - mp_target->innerIndexPtr()[i + 1] = internal::convert_index(inner); - mp_target->valuePtr()[i + 1] = it->second.value; + m_target->innerIndexPtr()[i + 1] = internal::convert_index(inner); + m_target->valuePtr()[i + 1] = it->second.value; } } } @@ -298,7 +298,7 @@ class RandomSetter { protected: HashMapType* m_hashmaps; - SparseMatrixType* mp_target; + SparseMatrixType* m_target; Index m_outerPackets; unsigned char m_keyBitsOffset; };