Skip to content

Commit 0e3ab6f

Browse files
committed
Addressing LTO warnings.
1 parent f5fdcbd commit 0e3ab6f

6 files changed

Lines changed: 11 additions & 12 deletions

File tree

src/cpp11.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ extern "C" SEXP _ernest_logspace_cumsum_mat(SEXP x) {
2727
END_CPP11
2828
}
2929
// propose-impl.cpp
30-
cpp11::list RandomWalkImpl(cpp11::doubles original, cpp11::function unit_log_fn, double criterion, int steps, double epsilon);
30+
cpp11::list RandomWalkImpl(cpp11::doubles original, cpp11::function unit_log_fn, double criterion, unsigned int steps, double epsilon);
3131
extern "C" SEXP _ernest_RandomWalkImpl(SEXP original, SEXP unit_log_fn, SEXP criterion, SEXP steps, SEXP epsilon) {
3232
BEGIN_CPP11
33-
return cpp11::as_sexp(RandomWalkImpl(cpp11::as_cpp<cpp11::decay_t<cpp11::doubles>>(original), cpp11::as_cpp<cpp11::decay_t<cpp11::function>>(unit_log_fn), cpp11::as_cpp<cpp11::decay_t<double>>(criterion), cpp11::as_cpp<cpp11::decay_t<int>>(steps), cpp11::as_cpp<cpp11::decay_t<double>>(epsilon)));
33+
return cpp11::as_sexp(RandomWalkImpl(cpp11::as_cpp<cpp11::decay_t<cpp11::doubles>>(original), cpp11::as_cpp<cpp11::decay_t<cpp11::function>>(unit_log_fn), cpp11::as_cpp<cpp11::decay_t<double>>(criterion), cpp11::as_cpp<cpp11::decay_t<unsigned int>>(steps), cpp11::as_cpp<cpp11::decay_t<double>>(epsilon)));
3434
END_CPP11
3535
}
3636
// propose-impl.cpp
37-
cpp11::list SliceImpl(cpp11::doubles original, cpp11::function unit_log_fn, double criterion, cpp11::doubles lower, cpp11::doubles upper, const int max_loop);
37+
cpp11::list SliceImpl(cpp11::doubles original, cpp11::function unit_log_fn, double criterion, cpp11::doubles lower, cpp11::doubles upper, unsigned int max_loop);
3838
extern "C" SEXP _ernest_SliceImpl(SEXP original, SEXP unit_log_fn, SEXP criterion, SEXP lower, SEXP upper, SEXP max_loop) {
3939
BEGIN_CPP11
40-
return cpp11::as_sexp(SliceImpl(cpp11::as_cpp<cpp11::decay_t<cpp11::doubles>>(original), cpp11::as_cpp<cpp11::decay_t<cpp11::function>>(unit_log_fn), cpp11::as_cpp<cpp11::decay_t<double>>(criterion), cpp11::as_cpp<cpp11::decay_t<cpp11::doubles>>(lower), cpp11::as_cpp<cpp11::decay_t<cpp11::doubles>>(upper), cpp11::as_cpp<cpp11::decay_t<const int>>(max_loop)));
40+
return cpp11::as_sexp(SliceImpl(cpp11::as_cpp<cpp11::decay_t<cpp11::doubles>>(original), cpp11::as_cpp<cpp11::decay_t<cpp11::function>>(unit_log_fn), cpp11::as_cpp<cpp11::decay_t<double>>(criterion), cpp11::as_cpp<cpp11::decay_t<cpp11::doubles>>(lower), cpp11::as_cpp<cpp11::decay_t<cpp11::doubles>>(upper), cpp11::as_cpp<cpp11::decay_t<unsigned int>>(max_loop)));
4141
END_CPP11
4242
}
4343
// update_lrps-impl.cpp

src/ellipsoid.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ std::list<Ellipsoid> vol::Ellipsoid::Split(const ConstRef<Matrix> X,
213213
}
214214

215215
// BASE CASE 1: Clusters too small to split
216-
if (idx0.size() < 2 * nvar_ || idx1.size() < 2 * nvar_) {
216+
unsigned int twice_nvar = 2 * nvar_;
217+
if (idx0.size() < twice_nvar || idx1.size() < twice_nvar) {
217218
return {*this};
218219
}
219220

src/propose-impl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// Proposal: X' ~ N(X_n, ε I).
1515
[[cpp11::register]]
1616
cpp11::list RandomWalkImpl(cpp11::doubles original, cpp11::function unit_log_fn,
17-
double criterion, int steps, double epsilon) {
17+
double criterion, unsigned int steps, double epsilon) {
1818
const int nvar = original.size();
1919
ern::RandomEngine rng;
2020

@@ -47,7 +47,7 @@ cpp11::list RandomWalkImpl(cpp11::doubles original, cpp11::function unit_log_fn,
4747
[[cpp11::register]]
4848
cpp11::list SliceImpl(cpp11::doubles original, cpp11::function unit_log_fn,
4949
double criterion, cpp11::doubles lower, cpp11::doubles upper,
50-
const int max_loop) {
50+
unsigned int max_loop) {
5151
// Setups
5252
vol::Rectangle rect(lower, upper);
5353
Eigen::VectorXd next_draw = as_Matrix(original);

src/rectangle.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace vol {
1616
class Rectangle {
1717
public:
1818
// Construct the (0-1) unit hypercube.
19-
inline explicit Rectangle(const int nvar)
19+
inline explicit Rectangle(const unsigned int nvar)
2020
: nvar_(nvar),
2121
lower_(Eigen::ArrayXd::Zero(nvar_)),
2222
upper_(Eigen::ArrayXd::Ones(nvar_)) {};
@@ -70,7 +70,7 @@ class Rectangle {
7070
inline Vector upper() const { return upper_; }
7171

7272
private:
73-
int nvar_; // Number of dimensions
73+
unsigned int nvar_; // Number of dimensions
7474
Eigen::ArrayXd lower_; // Lower bounds of the rectangle axes.
7575
Eigen::ArrayXd upper_; // Upper bounds of the rectangle axes.
7676
ern::RandomEngine gen; // Random number generator.

src/test-bounding.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ context("Ellipsoid class - basic functionality") {
7575
expect_true(ern::isZero(err_in, 1e-3));
7676
expect_true(ern::isZero(err_out, 1e-3));
7777
}
78-
79-
Eigen::Matrix2d shape = Eigen::Matrix2d::Identity();
8078
}
8179

8280
context("Ellipsoid class - geometric cases") {

src/utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ inline bool IsOutsideUnitCube(ConstRef<RowVector> vec) {
6868

6969
// Reflects components of `vec` to ensure all lie within the unit cube [0,1]^d.
7070
inline void ReflectWithinUnitCube(Ref<RowVector> vec) {
71-
for (size_t i = 0; i < vec.size(); ++i) {
71+
for (long int i = 0; i < vec.size(); ++i) {
7272
double val = vec[i];
7373
bool idx_even = std::fmod(val, 2.0) < 1.0;
7474
if (idx_even) {

0 commit comments

Comments
 (0)