Skip to content

Commit 2596bb4

Browse files
authored
Tidy up compiler warnings (#824)
1 parent 6df83b8 commit 2596bb4

6 files changed

Lines changed: 18 additions & 14 deletions

File tree

MANIFEST.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
recursive-include src/core *.cc *.h *.imp
1+
recursive-include src/core *.cc *.h
22
recursive-include src/games *.cc *.h *.imp
3-
recursive-include src/solvers *.c *.cc *.h *.imp
3+
recursive-include src/solvers *.cc *.h *.imp
44
recursive-include catalog *
55
include src/gambit.h
66
include src/pygambit/*.pxd

src/core/function.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ void FunctionOnSimplices::Project(Vector<double> &x, const Array<size_t> &length
4848
int index = 1;
4949
for (size_t part = 1; part <= lengths.size(); part++) {
5050
double avg = 0.0;
51-
int j;
51+
size_t j;
5252
for (j = 1; j <= lengths[part]; j++, index++) {
5353
avg += x[index];
5454
}
55-
avg /= (double)lengths[part];
55+
avg /= static_cast<double>(lengths[part]);
5656
index -= lengths[part];
5757
for (j = 1; j <= lengths[part]; j++, index++) {
5858
x[index] -= avg;

src/core/matrix.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ template <class T> class Matrix {
8686
/// @brief Highest valid column index
8787
int MaxCol() const { return m_data.MaxCol(); }
8888
/// @brief Number of rows in the matrix
89-
int NumRows() const { return m_data.NumRows(); }
89+
size_t NumRows() const { return m_data.NumRows(); }
9090
/// @brief Number of columns in the matrix
91-
int NumColumns() const { return m_data.NumColumns(); }
91+
size_t NumColumns() const { return m_data.NumColumns(); }
9292

9393
/// @brief Check if the matrix is a square matrix (num rows == num columns)
9494
bool IsSquare() const { return MinRow() == MinCol() && MaxRow() == MaxCol(); }

src/games/gamebagg.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ template <class T> T BAGGMixedStrategyProfileRep<T>::GetPayoff(int pl) const
108108
bplayer = i;
109109
btype = tp;
110110
}
111-
for (int j = 0; j < ns[g.baggPtr->typeOffset[i] + tp]; ++j, ++offs) {
111+
for (size_t j = 0; j < ns[g.baggPtr->typeOffset[i] + tp]; ++j, ++offs) {
112112
const GameStrategy strategy = this->m_support.GetGame()
113113
->GetPlayer(g.baggPtr->typeOffset[i] + tp + 1)
114114
->GetStrategy(j + 1);

src/solvers/nashsupport/nfgsupport.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ void GenerateSupportProfiles(const Game &game,
201201

202202
/// Solve over supports with a total number of strategies `size` and a maximum difference
203203
/// in player support size of `diff`.
204-
void GenerateSizeDiff(const Game &game, int size, int diff, CallbackFunction callback)
204+
void GenerateSizeDiff(const Game &game, int size, size_t diff, CallbackFunction callback)
205205
{
206206
auto players = game->GetPlayers();
207207
CartesianRange range(game->GetStrategies().shape_array());

src/solvers/simpdiv/simpdiv.cc

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,16 @@ Rational NashSimpdivStrategySolver::Simplex(MixedStrategyProfile<Rational> &y,
105105
v.SetFlattened(y.GetProbVector());
106106
besty.SetFlattened(y.GetProbVector());
107107
int i = 0;
108-
int j, k, h, jj, hh, ii, kk, tot;
108+
int jj, ii;
109+
size_t j, h, hh, tot, k, kk;
109110
Rational maxz;
110111

111112
// Label step0 not currently used, hence commented
112113
// step0:
113114
TT = 0;
114115
U = 0;
115116
ab = Rational(0);
116-
for (j = 1; j <= static_cast<int>(game->NumPlayers()); j++) {
117+
for (j = 1; j <= game->NumPlayers(); j++) {
117118
const GamePlayer player = game->GetPlayer(j);
118119
for (h = 1; h <= nstrats[j]; h++) {
119120
if (v.segment(j)[h] == Rational(0)) {
@@ -149,7 +150,8 @@ Rational NashSimpdivStrategySolver::Simplex(MixedStrategyProfile<Rational> &y,
149150
/* case1b */
150151
else if (TT.segment(j)[h]) {
151152
i = 1;
152-
while (labels(i, 1) != j || labels(i, 2) != h || i == state.ibar) {
153+
while (labels(i, 1) != static_cast<int>(j) || labels(i, 2) != static_cast<int>(h) ||
154+
i == state.ibar) {
153155
i++;
154156
}
155157
goto step3;
@@ -168,7 +170,8 @@ Rational NashSimpdivStrategySolver::Simplex(MixedStrategyProfile<Rational> &y,
168170
}
169171
else {
170172
i = 1;
171-
while ((pi(i, 1) != j || pi(i, 2) != k) && i <= state.t) {
173+
while ((pi(i, 1) != static_cast<int>(j) || pi(i, 2) != static_cast<int>(k)) &&
174+
i <= state.t) {
172175
i++;
173176
}
174177
}
@@ -293,7 +296,7 @@ Rational NashSimpdivStrategySolver::Simplex(MixedStrategyProfile<Rational> &y,
293296
pi.RotateUp(i - 1, state.t);
294297
state.t--;
295298
ii = 1;
296-
while (labels(ii, 1) != j || labels(ii, 2) != h) {
299+
while (labels(ii, 1) != static_cast<int>(j) || labels(ii, 2) != static_cast<int>(h)) {
297300
ii++;
298301
}
299302
i = ii;
@@ -339,7 +342,8 @@ void NashSimpdivStrategySolver::update(State &state, RectArray<int> &pi, RectArr
339342
SegmentedVector<Rational> &ab,
340343
const SegmentedVector<int> &U, int j, int i)
341344
{
342-
int jj, hh, k, f = 1;
345+
int jj, f = 1;
346+
size_t k, hh;
343347

344348
if (i >= 2 && i <= state.t) {
345349
pi.SwitchRows(i, i - 1);

0 commit comments

Comments
 (0)