mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Add const to non-mutating member functions across remaining modules
libeigen/eigen!2222 Co-authored-by: Rasmus Munk Larsen <rmlarsen@gmail.com>
This commit is contained in:
@@ -33,7 +33,7 @@ struct vector_int_pair {
|
||||
// iterator range or using bounding_box in a unified way
|
||||
template <typename ObjectList, typename VolumeList, typename BoxIter>
|
||||
struct get_boxes_helper {
|
||||
void operator()(const ObjectList &objects, BoxIter boxBegin, BoxIter boxEnd, VolumeList &outBoxes) {
|
||||
void operator()(const ObjectList &objects, BoxIter boxBegin, BoxIter boxEnd, VolumeList &outBoxes) const {
|
||||
outBoxes.insert(outBoxes.end(), boxBegin, boxEnd);
|
||||
eigen_assert(outBoxes.size() == objects.size());
|
||||
EIGEN_ONLY_USED_FOR_DEBUG(objects);
|
||||
@@ -42,7 +42,7 @@ struct get_boxes_helper {
|
||||
|
||||
template <typename ObjectList, typename VolumeList>
|
||||
struct get_boxes_helper<ObjectList, VolumeList, int> {
|
||||
void operator()(const ObjectList &objects, int, int, VolumeList &outBoxes) {
|
||||
void operator()(const ObjectList &objects, int, int, VolumeList &outBoxes) const {
|
||||
outBoxes.reserve(objects.size());
|
||||
for (int i = 0; i < (int)objects.size(); ++i) outBoxes.push_back(bounding_box(objects[i]));
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ class DGMRES : public IterativeSolverBase<DGMRES<MatrixType_, Preconditioner_> >
|
||||
/**
|
||||
* Get the restart value
|
||||
*/
|
||||
Index restart() { return m_restart; }
|
||||
Index restart() const { return m_restart; }
|
||||
|
||||
/**
|
||||
* Set the restart value (default is 30)
|
||||
@@ -178,7 +178,7 @@ class DGMRES : public IterativeSolverBase<DGMRES<MatrixType_, Preconditioner_> >
|
||||
/**
|
||||
* Get the size of the deflation subspace size
|
||||
*/
|
||||
Index deflSize() { return m_r; }
|
||||
Index deflSize() const { return m_r; }
|
||||
|
||||
/**
|
||||
* Set the maximum size of the deflation subspace
|
||||
|
||||
@@ -291,7 +291,7 @@ class GMRES : public IterativeSolverBase<GMRES<MatrixType_, Preconditioner_> > {
|
||||
|
||||
/** Get the number of iterations after that a restart is performed.
|
||||
*/
|
||||
Index get_restart() { return m_restart; }
|
||||
Index get_restart() const { return m_restart; }
|
||||
|
||||
/** Set the number of iterations after that a restart is performed.
|
||||
* \param restart number of iterations for a restarti, default is 30.
|
||||
|
||||
@@ -185,22 +185,22 @@ class LevenbergMarquardt : internal::no_assignment_operator {
|
||||
FVectorType &diag() { return m_diag; }
|
||||
|
||||
/** \returns the number of iterations performed */
|
||||
Index iterations() { return m_iter; }
|
||||
Index iterations() const { return m_iter; }
|
||||
|
||||
/** \returns the number of functions evaluation */
|
||||
Index nfev() { return m_nfev; }
|
||||
Index nfev() const { return m_nfev; }
|
||||
|
||||
/** \returns the number of jacobian evaluation */
|
||||
Index njev() { return m_njev; }
|
||||
Index njev() const { return m_njev; }
|
||||
|
||||
/** \returns the norm of current vector function */
|
||||
RealScalar fnorm() { return m_fnorm; }
|
||||
RealScalar fnorm() const { return m_fnorm; }
|
||||
|
||||
/** \returns the norm of the gradient of the error */
|
||||
RealScalar gnorm() { return m_gnorm; }
|
||||
RealScalar gnorm() const { return m_gnorm; }
|
||||
|
||||
/** \returns the LevenbergMarquardt parameter */
|
||||
RealScalar lm_param(void) { return m_par; }
|
||||
RealScalar lm_param(void) const { return m_par; }
|
||||
|
||||
/** \returns a reference to the current vector function
|
||||
*/
|
||||
@@ -217,7 +217,7 @@ class LevenbergMarquardt : internal::no_assignment_operator {
|
||||
|
||||
/** the permutation used in the QR factorization
|
||||
*/
|
||||
PermutationType permutation() { return m_permutation; }
|
||||
PermutationType permutation() const { return m_permutation; }
|
||||
|
||||
/**
|
||||
* \brief Reports whether the minimization was successful
|
||||
|
||||
@@ -105,7 +105,7 @@ class LevenbergMarquardt {
|
||||
Scalar fnorm, gnorm;
|
||||
bool useExternalScaling;
|
||||
|
||||
Scalar lm_param(void) { return par; }
|
||||
Scalar lm_param(void) const { return par; }
|
||||
|
||||
private:
|
||||
FunctorType &functor;
|
||||
|
||||
@@ -146,14 +146,14 @@ class MatrixMarketIterator {
|
||||
|
||||
inline std::string& matname() { return m_matname; }
|
||||
|
||||
inline int sym() { return m_sym; }
|
||||
inline int sym() const { return m_sym; }
|
||||
|
||||
bool hasRhs() { return m_hasRhs; }
|
||||
bool hasrefX() { return m_hasrefX; }
|
||||
bool isFolderValid() { return bool(m_folder_id); }
|
||||
bool hasRhs() const { return m_hasRhs; }
|
||||
bool hasrefX() const { return m_hasrefX; }
|
||||
bool isFolderValid() const { return bool(m_folder_id); }
|
||||
|
||||
protected:
|
||||
inline bool Fileexists(std::string file) {
|
||||
inline bool Fileexists(std::string file) const {
|
||||
std::ifstream file_id(file.c_str());
|
||||
if (!file_id.good()) {
|
||||
return false;
|
||||
|
||||
@@ -38,7 +38,7 @@ class KahanSum {
|
||||
Scalar _correction{};
|
||||
|
||||
public:
|
||||
Scalar value() { return _sum; }
|
||||
Scalar value() const { return _sum; }
|
||||
|
||||
void operator+=(Scalar increment) {
|
||||
const Scalar correctedIncrement = increment + _correction;
|
||||
@@ -59,7 +59,7 @@ class FABSum {
|
||||
Index _blockUsed{};
|
||||
|
||||
public:
|
||||
Scalar value() { return _block.topRows(_blockUsed).sum() + _totalSum.value(); }
|
||||
Scalar value() const { return _block.topRows(_blockUsed).sum() + _totalSum.value(); }
|
||||
|
||||
void operator+=(Scalar increment) {
|
||||
_block(_blockUsed++, 0) = increment;
|
||||
|
||||
@@ -281,7 +281,7 @@ struct TensorEvaluator<const TensorContractionOp<Indices, LeftArgType, RightArgT
|
||||
// Dummy struct to represent an empty DoneCallback.
|
||||
|
||||
struct NoCallback {
|
||||
void operator()() { eigen_assert(false && "NoCallback should never be called"); }
|
||||
void operator()() const { eigen_assert(false && "NoCallback should never be called"); }
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------ //
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace internal {
|
||||
template <typename Device, typename CoeffReturnType>
|
||||
struct non_integral_type_placement_new {
|
||||
template <typename StorageType>
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void operator()(Index numValues, StorageType m_buffer) {
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void operator()(Index numValues, StorageType m_buffer) const {
|
||||
// Initialize non-trivially constructible types.
|
||||
if (!internal::is_arithmetic<CoeffReturnType>::value) {
|
||||
for (Index i = 0; i < numValues; ++i) new (m_buffer + i) CoeffReturnType();
|
||||
@@ -86,7 +86,7 @@ struct non_integral_type_placement_new {
|
||||
template <typename CoeffReturnType>
|
||||
struct non_integral_type_placement_new<Eigen::SyclDevice, CoeffReturnType> {
|
||||
template <typename StorageType>
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void operator()(Index, StorageType) {}
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void operator()(Index, StorageType) const {}
|
||||
};
|
||||
} // end namespace internal
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ EIGEN_STRONG_INLINE void ReducePacket(Self& self, Index offset, typename Self::C
|
||||
|
||||
template <typename Self, bool Vectorize, bool Parallel>
|
||||
struct ReduceBlock {
|
||||
EIGEN_STRONG_INLINE void operator()(Self& self, Index idx1, typename Self::CoeffReturnType* data) {
|
||||
EIGEN_STRONG_INLINE void operator()(Self& self, Index idx1, typename Self::CoeffReturnType* data) const {
|
||||
for (Index idx2 = 0; idx2 < self.stride(); idx2++) {
|
||||
// Calculate the starting offset for the scan
|
||||
Index offset = idx1 + idx2;
|
||||
@@ -155,7 +155,7 @@ struct ReduceBlock {
|
||||
// Specialization for vectorized reduction.
|
||||
template <typename Self>
|
||||
struct ReduceBlock<Self, /*Vectorize=*/true, /*Parallel=*/false> {
|
||||
EIGEN_STRONG_INLINE void operator()(Self& self, Index idx1, typename Self::CoeffReturnType* data) {
|
||||
EIGEN_STRONG_INLINE void operator()(Self& self, Index idx1, typename Self::CoeffReturnType* data) const {
|
||||
using Packet = typename Self::PacketReturnType;
|
||||
const int PacketSize = internal::unpacket_traits<Packet>::size;
|
||||
Index idx2 = 0;
|
||||
@@ -204,7 +204,7 @@ EIGEN_STRONG_INLINE Index AdjustBlockSize(Index item_size, Index block_size) {
|
||||
|
||||
template <typename Self>
|
||||
struct ReduceBlock<Self, /*Vectorize=*/true, /*Parallel=*/true> {
|
||||
EIGEN_STRONG_INLINE void operator()(Self& self, Index idx1, typename Self::CoeffReturnType* data) {
|
||||
EIGEN_STRONG_INLINE void operator()(Self& self, Index idx1, typename Self::CoeffReturnType* data) const {
|
||||
using Scalar = typename Self::CoeffReturnType;
|
||||
using Packet = typename Self::PacketReturnType;
|
||||
const int PacketSize = internal::unpacket_traits<Packet>::size;
|
||||
@@ -243,7 +243,7 @@ struct ReduceBlock<Self, /*Vectorize=*/true, /*Parallel=*/true> {
|
||||
|
||||
template <typename Self>
|
||||
struct ReduceBlock<Self, /*Vectorize=*/false, /*Parallel=*/true> {
|
||||
EIGEN_STRONG_INLINE void operator()(Self& self, Index idx1, typename Self::CoeffReturnType* data) {
|
||||
EIGEN_STRONG_INLINE void operator()(Self& self, Index idx1, typename Self::CoeffReturnType* data) const {
|
||||
using Scalar = typename Self::CoeffReturnType;
|
||||
self.device().parallelFor(
|
||||
self.stride(), TensorOpCost(self.size(), self.size(), 16 * self.size()),
|
||||
@@ -261,7 +261,7 @@ struct ReduceBlock<Self, /*Vectorize=*/false, /*Parallel=*/true> {
|
||||
// Specialization for multi-threaded execution.
|
||||
template <typename Self, typename Reducer, bool Vectorize>
|
||||
struct ScanLauncher<Self, Reducer, ThreadPoolDevice, Vectorize> {
|
||||
void operator()(Self& self, typename Self::CoeffReturnType* data) {
|
||||
void operator()(Self& self, typename Self::CoeffReturnType* data) const {
|
||||
using Scalar = typename Self::CoeffReturnType;
|
||||
using Packet = typename Self::PacketReturnType;
|
||||
const int PacketSize = internal::unpacket_traits<Packet>::size;
|
||||
@@ -333,7 +333,7 @@ __global__ EIGEN_HIP_LAUNCH_BOUNDS_1024 void ScanKernel(Self self, Index total_s
|
||||
|
||||
template <typename Self, typename Reducer, bool Vectorize>
|
||||
struct ScanLauncher<Self, Reducer, GpuDevice, Vectorize> {
|
||||
void operator()(const Self& self, typename Self::CoeffReturnType* data) {
|
||||
void operator()(const Self& self, typename Self::CoeffReturnType* data) const {
|
||||
Index total_size = internal::array_prod(self.dimensions());
|
||||
Index num_blocks = (total_size / self.size() + 63) / 64;
|
||||
Index block_size = 64;
|
||||
|
||||
Reference in New Issue
Block a user