From 2b48cda825f3121dca246bcfb5f5946a41d481c4 Mon Sep 17 00:00:00 2001 From: Pieter Hijma Date: Thu, 27 Jun 2024 20:45:29 +0200 Subject: [PATCH] Fix various compiler warnings --- OndselSolver/ASMTAssembly.cpp | 4 ++-- OndselSolver/ASMTPart.cpp | 6 +++--- OndselSolver/ConstraintIJ.cpp | 6 ++++-- OndselSolver/ConstraintIJ.h | 4 ++-- OndselSolver/GESpMatFullPv.cpp | 2 +- OndselSolver/GESpMatParPv.cpp | 2 +- OndselSolver/GeneralSpline.cpp | 4 ++-- OndselSolver/LDUFullMat.cpp | 2 +- OndselSolver/LDUSpMat.cpp | 2 +- OndselSolver/LDUSpMat.h | 5 +++-- OndselSolver/LDUSpMatParPv.cpp | 2 +- OndselSolver/MatrixDecomposition.cpp | 2 +- OndselSolver/MatrixDecomposition.h | 6 +++--- OndselSolver/MatrixSolver.h | 6 ++++-- OndselSolver/NewtonRaphson.cpp | 6 ++++-- OndselSolver/PosKineNewtonRaphson.cpp | 2 +- OndselSolver/SparseMatrix.h | 2 +- OndselSolver/VelKineSolver.cpp | 2 +- 18 files changed, 36 insertions(+), 29 deletions(-) diff --git a/OndselSolver/ASMTAssembly.cpp b/OndselSolver/ASMTAssembly.cpp index 448bed9..87eec10 100644 --- a/OndselSolver/ASMTAssembly.cpp +++ b/OndselSolver/ASMTAssembly.cpp @@ -1092,7 +1092,7 @@ void MbD::ASMTAssembly::preMbDrun(std::shared_ptr mbdSys) std::static_pointer_cast(mbdObject)->asFixed(); } -void MbD::ASMTAssembly::preMbDrunDragStep(std::shared_ptr mbdSys, std::shared_ptr>> dragParts) +void MbD::ASMTAssembly::preMbDrunDragStep(std::shared_ptr mbdSys, std::shared_ptr>> /*dragParts*/) { for (auto& part : *parts) { part->preMbDrunDragStep(mbdSys, mbdUnits); @@ -1371,7 +1371,7 @@ void MbD::ASMTAssembly::runDragStep( auto qEO2 = cqEO2->at(j); std::shared_ptr> qEOmid; auto cosHalfTheta = qEO1->dot(qEO2); - if (abs(cosHalfTheta) >= 1.0) { + if (std::abs(cosHalfTheta) >= 1.0) { qEOmid = qEO1->copy(); } else { diff --git a/OndselSolver/ASMTPart.cpp b/OndselSolver/ASMTPart.cpp index fdf185a..d34e9db 100644 --- a/OndselSolver/ASMTPart.cpp +++ b/OndselSolver/ASMTPart.cpp @@ -5,8 +5,8 @@ * * * See LICENSE file for details about copyright. * ***************************************************************************/ -#include -#include +#include +#include #include "ASMTPart.h" #include "CREATE.h" @@ -126,7 +126,7 @@ void MbD::ASMTPart::createMbD(std::shared_ptr mbdSys, std::shared_ptr(mbdObject)->asFixed(); } -void MbD::ASMTPart::preMbDrunDragStep(std::shared_ptr mbdSys, std::shared_ptr mbdUnits) +void MbD::ASMTPart::preMbDrunDragStep(std::shared_ptr /*mbdSys*/, std::shared_ptr mbdUnits) { auto mbdPart = std::static_pointer_cast(mbdObject); mbdPart->qX(rOcmO()->times(1.0 / mbdUnits->length)); diff --git a/OndselSolver/ConstraintIJ.cpp b/OndselSolver/ConstraintIJ.cpp index df9d03f..06aaea1 100644 --- a/OndselSolver/ConstraintIJ.cpp +++ b/OndselSolver/ConstraintIJ.cpp @@ -5,13 +5,15 @@ * * * See LICENSE file for details about copyright. * ***************************************************************************/ - + #include "ConstraintIJ.h" + +#include #include "EndFramec.h" using namespace MbD; -ConstraintIJ::ConstraintIJ(EndFrmsptr frmi, EndFrmsptr frmj) : frmI(frmi), frmJ(frmj), Constraint() +ConstraintIJ::ConstraintIJ(EndFrmsptr frmi, EndFrmsptr frmj) : frmI(std::move(frmi)), frmJ(std::move(frmj)) { } diff --git a/OndselSolver/ConstraintIJ.h b/OndselSolver/ConstraintIJ.h index 8039ea9..9b64f4f 100644 --- a/OndselSolver/ConstraintIJ.h +++ b/OndselSolver/ConstraintIJ.h @@ -14,10 +14,10 @@ namespace MbD { class EndFramec; using EndFrmsptr = std::shared_ptr; - + class ConstraintIJ : public Constraint { - //frmI frmJ aConstant + //frmI frmJ aConstant public: ConstraintIJ(EndFrmsptr frmi, EndFrmsptr frmj); diff --git a/OndselSolver/GESpMatFullPv.cpp b/OndselSolver/GESpMatFullPv.cpp index c21bd5d..f868dc9 100644 --- a/OndselSolver/GESpMatFullPv.cpp +++ b/OndselSolver/GESpMatFullPv.cpp @@ -125,7 +125,7 @@ void GESpMatFullPv::backSubstituteIntoDU() for (auto const& keyValue : *rowi) { auto jj = keyValue.first; auto j = positionsOfOriginalCols->at(jj); - if (j > i) { + if ((int) j > i) { duij = keyValue.second; sum += answerX->at(jj) * duij; } diff --git a/OndselSolver/GESpMatParPv.cpp b/OndselSolver/GESpMatParPv.cpp index 558bb80..213d4d7 100644 --- a/OndselSolver/GESpMatParPv.cpp +++ b/OndselSolver/GESpMatParPv.cpp @@ -60,7 +60,7 @@ void GESpMatParPv::backSubstituteIntoDU() sum = 0.0; // rhsZeroElement copy. for (auto const& keyValue : *rowi) { auto j = keyValue.first; - if (j > i) { + if ((int)j > i) { duij = keyValue.second; sum += answerX->at(j) * duij; } diff --git a/OndselSolver/GeneralSpline.cpp b/OndselSolver/GeneralSpline.cpp index 76a0bdf..5040464 100644 --- a/OndselSolver/GeneralSpline.cpp +++ b/OndselSolver/GeneralSpline.cpp @@ -105,7 +105,7 @@ void MbD::GeneralSpline::computeDerivatives() } else { //"Zero out higher derivatives at node n and node 1 to get the p end equations." - auto count = 0; + unsigned int count = 0; auto npass = 0; while (count < p) { matrix->atijput(np - count, np - npass, 1.0); @@ -149,7 +149,7 @@ double MbD::GeneralSpline::derivativeAt(size_t n, double xxx) calcIndexAndDeltaFor(xxx); auto& derivsi = derivs->at(index); double sum = 0.0; - for (int j = (int)degree; j >= n + 1; j--) //Use int because of decrement + for (int j = (int)degree; j >= (int) n + 1; j--) //Use int because of decrement { sum = (sum + derivsi->at((size_t)j - 1)) * delta / (j - n); } diff --git a/OndselSolver/LDUFullMat.cpp b/OndselSolver/LDUFullMat.cpp index 8f91a28..78b528c 100644 --- a/OndselSolver/LDUFullMat.cpp +++ b/OndselSolver/LDUFullMat.cpp @@ -160,7 +160,7 @@ void LDUFullMat::backSubstituteIntoDU() { auto& rowi = matrixA->at(i); double sum = answerX->at((size_t)n - 1) * rowi->at((size_t)n - 1); - for (int j = i + 1; j < n - 1; j++) + for (int j = i + 1; j < (int)n - 1; j++) { sum += answerX->at(j) * rowi->at(j); } diff --git a/OndselSolver/LDUSpMat.cpp b/OndselSolver/LDUSpMat.cpp index b4371fd..a028886 100644 --- a/OndselSolver/LDUSpMat.cpp +++ b/OndselSolver/LDUSpMat.cpp @@ -5,7 +5,7 @@ * * * See LICENSE file for details about copyright. * ***************************************************************************/ - + #include "LDUSpMat.h" #include "FullColumn.h" diff --git a/OndselSolver/LDUSpMat.h b/OndselSolver/LDUSpMat.h index 3507bb1..9184701 100644 --- a/OndselSolver/LDUSpMat.h +++ b/OndselSolver/LDUSpMat.h @@ -5,7 +5,7 @@ * * * See LICENSE file for details about copyright. * ***************************************************************************/ - + #pragma once #include "MatrixLDU.h" @@ -14,8 +14,9 @@ namespace MbD { class LDUSpMat : public MatrixLDU { - //matrixL matrixD matrixU markowitzPivotRowCount markowitzPivotColCount privateIndicesOfNonZerosInPivotRow rowPositionsOfNonZerosInPivotColumn + //matrixL matrixD matrixU markowitzPivotRowCount markowitzPivotColCount privateIndicesOfNonZerosInPivotRow rowPositionsOfNonZerosInPivotColumn public: + using MatrixSolver::basicSolvewithsaveOriginal; FColDsptr basicSolvewithsaveOriginal(SpMatDsptr spMat, FColDsptr fullCol, bool saveOriginal) override; void decomposesaveOriginal(FMatDsptr fullMat, bool saveOriginal); void decomposesaveOriginal(SpMatDsptr spMat, bool saveOriginal); diff --git a/OndselSolver/LDUSpMatParPv.cpp b/OndselSolver/LDUSpMatParPv.cpp index 3c901c1..9a5e91d 100644 --- a/OndselSolver/LDUSpMatParPv.cpp +++ b/OndselSolver/LDUSpMatParPv.cpp @@ -5,5 +5,5 @@ * * * See LICENSE file for details about copyright. * ***************************************************************************/ - + #include "LDUSpMatParPv.h" diff --git a/OndselSolver/MatrixDecomposition.cpp b/OndselSolver/MatrixDecomposition.cpp index 2c8ca5c..7692ab6 100644 --- a/OndselSolver/MatrixDecomposition.cpp +++ b/OndselSolver/MatrixDecomposition.cpp @@ -5,7 +5,7 @@ * * * See LICENSE file for details about copyright. * ***************************************************************************/ - + #include "MatrixDecomposition.h" using namespace MbD; diff --git a/OndselSolver/MatrixDecomposition.h b/OndselSolver/MatrixDecomposition.h index e63868e..ef3e332 100644 --- a/OndselSolver/MatrixDecomposition.h +++ b/OndselSolver/MatrixDecomposition.h @@ -5,7 +5,7 @@ * * * See LICENSE file for details about copyright. * ***************************************************************************/ - + #pragma once #include "MatrixSolver.h" @@ -19,9 +19,9 @@ namespace MbD { virtual void applyRowOrderOnRightHandSideB(); virtual void forwardSubstituteIntoL(); virtual void backSubstituteIntoU(); - virtual FColDsptr basicSolvewithsaveOriginal(FMatDsptr aMatrix, FColDsptr aVector, bool saveOriginal); + FColDsptr basicSolvewithsaveOriginal(FMatDsptr aMatrix, FColDsptr aVector, bool saveOriginal) override; virtual void forwardSubstituteIntoLD(); - virtual void postSolve(); + void postSolve() override; virtual void preSolvesaveOriginal(FMatDsptr aMatrix, bool saveOriginal); }; diff --git a/OndselSolver/MatrixSolver.h b/OndselSolver/MatrixSolver.h index 0bb99fa..75df028 100644 --- a/OndselSolver/MatrixSolver.h +++ b/OndselSolver/MatrixSolver.h @@ -5,7 +5,7 @@ * * * See LICENSE file for details about copyright. * ***************************************************************************/ - + #pragma once #include "Solver.h" @@ -17,7 +17,7 @@ namespace MbD { class MatrixSolver : public Solver { - //m n matrixA answerX rightHandSideB rowOrder colOrder rowScalings pivotValues singularPivotTolerance millisecondsToRun + //m n matrixA answerX rightHandSideB rowOrder colOrder rowScalings pivotValues singularPivotTolerance millisecondsToRun public: MatrixSolver(){} virtual ~MatrixSolver() {} @@ -27,8 +27,10 @@ namespace MbD { virtual FColDsptr solvewithsaveOriginal(FMatDsptr fullMat, FColDsptr fullCol, bool saveOriginal); virtual FColDsptr timedSolvewithsaveOriginal(FMatDsptr fullMat, FColDsptr fullCol, bool saveOriginal); virtual FColDsptr timedSolvewithsaveOriginal(SpMatDsptr spMat, FColDsptr fullCol, bool saveOriginal); + virtual FColDsptr basicSolvewithsaveOriginal(FMatDsptr fullMat, FColDsptr fullCol, bool saveOriginal) = 0; virtual FColDsptr basicSolvewithsaveOriginal(SpMatDsptr spMat, FColDsptr fullCol, bool saveOriginal) = 0; + virtual void preSolvewithsaveOriginal(FMatDsptr fullMat, FColDsptr fullCol, bool saveOriginal) = 0; virtual void preSolvewithsaveOriginal(SpMatDsptr spMat, FColDsptr fullCol, bool saveOriginal) = 0; virtual void doPivoting(size_t p) = 0; diff --git a/OndselSolver/NewtonRaphson.cpp b/OndselSolver/NewtonRaphson.cpp index 3175c8b..806544f 100644 --- a/OndselSolver/NewtonRaphson.cpp +++ b/OndselSolver/NewtonRaphson.cpp @@ -108,7 +108,7 @@ bool NewtonRaphson::isConvergedToNumericalLimit() auto tooLargeTol = 1.0e-2; constexpr auto smallEnoughTol = std::numeric_limits::epsilon(); auto nDecade = log10(tooLargeTol / smallEnoughTol); - auto nDivergenceMax = 3; + size_t nDivergenceMax = 3; auto dxNormIterNo = dxNorms->at(iterNo); if (iterNo > 0) { auto dxNormIterNoOld = dxNorms->at(iterNo); @@ -119,7 +119,9 @@ bool NewtonRaphson::isConvergedToNumericalLimit() stillConverging = true; } else { - if (!farTooLargeError) nDivergence++; + if (!farTooLargeError) { + nDivergence++; + } stillConverging = nDivergence < nDivergenceMax; } return !(farTooLargeError || (worthIterating && stillConverging)); diff --git a/OndselSolver/PosKineNewtonRaphson.cpp b/OndselSolver/PosKineNewtonRaphson.cpp index 41e79f4..bd1dfe1 100644 --- a/OndselSolver/PosKineNewtonRaphson.cpp +++ b/OndselSolver/PosKineNewtonRaphson.cpp @@ -58,7 +58,7 @@ void PosKineNewtonRaphson::assignEquationNumbers() // uHolder->iu(varNo); // varNo += 1; //} - auto eqnNo = 0; + size_t eqnNo = 0; for (auto& con : *constraints) { con->iG = eqnNo; eqnNo += 1; diff --git a/OndselSolver/SparseMatrix.h b/OndselSolver/SparseMatrix.h index ed1b08d..d385104 100644 --- a/OndselSolver/SparseMatrix.h +++ b/OndselSolver/SparseMatrix.h @@ -247,4 +247,4 @@ namespace MbD { this->at(i)->magnifySelf(factor); } } -} \ No newline at end of file +} diff --git a/OndselSolver/VelKineSolver.cpp b/OndselSolver/VelKineSolver.cpp index 422e0a9..9ff021e 100644 --- a/OndselSolver/VelKineSolver.cpp +++ b/OndselSolver/VelKineSolver.cpp @@ -36,7 +36,7 @@ void VelKineSolver::assignEquationNumbers() // uHolder->iu(varNo); // varNo += 1; //} - auto eqnNo = 0; + size_t eqnNo = 0; for (auto& con : *constraints) { con->iG = eqnNo; eqnNo += 1;