From 6f4fca7efbf51a818d7ec63eab121ec5675b2376 Mon Sep 17 00:00:00 2001 From: PaddleStroke Date: Thu, 16 Nov 2023 21:32:13 +0100 Subject: [PATCH] Werner compil warning (#32) * Replace int by size_t in for loops. * Various dtor missing and some other warning fixes. * fixed size_t vs int * fixed size_t vs int --------- Co-authored-by: Paddle Co-authored-by: Aik-Siong Koh --- OndselSolver/ASMTAssembly.cpp | 4 +-- OndselSolver/ASMTItem.cpp | 2 +- OndselSolver/ASMTItem.h | 3 ++- OndselSolver/ASMTItemIJ.cpp | 12 ++++----- OndselSolver/ASMTSpatialContainer.cpp | 36 +++++++++++++-------------- OndselSolver/Array.h | 17 +++++++------ OndselSolver/DiagonalMatrix.cpp | 10 ++++---- OndselSolver/DifferenceOperator.cpp | 2 +- OndselSolver/DifferenceOperator.h | 1 + OndselSolver/FullColumn.cpp | 12 ++++----- OndselSolver/FullColumn.h | 2 +- OndselSolver/FullMatrix.cpp | 30 +++++++++++----------- OndselSolver/FullRow.cpp | 2 +- OndselSolver/FullRow.h | 6 ++--- OndselSolver/FullVector.h | 22 ++++++++-------- OndselSolver/FunctionWithManyArgs.cpp | 2 +- OndselSolver/GeneralSpline.cpp | 4 +-- OndselSolver/Item.h | 1 + OndselSolver/MBDynItem.h | 1 + OndselSolver/MBDynSystem.cpp | 4 +-- OndselSolver/MarkerFrame.cpp | 2 +- OndselSolver/MatrixSolver.h | 1 + OndselSolver/Numeric.h | 2 +- OndselSolver/PiecewiseFunction.cpp | 8 +++--- OndselSolver/Polynomial.cpp | 12 ++++----- OndselSolver/Product.cpp | 6 ++--- OndselSolver/RowTypeMatrix.h | 4 +-- OndselSolver/Solver.h | 1 + OndselSolver/SparseMatrix.h | 16 ++++++------ OndselSolver/SparseRow.h | 6 ++--- OndselSolver/SparseVector.h | 1 + OndselSolver/Sum.cpp | 4 +-- OndselSolver/Symbolic.h | 1 + OndselSolver/SymbolicParser.cpp | 2 +- OndselSolver/System.cpp | 2 +- 35 files changed, 125 insertions(+), 116 deletions(-) diff --git a/OndselSolver/ASMTAssembly.cpp b/OndselSolver/ASMTAssembly.cpp index ac0edfb..f409fa8 100644 --- a/OndselSolver/ASMTAssembly.cpp +++ b/OndselSolver/ASMTAssembly.cpp @@ -1215,13 +1215,13 @@ void MbD::ASMTAssembly::storeOnTimeSeries(std::ofstream& os) if (times->empty()) return; os << "TimeSeries" << std::endl; os << "Number\tInput\t"; - for (int i = 1; i < times->size(); i++) + for (size_t i = 1; i < times->size(); i++) { os << i << '\t'; } os << std::endl; os << "Time\tInput\t"; - for (int i = 1; i < times->size(); i++) + for (size_t i = 1; i < times->size(); i++) { os << times->at(i) << '\t'; } diff --git a/OndselSolver/ASMTItem.cpp b/OndselSolver/ASMTItem.cpp index 29ccdf6..3bb3df4 100644 --- a/OndselSolver/ASMTItem.cpp +++ b/OndselSolver/ASMTItem.cpp @@ -220,7 +220,7 @@ void MbD::ASMTItem::storeOnLevelBool(std::ofstream& os, int level, bool value) void MbD::ASMTItem::storeOnLevelArray(std::ofstream& os, int level, std::vector array) { storeOnLevelTabs(os, level); - for (int i = 0; i < array.size(); i++) + for (size_t i = 0; i < array.size(); i++) { os << array[i] << '\t'; } diff --git a/OndselSolver/ASMTItem.h b/OndselSolver/ASMTItem.h index 9fe9489..2836df7 100644 --- a/OndselSolver/ASMTItem.h +++ b/OndselSolver/ASMTItem.h @@ -20,6 +20,7 @@ namespace MbD { { // public: + virtual ~ASMTItem() {} virtual ASMTAssembly* root(); virtual ASMTSpatialContainer* partOrAssembly(); virtual ASMTPart* part(); @@ -64,7 +65,7 @@ namespace MbD { //inline void ASMTItem::storeOnLevelArray(std::ofstream& os, int level, std::vector array) //{ // storeOnLevelTabs(os, level); - // for (int i = 0; i < array.size(); i++) + // for (size_t i = 0; i < array.size(); i++) // { // os << array[i] << '\t'; // } diff --git a/OndselSolver/ASMTItemIJ.cpp b/OndselSolver/ASMTItemIJ.cpp index de459aa..4da6829 100644 --- a/OndselSolver/ASMTItemIJ.cpp +++ b/OndselSolver/ASMTItemIJ.cpp @@ -108,37 +108,37 @@ void MbD::ASMTItemIJ::storeOnLevel(std::ofstream& os, int level) void MbD::ASMTItemIJ::storeOnTimeSeries(std::ofstream& os) { os << "FXonI\t"; - for (int i = 0; i < fxs->size(); i++) + for (size_t i = 0; i < fxs->size(); i++) { os << fxs->at(i) << '\t'; } os << std::endl; os << "FYonI\t"; - for (int i = 0; i < fys->size(); i++) + for (size_t i = 0; i < fys->size(); i++) { os << fys->at(i) << '\t'; } os << std::endl; os << "FZonI\t"; - for (int i = 0; i < fzs->size(); i++) + for (size_t i = 0; i < fzs->size(); i++) { os << fzs->at(i) << '\t'; } os << std::endl; os << "TXonI\t"; - for (int i = 0; i < txs->size(); i++) + for (size_t i = 0; i < txs->size(); i++) { os << txs->at(i) << '\t'; } os << std::endl; os << "TYonI\t"; - for (int i = 0; i < tys->size(); i++) + for (size_t i = 0; i < tys->size(); i++) { os << tys->at(i) << '\t'; } os << std::endl; os << "TZonI\t"; - for (int i = 0; i < tzs->size(); i++) + for (size_t i = 0; i < tzs->size(); i++) { os << tzs->at(i) << '\t'; } diff --git a/OndselSolver/ASMTSpatialContainer.cpp b/OndselSolver/ASMTSpatialContainer.cpp index 0bd509d..fad29a2 100644 --- a/OndselSolver/ASMTSpatialContainer.cpp +++ b/OndselSolver/ASMTSpatialContainer.cpp @@ -601,109 +601,109 @@ void MbD::ASMTSpatialContainer::storeOnLevelRefSurfaces(std::ofstream& os, int l void MbD::ASMTSpatialContainer::storeOnTimeSeries(std::ofstream& os) { os << "X\t"; - for (int i = 0; i < xs->size(); i++) + for (size_t i = 0; i < xs->size(); i++) { os << xs->at(i) << '\t'; } os << std::endl; os << "Y\t"; - for (int i = 0; i < ys->size(); i++) + for (size_t i = 0; i < ys->size(); i++) { os << ys->at(i) << '\t'; } os << std::endl; os << "Z\t"; - for (int i = 0; i < zs->size(); i++) + for (size_t i = 0; i < zs->size(); i++) { os << zs->at(i) << '\t'; } os << std::endl; os << "Bryantx\t"; - for (int i = 0; i < bryxs->size(); i++) + for (size_t i = 0; i < bryxs->size(); i++) { os << bryxs->at(i) << '\t'; } os << std::endl; os << "Bryanty\t"; - for (int i = 0; i < bryys->size(); i++) + for (size_t i = 0; i < bryys->size(); i++) { os << bryys->at(i) << '\t'; } os << std::endl; os << "Bryantz\t"; - for (int i = 0; i < bryzs->size(); i++) + for (size_t i = 0; i < bryzs->size(); i++) { os << bryzs->at(i) << '\t'; } os << std::endl; os << "VX\t"; - for (int i = 0; i < vxs->size(); i++) + for (size_t i = 0; i < vxs->size(); i++) { os << vxs->at(i) << '\t'; } os << std::endl; os << "VY\t"; - for (int i = 0; i < vys->size(); i++) + for (size_t i = 0; i < vys->size(); i++) { os << vys->at(i) << '\t'; } os << std::endl; os << "VZ\t"; - for (int i = 0; i < vzs->size(); i++) + for (size_t i = 0; i < vzs->size(); i++) { os << vzs->at(i) << '\t'; } os << std::endl; os << "OmegaX\t"; - for (int i = 0; i < omexs->size(); i++) + for (size_t i = 0; i < omexs->size(); i++) { os << omexs->at(i) << '\t'; } os << std::endl; os << "OmegaY\t"; - for (int i = 0; i < omeys->size(); i++) + for (size_t i = 0; i < omeys->size(); i++) { os << omeys->at(i) << '\t'; } os << std::endl; os << "OmegaZ\t"; - for (int i = 0; i < omezs->size(); i++) + for (size_t i = 0; i < omezs->size(); i++) { os << omezs->at(i) << '\t'; } os << std::endl; os << "AX\t"; - for (int i = 0; i < axs->size(); i++) + for (size_t i = 0; i < axs->size(); i++) { os << axs->at(i) << '\t'; } os << std::endl; os << "AY\t"; - for (int i = 0; i < ays->size(); i++) + for (size_t i = 0; i < ays->size(); i++) { os << ays->at(i) << '\t'; } os << std::endl; os << "AZ\t"; - for (int i = 0; i < azs->size(); i++) + for (size_t i = 0; i < azs->size(); i++) { os << azs->at(i) << '\t'; } os << std::endl; os << "AlphaX\t"; - for (int i = 0; i < alpxs->size(); i++) + for (size_t i = 0; i < alpxs->size(); i++) { os << alpxs->at(i) << '\t'; } os << std::endl; os << "AlphaY\t"; - for (int i = 0; i < alpys->size(); i++) + for (size_t i = 0; i < alpys->size(); i++) { os << alpys->at(i) << '\t'; } os << std::endl; os << "AlphaZ\t"; - for (int i = 0; i < alpzs->size(); i++) + for (size_t i = 0; i < alpzs->size(); i++) { os << alpzs->at(i) << '\t'; } diff --git a/OndselSolver/Array.h b/OndselSolver/Array.h index 15dc4f5..890c0bc 100644 --- a/OndselSolver/Array.h +++ b/OndselSolver/Array.h @@ -31,6 +31,7 @@ namespace MbD { Array(int count, const T& value) : std::vector(count, value) {} Array(typename std::vector::iterator begin, typename std::vector::iterator end) : std::vector(begin, end) {} Array(std::initializer_list list) : std::vector{ list } {} + virtual ~Array() {} virtual void initialize(); void copyFrom(std::shared_ptr> x); virtual void zeroSelf(); @@ -65,14 +66,14 @@ namespace MbD { template inline void Array::copyFrom(std::shared_ptr> x) { - for (int i = 0; i < x->size(); i++) { + for (size_t i = 0; i < x->size(); i++) { this->at(i) = x->at(i); } } template inline void Array::zeroSelf() { - for (int i = 0; i < this->size(); i++) { + for (size_t i = 0; i < this->size(); i++) { this->at(i) = (T)0; } } @@ -97,7 +98,7 @@ namespace MbD { //inline double Array::maxMagnitude() //{ // double max = 0.0; - // for (int i = 0; i < this->size(); i++) + // for (size_t i = 0; i < this->size(); i++) // { // auto element = this->at(i); // if (element < 0.0) element = -element; @@ -109,7 +110,7 @@ namespace MbD { inline double Array::maxMagnitudeOfVector() { double answer = 0.0; - for (int i = 0; i < this->size(); i++) + for (size_t i = 0; i < this->size(); i++) { double mag = std::abs(this->at(i)); if (answer < mag) answer = mag; @@ -119,7 +120,7 @@ namespace MbD { template inline void Array::equalArrayAt(std::shared_ptr> array, int i) { - for (int ii = 0; ii < this->size(); ii++) + for (size_t ii = 0; ii < this->size(); ii++) { this->at(ii) = array->at((size_t)i + ii); } @@ -141,7 +142,7 @@ namespace MbD { //template<> //inline void Array::conditionSelfWithTol(double tol) //{ - // for (int i = 0; i < this->size(); i++) + // for (size_t i = 0; i < this->size(); i++) // { // double element = this->at(i); // if (element < 0.0) element = -element; @@ -157,7 +158,7 @@ namespace MbD { //inline double Array::length() //{ // double ssq = 0.0; - // for (int i = 0; i < this->size(); i++) + // for (size_t i = 0; i < this->size(); i++) // { // double elem = this->at(i); // ssq += elem * elem; @@ -167,7 +168,7 @@ namespace MbD { template inline void Array::magnifySelf(T factor) { - for (int i = 0; i < this->size(); i++) + for (size_t i = 0; i < this->size(); i++) { this->atitimes(i, factor); } diff --git a/OndselSolver/DiagonalMatrix.cpp b/OndselSolver/DiagonalMatrix.cpp index c03cfc9..68d849f 100644 --- a/OndselSolver/DiagonalMatrix.cpp +++ b/OndselSolver/DiagonalMatrix.cpp @@ -23,7 +23,7 @@ namespace MbD { } void DiagonalMatrix::atiputDiagonalMatrix(int i, std::shared_ptr diagMat) { - for (int ii = 0; ii < diagMat->size(); ii++) + for (size_t ii = 0; ii < diagMat->size(); ii++) { this->at(i + ii) = diagMat->at(ii); } @@ -53,7 +53,7 @@ namespace MbD { double DiagonalMatrix::sumOfSquares() { double sum = 0.0; - for (int i = 0; i < this->size(); i++) + for (size_t i = 0; i < this->size(); i++) { double element = this->at(i); sum += element * element; @@ -67,14 +67,14 @@ namespace MbD { } void DiagonalMatrix::zeroSelf() { - for (int i = 0; i < this->size(); i++) { + for (size_t i = 0; i < this->size(); i++) { this->at(i) = 0.0; } } double DiagonalMatrix::maxMagnitude() { double max = 0.0; - for (int i = 0; i < this->size(); i++) + for (size_t i = 0; i < this->size(); i++) { double element = this->at(i); if (element < 0.0) element = -element; @@ -86,7 +86,7 @@ namespace MbD { { s << "DiagMat["; s << this->at(0); - for (int i = 1; i < this->size(); i++) + for (size_t i = 1; i < this->size(); i++) { s << ", " << this->at(i); } diff --git a/OndselSolver/DifferenceOperator.cpp b/OndselSolver/DifferenceOperator.cpp index aede368..14aca53 100644 --- a/OndselSolver/DifferenceOperator.cpp +++ b/OndselSolver/DifferenceOperator.cpp @@ -18,7 +18,7 @@ using namespace MbD; FRowDsptr DifferenceOperator::OneOverFactorials = []() { auto oneOverFactorials = std::make_shared>(10); - for (int i = 0; i < oneOverFactorials->size(); i++) + for (size_t i = 0; i < oneOverFactorials->size(); i++) { oneOverFactorials->at(i) = 1.0 / std::tgamma(i + 1); } diff --git a/OndselSolver/DifferenceOperator.h b/OndselSolver/DifferenceOperator.h index 8926f8d..910a6ee 100644 --- a/OndselSolver/DifferenceOperator.h +++ b/OndselSolver/DifferenceOperator.h @@ -17,6 +17,7 @@ namespace MbD { { //iStep order taylorMatrix operatorMatrix time timeNodes public: + virtual ~DifferenceOperator() {} void calcOperatorMatrix(); virtual void initialize(); virtual void initializeLocally(); diff --git a/OndselSolver/FullColumn.cpp b/OndselSolver/FullColumn.cpp index acf14d7..9e760e4 100644 --- a/OndselSolver/FullColumn.cpp +++ b/OndselSolver/FullColumn.cpp @@ -58,7 +58,7 @@ namespace MbD { template void FullColumn::atiputFullColumn(int i, FColsptr fullCol) { - for (int ii = 0; ii < fullCol->size(); ii++) + for (size_t ii = 0; ii < fullCol->size(); ii++) { this->at(i + ii) = fullCol->at(ii); } @@ -66,7 +66,7 @@ namespace MbD { template void FullColumn::atiplusFullColumn(int i, FColsptr fullCol) { - for (int ii = 0; ii < fullCol->size(); ii++) + for (size_t ii = 0; ii < fullCol->size(); ii++) { this->at(i + ii) += fullCol->at(ii); } @@ -75,7 +75,7 @@ namespace MbD { void FullColumn::equalSelfPlusFullColumnAt(FColsptr fullCol, int ii) { //self is subcolumn of fullCol - for (int i = 0; i < this->size(); i++) + for (size_t i = 0; i < this->size(); i++) { this->at(i) += fullCol->at(ii + i); } @@ -83,7 +83,7 @@ namespace MbD { template void FullColumn::atiminusFullColumn(int i1, FColsptr fullCol) { - for (int ii = 0; ii < fullCol->size(); ii++) + for (size_t ii = 0; ii < fullCol->size(); ii++) { int i = i1 + ii; this->at(i) -= fullCol->at(ii); @@ -93,7 +93,7 @@ namespace MbD { void FullColumn::equalFullColumnAt(FColsptr fullCol, int i) { this->equalArrayAt(fullCol, i); - //for (int ii = 0; ii < this->size(); ii++) + //for (size_t ii = 0; ii < this->size(); ii++) //{ // this->at(ii) = fullCol->at(i + ii); //} @@ -117,7 +117,7 @@ namespace MbD { template void FullColumn::atiplusFullColumntimes(int i1, FColsptr fullCol, T factor) { - for (int ii = 0; ii < fullCol->size(); ii++) + for (size_t ii = 0; ii < fullCol->size(); ii++) { int i = i1 + ii; this->at(i) += fullCol->at(ii) * factor; diff --git a/OndselSolver/FullColumn.h b/OndselSolver/FullColumn.h index 663dfcc..70b6fd1 100644 --- a/OndselSolver/FullColumn.h +++ b/OndselSolver/FullColumn.h @@ -59,7 +59,7 @@ namespace MbD { { s << "FullCol{"; s << this->at(0); - for (int i = 1; i < int(this->size()); i++) + for (size_t i = 1; i < this->size(); i++) { s << ", " << this->at(i); } diff --git a/OndselSolver/FullMatrix.cpp b/OndselSolver/FullMatrix.cpp index fa2053f..978b71b 100644 --- a/OndselSolver/FullMatrix.cpp +++ b/OndselSolver/FullMatrix.cpp @@ -257,32 +257,32 @@ namespace MbD { } void FullMatrixDouble::zeroSelf() { - for (int i = 0; i < this->size(); i++) { + for (size_t i = 0; i < this->size(); i++) { this->at(i)->zeroSelf(); } } void FullMatrixFullMatrixDouble::zeroSelf() { - for (int i = 0; i < this->size(); i++) { + for (size_t i = 0; i < this->size(); i++) { this->at(i)->zeroSelf(); } } void FullMatrixFullColumnDouble::zeroSelf() { - for (int i = 0; i < this->size(); i++) { + for (size_t i = 0; i < this->size(); i++) { this->at(i)->zeroSelf(); } } void FullMatrixDouble::identity() { this->zeroSelf(); - for (int i = 0; i < this->size(); i++) { + for (size_t i = 0; i < this->size(); i++) { this->at(i)->at(i) = 1.0; } } void FullMatrixFullMatrixDouble::identity() { assert(false); // this->zeroSelf(); -// for (int i = 0; i < this->size(); i++) { +// for (size_t i = 0; i < this->size(); i++) { // this->at(i)->at(i) = 1.0; // } } @@ -410,7 +410,7 @@ namespace MbD { } void FullMatrixDouble::atijputFullColumn(int i1, int j1, FColsptr fullCol) { - for (int ii = 0; ii < fullCol->size(); ii++) + for (size_t ii = 0; ii < fullCol->size(); ii++) { this->at(i1 + ii)->at(j1) = fullCol->at(ii); } @@ -432,7 +432,7 @@ namespace MbD { double FullMatrixDouble::sumOfSquares() { double sum = 0.0; - for (int i = 0; i < this->size(); i++) + for (size_t i = 0; i < this->size(); i++) { sum += this->at(i)->sumOfSquares(); } @@ -441,7 +441,7 @@ namespace MbD { double FullMatrixFullMatrixDouble::sumOfSquares() { double sum = 0.0; - for (int i = 0; i < this->size(); i++) + for (size_t i = 0; i < this->size(); i++) { sum += this->at(i)->sumOfSquares(); } @@ -450,7 +450,7 @@ namespace MbD { double FullMatrixFullColumnDouble::sumOfSquares() { double sum = 0.0; - for (int i = 0; i < this->size(); i++) + for (size_t i = 0; i < this->size(); i++) { sum += this->at(i)->sumOfSquares(); } @@ -482,14 +482,14 @@ namespace MbD { } void FullMatrixDouble::magnifySelf(double factor) { - for (int i = 0; i < this->size(); i++) { + for (size_t i = 0; i < this->size(); i++) { this->at(i)->magnifySelf(factor); } } std::ostream& FullMatrixDouble::printOn(std::ostream& s) const { s << "FullMat[" << std::endl; - for (int i = 0; i < this->size(); i++) + for (size_t i = 0; i < this->size(); i++) { s << *(this->at(i)) << std::endl; } @@ -558,7 +558,7 @@ namespace MbD { double FullMatrixDouble::trace() { double trace = 0.0; - for (int i = 0; i < this->size(); i++) + for (size_t i = 0; i < this->size(); i++) { trace += this->at(i)->at(i); } @@ -567,7 +567,7 @@ namespace MbD { double FullMatrixDouble::maxMagnitude() { double max = 0.0; - for (int i = 0; i < this->size(); i++) + for (size_t i = 0; i < this->size(); i++) { double element = this->at(i)->maxMagnitude(); if (max < element) max = element; @@ -577,7 +577,7 @@ namespace MbD { double FullMatrixFullMatrixDouble::maxMagnitude() { double max = 0.0; - for (int i = 0; i < this->size(); i++) + for (size_t i = 0; i < this->size(); i++) { double element = this->at(i)->maxMagnitude(); if (max < element) max = element; @@ -587,7 +587,7 @@ namespace MbD { double FullMatrixFullColumnDouble::maxMagnitude() { double max = 0.0; - for (int i = 0; i < this->size(); i++) + for (size_t i = 0; i < this->size(); i++) { double element = this->at(i)->maxMagnitude(); if (max < element) max = element; diff --git a/OndselSolver/FullRow.cpp b/OndselSolver/FullRow.cpp index 4e08613..1c8a877 100644 --- a/OndselSolver/FullRow.cpp +++ b/OndselSolver/FullRow.cpp @@ -66,7 +66,7 @@ namespace MbD { FRowsptr FullRow::timesFullMatrix(std::shared_ptr fullMat) { FRowsptr answer = fullMat->at(0)->times(this->at(0)); - for (int j = 1; j < (int) this->size(); j++) + for (size_t j = 1; j < this->size(); j++) { answer->equalSelfPlusFullRowTimes(fullMat->at(j), this->at(j)); } diff --git a/OndselSolver/FullRow.h b/OndselSolver/FullRow.h index 85712bf..1efe1b8 100644 --- a/OndselSolver/FullRow.h +++ b/OndselSolver/FullRow.h @@ -99,7 +99,7 @@ namespace MbD { inline T FullRow::timesFullColumn(FullColumn* fullCol) { auto answer = this->at(0) * fullCol->at(0); - for (int i = 1; i < this->size(); i++) + for (size_t i = 1; i < this->size(); i++) { answer += this->at(i) * fullCol->at(i); } @@ -134,7 +134,7 @@ namespace MbD { template inline void FullRow::atiplusFullRow(int j1, FRowsptr fullRow) { - for (int jj = 0; jj < fullRow->size(); jj++) + for (size_t jj = 0; jj < fullRow->size(); jj++) { auto j = j1 + jj; this->at(j) += fullRow->at(jj); @@ -176,7 +176,7 @@ namespace MbD { { s << "FullRow{"; s << this->at(0); - for (int i = 1; i < this->size(); i++) + for (size_t i = 1; i < this->size(); i++) { s << ", " << this->at(i); } diff --git a/OndselSolver/FullVector.h b/OndselSolver/FullVector.h index 60a3bb7..b74ce0e 100644 --- a/OndselSolver/FullVector.h +++ b/OndselSolver/FullVector.h @@ -71,7 +71,7 @@ namespace MbD { inline double FullVector::sumOfSquares() { double sum = 0.0; - for (int i = 0; i < (int)this->size(); i++) + for (size_t i = 0; i < this->size(); i++) { double element = this->at(i); sum += element * element; @@ -92,7 +92,7 @@ namespace MbD { template<> inline void FullVector::zeroSelf() { - for (int i = 0; i < (int)this->size(); i++) { + for (size_t i = 0; i < this->size(); i++) { this->at(i) = 0.0; } } @@ -104,7 +104,7 @@ namespace MbD { template inline void FullVector::atiplusFullVector(int i1, std::shared_ptr> fullVec) { - for (int ii = 0; ii < fullVec->size(); ii++) + for (size_t ii = 0; ii < fullVec->size(); ii++) { auto i = i1 + ii; this->at(i) += fullVec->at(ii); @@ -113,7 +113,7 @@ namespace MbD { template inline void FullVector::atiplusFullVectortimes(int i1, std::shared_ptr> fullVec, T factor) { - for (int ii = 0; ii < fullVec->size(); ii++) + for (size_t ii = 0; ii < fullVec->size(); ii++) { auto i = i1 + ii; this->at(i) += fullVec->at(ii) * factor; @@ -122,7 +122,7 @@ namespace MbD { template inline void FullVector::equalSelfPlusFullVectortimes(std::shared_ptr> fullVec, T factor) { - for (int i = 0; i < this->size(); i++) + for (size_t i = 0; i < this->size(); i++) { this->atiplusNumber(i, fullVec->at(i) * factor); } @@ -131,7 +131,7 @@ namespace MbD { inline double FullVector::maxMagnitude() { double max = 0.0; - for (int i = 0; i < (int)this->size(); i++) + for (size_t i = 0; i < this->size(); i++) { double element = this->at(i); if (element < 0.0) element = -element; @@ -156,7 +156,7 @@ namespace MbD { inline double FullVector::length() { double ssq = 0.0; - for (int i = 0; i < this->size(); i++) + for (size_t i = 0; i < this->size(); i++) { double elem = this->at(i); ssq += elem * elem; @@ -173,7 +173,7 @@ namespace MbD { template<> inline void FullVector::conditionSelfWithTol(double tol) { - for (int i = 0; i < (int)this->size(); i++) + for (size_t i = 0; i < this->size(); i++) { double element = this->at(i); if (element < 0.0) element = -element; @@ -205,7 +205,7 @@ namespace MbD { //"Test if elements are increasing." //"Ok if spoilers are less than tol." auto next = this->at(0); - for (int i = 1; i < this->size(); i++) + for (size_t i = 1; i < this->size(); i++) { auto previous = next; next = this->at(i); @@ -219,7 +219,7 @@ namespace MbD { //"Test if elements are increasing." //"Ok if spoilers are less than tol." auto next = this->at(0); - for (int i = 1; i < this->size(); i++) + for (size_t i = 1; i < this->size(); i++) { auto previous = next; next = this->at(i); @@ -232,7 +232,7 @@ namespace MbD { { s << "FullVec{"; s << this->at(0); - for (int i = 1; i < (int)this->size(); i++) + for (size_t i = 1; i < (int)this->size(); i++) { s << ", " << this->at(i); } diff --git a/OndselSolver/FunctionWithManyArgs.cpp b/OndselSolver/FunctionWithManyArgs.cpp index e2e2cdc..fe944c0 100644 --- a/OndselSolver/FunctionWithManyArgs.cpp +++ b/OndselSolver/FunctionWithManyArgs.cpp @@ -33,7 +33,7 @@ FunctionWithManyArgs::FunctionWithManyArgs(Symsptr term, Symsptr term1, Symsptr FunctionWithManyArgs::FunctionWithManyArgs(std::shared_ptr> _terms) { terms = std::make_shared>(); - for (int i = 0; i < _terms->size(); i++) + for (size_t i = 0; i < _terms->size(); i++) terms->push_back(_terms->at(i)); } diff --git a/OndselSolver/GeneralSpline.cpp b/OndselSolver/GeneralSpline.cpp index 15d21e8..47f3062 100644 --- a/OndselSolver/GeneralSpline.cpp +++ b/OndselSolver/GeneralSpline.cpp @@ -245,14 +245,14 @@ std::ostream& MbD::GeneralSpline::printOn(std::ostream& s) const s << degree << ", " << std::endl; s << "xs{"; s << xs->at(0); - for (int i = 1; i < xs->size(); i++) + for (size_t i = 1; i < xs->size(); i++) { s << ", " << xs->at(i); } s << "}, " << std::endl; s << "ys{"; s << ys->at(0); - for (int i = 1; i < ys->size(); i++) + for (size_t i = 1; i < ys->size(); i++) { s << ", " << ys->at(i); } diff --git a/OndselSolver/Item.h b/OndselSolver/Item.h index 57ea6f4..7b02d56 100644 --- a/OndselSolver/Item.h +++ b/OndselSolver/Item.h @@ -32,6 +32,7 @@ namespace MbD { public: Item(); Item(const char* str); + virtual ~Item() {} virtual System* root(); void noop(); diff --git a/OndselSolver/MBDynItem.h b/OndselSolver/MBDynItem.h index b4d8745..91d4162 100644 --- a/OndselSolver/MBDynItem.h +++ b/OndselSolver/MBDynItem.h @@ -24,6 +24,7 @@ namespace MbD { { // public: + virtual ~MBDynItem() {} virtual MBDynSystem* root(); virtual void initialize(); diff --git a/OndselSolver/MBDynSystem.cpp b/OndselSolver/MBDynSystem.cpp index fe6b7a9..b8b3e4d 100644 --- a/OndselSolver/MBDynSystem.cpp +++ b/OndselSolver/MBDynSystem.cpp @@ -151,7 +151,7 @@ void MbD::MBDynSystem::outputFiles() auto asmtMotions = asmtAsm->motions; std::ofstream os(movFile); os << std::setprecision(std::numeric_limits::digits10 + 1); - for (int i = 1; i < asmtTimes->size(); i++) + for (size_t i = 1; i < asmtTimes->size(); i++) { for (auto& node : *nodes) { node->outputLine(i, os); @@ -241,7 +241,7 @@ void MbD::MBDynSystem::readElementsBlock(std::vector& lines) void MbD::MBDynSystem::eraseComments(std::vector& lines) { - for (int i = 0; i < lines.size(); i++) + for (size_t i = 0; i < lines.size(); i++) { auto line = lines[i]; auto it = line.find('#'); diff --git a/OndselSolver/MarkerFrame.cpp b/OndselSolver/MarkerFrame.cpp index fb9eafa..b86f064 100644 --- a/OndselSolver/MarkerFrame.cpp +++ b/OndselSolver/MarkerFrame.cpp @@ -42,7 +42,7 @@ void MarkerFrame::initializeLocally() { pprOmOpEpE = EulerParameters::ppApEpEtimesColumn(rpmp); ppAOmpEpE = EulerParameters::ppApEpEtimesMatrix(aApm); - for (int i = 0; i < endFrames->size(); i++) + for (size_t i = 0; i < endFrames->size(); i++) { auto eFrmqc = std::dynamic_pointer_cast(endFrames->at(i)); if (eFrmqc) { diff --git a/OndselSolver/MatrixSolver.h b/OndselSolver/MatrixSolver.h index 4f46e88..a1486b9 100644 --- a/OndselSolver/MatrixSolver.h +++ b/OndselSolver/MatrixSolver.h @@ -20,6 +20,7 @@ namespace MbD { //m n matrixA answerX rightHandSideB rowOrder colOrder rowScalings pivotValues singularPivotTolerance millisecondsToRun public: MatrixSolver(){} + virtual ~MatrixSolver() {} void initialize() override; void setSystem(Solver* sys) override; virtual FColDsptr solvewithsaveOriginal(SpMatDsptr spMat, FColDsptr fullCol, bool saveOriginal); diff --git a/OndselSolver/Numeric.h b/OndselSolver/Numeric.h index d4bd4e9..2c8ee45 100644 --- a/OndselSolver/Numeric.h +++ b/OndselSolver/Numeric.h @@ -27,7 +27,7 @@ namespace MbD { { T previous, next; next = vec->at(0); - for (int i = 1; i < vec->size(); i++) + for (std::size_t i = 1; i < vec->size(); i++) { previous = next; next = vec->at(i); diff --git a/OndselSolver/PiecewiseFunction.cpp b/OndselSolver/PiecewiseFunction.cpp index 5e88f89..1055ebd 100644 --- a/OndselSolver/PiecewiseFunction.cpp +++ b/OndselSolver/PiecewiseFunction.cpp @@ -70,7 +70,7 @@ Symsptr MbD::PiecewiseFunction::integrateWRT(Symsptr var) std::back_inserter(*integrals), [var](auto& func) { return func->integrateWRT(var); } ); - for (int i = 0; i < transitions->size(); i++) + for (size_t i = 0; i < transitions->size(); i++) { auto x = transitions->at(i)->getValue(); auto fi = integrals->at(i)->getValue(x); @@ -85,7 +85,7 @@ Symsptr MbD::PiecewiseFunction::integrateWRT(Symsptr var) double MbD::PiecewiseFunction::getValue() { auto xval = xx->getValue(); - for (int i = 0; i < transitions->size(); i++) + for (size_t i = 0; i < transitions->size(); i++) { if (xval < transitions->at(i)->getValue()) { return functions->at(i)->getValue(); @@ -99,14 +99,14 @@ std::ostream& MbD::PiecewiseFunction::printOn(std::ostream& s) const s << "PiecewiseFunction(" << *xx << ", " << std::endl; s << "functions{" << std::endl; s << *functions->at(0) << std::endl; - for (int i = 1; i < functions->size(); i++) + for (size_t i = 1; i < functions->size(); i++) { s << *functions->at(i) << std::endl; } s << "}, " << std::endl; s << "transitions{" << std::endl; s << *transitions->at(0) << std::endl; - for (int i = 1; i < transitions->size(); i++) + for (size_t i = 1; i < transitions->size(); i++) { s << *transitions->at(i) << std::endl; } diff --git a/OndselSolver/Polynomial.cpp b/OndselSolver/Polynomial.cpp index d402249..3e707dc 100644 --- a/OndselSolver/Polynomial.cpp +++ b/OndselSolver/Polynomial.cpp @@ -32,7 +32,7 @@ MbD::Polynomial::Polynomial(Symsptr var, std::shared_ptr> c Symsptr MbD::Polynomial::expandUntil(Symsptr sptr, std::shared_ptr> set) { auto newCoeffs = std::make_shared>(); - for (int i = 0; i < coeffs->size(); i++) + for (size_t i = 0; i < coeffs->size(); i++) { auto coeff = coeffs->at(i); auto newCoeff = coeff->expandUntil(coeff, set); @@ -44,7 +44,7 @@ Symsptr MbD::Polynomial::expandUntil(Symsptr sptr, std::shared_ptr> set) { auto newCoeffs = std::make_shared>(); - for (int i = 0; i < coeffs->size(); i++) + for (size_t i = 0; i < coeffs->size(); i++) { auto coeff = coeffs->at(i); auto newCoeff = coeff->simplifyUntil(coeff, set); @@ -58,7 +58,7 @@ Symsptr MbD::Polynomial::differentiateWRTx() //Differentiate powers if (coeffs->size() == 1) return sptrConstant(0.0); auto newCoeffs = std::make_shared>(); - for (int i = 1; i < coeffs->size(); i++) + for (size_t i = 1; i < coeffs->size(); i++) { auto newCoeff = i * coeffs->at(i)->getValue(); newCoeffs->push_back(sptrConstant(newCoeff)); @@ -80,7 +80,7 @@ Symsptr MbD::Polynomial::integrateWRT(Symsptr var) assert(xx == var); auto newCoeffs = std::make_shared>(); newCoeffs->push_back(sptrConstant(0.0)); - for (int i = 0; i < coeffs->size(); i++) + for (size_t i = 0; i < coeffs->size(); i++) { auto newCoeff = coeffs->at(i)->getValue() / (i + 1); newCoeffs->push_back(sptrConstant(newCoeff)); @@ -93,7 +93,7 @@ double MbD::Polynomial::getValue() auto xvalue = xx->getValue(); auto xpower = 1.0; auto answer = 0.0; - for (int i = 0; i < coeffs->size(); i++) + for (size_t i = 0; i < coeffs->size(); i++) { answer += coeffs->at(i)->getValue() * xpower; xpower *= xvalue; @@ -113,7 +113,7 @@ std::ostream& MbD::Polynomial::printOn(std::ostream& s) const s << *xx << ", "; s << "coeffs{"; s << *coeffs->at(0); - for (int i = 1; i < coeffs->size(); i++) + for (size_t i = 1; i < coeffs->size(); i++) { s << ", " << *coeffs->at(i); } diff --git a/OndselSolver/Product.cpp b/OndselSolver/Product.cpp index 93b495f..9ecd54b 100644 --- a/OndselSolver/Product.cpp +++ b/OndselSolver/Product.cpp @@ -29,7 +29,7 @@ Symsptr MbD::Product::differentiateWRT(Symsptr var) } ); auto derivativeTerms = std::make_shared>(); - for (int i = 0; i < terms->size(); i++) + for (size_t i = 0; i < terms->size(); i++) { auto& derivative = derivatives->at(i); auto newTermFunctions = std::make_shared>(*terms); @@ -125,7 +125,7 @@ std::ostream& Product::printOn(std::ostream& s) const { s << "("; s << *(this->terms->at(0)); - for (int i = 1; i < this->terms->size(); i++) + for (size_t i = 1; i < this->terms->size(); i++) { s << "*" << *(this->terms->at(i)); } @@ -141,7 +141,7 @@ bool Product::isProduct() double Product::getValue() { double answer = 1.0; - for (int i = 0; i < terms->size(); i++) answer *= terms->at(i)->getValue(); + for (size_t i = 0; i < terms->size(); i++) answer *= terms->at(i)->getValue(); return answer; } diff --git a/OndselSolver/RowTypeMatrix.h b/OndselSolver/RowTypeMatrix.h index 59298c9..b8ac7d7 100644 --- a/OndselSolver/RowTypeMatrix.h +++ b/OndselSolver/RowTypeMatrix.h @@ -35,7 +35,7 @@ namespace MbD { template inline void RowTypeMatrix::copyFrom(std::shared_ptr> x) { - for (int i = 0; i < x->size(); i++) { + for (size_t i = 0; i < x->size(); i++) { this->at(i)->copyFrom(x->at(i)); } } @@ -43,7 +43,7 @@ namespace MbD { //inline double RowTypeMatrix::maxMagnitude() //{ // double max = 0.0; - // for (int i = 0; i < this->size(); i++) + // for (size_t i = 0; i < this->size(); i++) // { // double element = this->at(i)->maxMagnitude(); // if (max < element) max = element; diff --git a/OndselSolver/Solver.h b/OndselSolver/Solver.h index 4c5247d..941ce34 100644 --- a/OndselSolver/Solver.h +++ b/OndselSolver/Solver.h @@ -16,6 +16,7 @@ namespace MbD { //statistics public: void noop(); + virtual ~Solver() {} virtual void initialize(); virtual void initializeLocally(); virtual void initializeGlobally(); diff --git a/OndselSolver/SparseMatrix.h b/OndselSolver/SparseMatrix.h index f0fc7b3..fdd1553 100644 --- a/OndselSolver/SparseMatrix.h +++ b/OndselSolver/SparseMatrix.h @@ -98,7 +98,7 @@ namespace MbD { inline double SparseMatrix::sumOfSquares() { double sum = 0.0; - for (int i = 0; i < this->size(); i++) + for (size_t i = 0; i < this->size(); i++) { sum += this->at(i)->sumOfSquares(); } @@ -107,7 +107,7 @@ namespace MbD { template<> inline void SparseMatrix::zeroSelf() { - for (int i = 0; i < this->size(); i++) { + for (size_t i = 0; i < this->size(); i++) { this->at(i)->zeroSelf(); } } @@ -119,7 +119,7 @@ namespace MbD { template inline void SparseMatrix::atijplusFullColumn(int i, int j, FColsptr fullCol) { - for (int ii = 0; ii < fullCol->size(); ii++) + for (size_t ii = 0; ii < fullCol->size(); ii++) { this->atijplusNumber(i + ii, j, fullCol->at(ii)); } @@ -127,7 +127,7 @@ namespace MbD { template inline void SparseMatrix::atijminusFullColumn(int i, int j, FColDsptr fullCol) { - for (int ii = 0; ii < fullCol->size(); ii++) + for (size_t ii = 0; ii < fullCol->size(); ii++) { this->atijminusNumber(i + ii, j, fullCol->at(ii)); } @@ -191,7 +191,7 @@ namespace MbD { inline double SparseMatrix::maxMagnitude() { double max = 0.0; - for (int i = 0; i < this->size(); i++) + for (size_t i = 0; i < this->size(); i++) { double element = this->at(i)->maxMagnitude(); if (max < element) max = element; @@ -202,7 +202,7 @@ namespace MbD { inline std::ostream& SparseMatrix::printOn(std::ostream& s) const { s << "SpMat[" << std::endl; - for (int i = 0; i < this->size(); i++) + for (size_t i = 0; i < this->size(); i++) { s << *(this->at(i)) << std::endl; } @@ -229,7 +229,7 @@ namespace MbD { //"Just evaluate quickly." auto answer = clonesptr(); - for (int i = 0; i < answer->size(); i++) + for (size_t i = 0; i < answer->size(); i++) { answer->atiput(i, answer->at(i)->plusSparseRow(spMat->at(i))); } @@ -243,7 +243,7 @@ namespace MbD { template inline void SparseMatrix::magnifySelf(T factor) { - for (int i = 0; i < this->size(); i++) { + for (size_t i = 0; i < this->size(); i++) { this->at(i)->magnifySelf(factor); } } diff --git a/OndselSolver/SparseRow.h b/OndselSolver/SparseRow.h index b7a4425..0220aef 100644 --- a/OndselSolver/SparseRow.h +++ b/OndselSolver/SparseRow.h @@ -64,7 +64,7 @@ namespace MbD { template inline void SparseRow::atiplusFullRow(int j, FRowsptr fullRow) { - for (int jj = 0; jj < fullRow->size(); jj++) + for (size_t jj = 0; jj < fullRow->size(); jj++) { (*this)[j + jj] += fullRow->at(jj); } @@ -72,7 +72,7 @@ namespace MbD { template inline void SparseRow::atiminusFullRow(int j, FRowsptr fullRow) { - for (int jj = 0; jj < fullRow->size(); jj++) + for (size_t jj = 0; jj < fullRow->size(); jj++) { (*this)[j + jj] -= fullRow->at(jj); } @@ -80,7 +80,7 @@ namespace MbD { template inline void SparseRow::atiplusFullRowtimes(int j, FRowsptr fullRow, double factor) { - for (int jj = 0; jj < fullRow->size(); jj++) + for (size_t jj = 0; jj < fullRow->size(); jj++) { (*this)[j + jj] += fullRow->at(jj) * factor; } diff --git a/OndselSolver/SparseVector.h b/OndselSolver/SparseVector.h index f032d52..484aa14 100644 --- a/OndselSolver/SparseVector.h +++ b/OndselSolver/SparseVector.h @@ -34,6 +34,7 @@ namespace MbD { this->insert(std::pair(index, value)); } } + virtual ~SparseVector() {} double rootMeanSquare(); int numberOfElements(); double sumOfSquares(); diff --git a/OndselSolver/Sum.cpp b/OndselSolver/Sum.cpp index 1ebbd6b..bfa16cd 100644 --- a/OndselSolver/Sum.cpp +++ b/OndselSolver/Sum.cpp @@ -128,7 +128,7 @@ bool Sum::isSum() double Sum::getValue() { double answer = 0.0; - for (int i = 0; i < terms->size(); i++) answer += terms->at(i)->getValue(); + for (size_t i = 0; i < terms->size(); i++) answer += terms->at(i)->getValue(); return answer; } @@ -174,7 +174,7 @@ std::ostream& Sum::printOn(std::ostream& s) const { s << "("; s << *(this->terms->at(0)); - for (int i = 1; i < this->terms->size(); i++) + for (size_t i = 1; i < this->terms->size(); i++) { s << " + " << *(this->terms->at(i)); } diff --git a/OndselSolver/Symbolic.h b/OndselSolver/Symbolic.h index 9dea365..f1b91c5 100644 --- a/OndselSolver/Symbolic.h +++ b/OndselSolver/Symbolic.h @@ -27,6 +27,7 @@ namespace MbD { { public: Symbolic(); + virtual ~Symbolic() {} static Symsptr times(Symsptr arg, Symsptr arg1); static Symsptr sum(Symsptr arg, Symsptr arg1); static Symsptr raisedTo(Symsptr x, Symsptr y); diff --git a/OndselSolver/SymbolicParser.cpp b/OndselSolver/SymbolicParser.cpp index 067a193..d939468 100644 --- a/OndselSolver/SymbolicParser.cpp +++ b/OndselSolver/SymbolicParser.cpp @@ -487,7 +487,7 @@ void MbD::SymbolicParser::notifyat(std::string msg, int mrk) void MbD::SymbolicParser::combineStackTo(int pos) { auto args = std::make_shared>(); - while (stack->size() > pos) { + while (stack->size() > (size_t) pos) { Symsptr arg = stack->top(); stack->pop(); args->push_back(arg); diff --git a/OndselSolver/System.cpp b/OndselSolver/System.cpp index d10d62e..2fff4fd 100644 --- a/OndselSolver/System.cpp +++ b/OndselSolver/System.cpp @@ -186,7 +186,7 @@ double System::maximumMass() double System::maximumMomentOfInertia() { double max = 0.0; - for (int i = 0; i < parts->size(); i++) + for (size_t i = 0; i < parts->size(); i++) { auto& part = parts->at(i); for (int j = 0; j < 3; j++)