Skip to content

Commit 152b17b

Browse files
committed
Address some common compiler warnings.
This implements some clean-ups that address some compiler warnings. Principal among these are more consistent uses of size_t for values which are related to the sizes of containers. Along the way, where it was straightforward to do so, some passages were re-written to avoid signed/un-signed comparisons by using instead STL algorithms and idioms.
1 parent 7381f3e commit 152b17b

60 files changed

Lines changed: 527 additions & 846 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/core/function.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ using namespace Gambit;
4646
void FunctionOnSimplices::Project(Vector<double> &x, const Array<int> &lengths) const
4747
{
4848
int index = 1;
49-
for (int part = 1; part <= lengths.size(); part++) {
49+
for (size_t part = 1; part <= lengths.size(); part++) {
5050
double avg = 0.0;
5151
int j;
5252
for (j = 1; j <= lengths[part]; j++, index++) {
@@ -70,7 +70,7 @@ void FunctionOnSimplices::Project(Vector<double> &x, const Array<int> &lengths)
7070

7171
void ConjugatePRMinimizer::AlphaXPlusY(double alpha, const Vector<double> &x, Vector<double> &y)
7272
{
73-
for (int i = 1; i <= y.size(); i++) {
73+
for (size_t i = 1; i <= y.size(); i++) {
7474
y[i] += alpha * x[i];
7575
}
7676
}

src/core/matrix.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,10 @@ template <class T> class Matrix : public RectArray<T> {
8080
Matrix<T> operator*(const Matrix<T> &) const;
8181
Vector<T> operator*(const Vector<T> &) const;
8282
Matrix<T> operator*(const T &) const;
83-
Matrix<T> &operator*=(const Matrix<T> &);
8483
Matrix<T> &operator*=(const T &);
8584

8685
Matrix<T> operator/(const T &) const;
8786
Matrix<T> &operator/=(const T &);
88-
89-
/// Kronecker product
90-
Matrix<T> operator&(const Matrix<T> &) const;
9187
//@
9288

9389
/// @name Other operations

src/core/matrix.imp

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -253,26 +253,6 @@ template <class T> Matrix<T> Matrix<T>::operator*(const T &s) const
253253
return tmp;
254254
}
255255

256-
// in-place multiplication by square matrix
257-
template <class T> Matrix<T> &Matrix<T>::operator*=(const Matrix<T> &M)
258-
{
259-
if (this->mincol != M.minrow || this->maxcol != M.maxrow) {
260-
throw DimensionException();
261-
}
262-
if (M.minrow != M.mincol || M.maxrow != M.maxcol) {
263-
throw DimensionException();
264-
}
265-
266-
Vector<T> row(this->mincol, this->maxcol);
267-
Vector<T> result(this->mincol, this->maxcol);
268-
for (int i = this->minrow; i <= this->maxrow; i++) {
269-
this->GetRow(i, row);
270-
M.RMultiply(row, result);
271-
this->SetRow(i, result);
272-
}
273-
return (*this);
274-
}
275-
276256
template <class T> Matrix<T> &Matrix<T>::operator*=(const T &s)
277257
{
278258
for (int i = this->minrow; i <= this->maxrow; i++) {
@@ -281,7 +261,6 @@ template <class T> Matrix<T> &Matrix<T>::operator*=(const T &s)
281261
while (j--) {
282262
*(dst++) *= s;
283263
}
284-
// assert((dst - 1) == this->data[i] + this->maxcol);
285264
}
286265
return (*this);
287266
}
@@ -300,7 +279,6 @@ template <class T> Matrix<T> Matrix<T>::operator/(const T &s) const
300279
while (j--) {
301280
*(dst++) = *(src++) / s;
302281
}
303-
// assert((src - 1) == this->data[i] + this->maxcol);
304282
}
305283
return tmp;
306284
}
@@ -317,35 +295,10 @@ template <class T> Matrix<T> &Matrix<T>::operator/=(const T &s)
317295
while (j--) {
318296
*(dst++) /= s;
319297
}
320-
// assert((dst - 1) == this->data[i] + this->maxcol);
321298
}
322299
return (*this);
323300
}
324301

325-
//-------------------------------------------------------------------------
326-
// Matrix<T>: Kronecker Product
327-
//-------------------------------------------------------------------------
328-
329-
template <class T> Matrix<T> Matrix<T>::operator&(const Matrix<T> &M) const
330-
{
331-
Matrix<T> tmp(1, (this->maxrow - this->minrow + 1) * (M.maxrow - M.minrow + 1), 1,
332-
(this->maxcol - this->mincol + 1) * (M.maxcol - M.mincol + 1));
333-
334-
for (int i = 0; i <= this->maxrow - this->minrow; i++) {
335-
for (int j = 1; j <= M.maxrow - M.minrow + 1; j++) {
336-
for (int k = 0; k <= this->maxcol - this->mincol; k++) {
337-
for (int l = 1; l <= M.maxcol - M.mincol + 1; l++) {
338-
339-
tmp((M.maxrow - M.minrow + 1) * i + j, (M.maxcol - M.mincol + 1) * k + l) =
340-
(*this)(i + this->minrow, k + this->mincol) * M(j + M.minrow - 1, l + M.mincol - 1);
341-
}
342-
}
343-
}
344-
}
345-
346-
return tmp;
347-
}
348-
349302
//-------------------------------------------------------------------------
350303
// Matrix<T>: Transpose
351304
//-------------------------------------------------------------------------

0 commit comments

Comments
 (0)