diff --git a/CMakeLists.txt b/CMakeLists.txt index e4da2f6..15666a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,9 @@ endif() set(ONDSELSOLVER_SRC + OndselSolver/AllowZRotation.cpp + OndselSolver/AllowZRotationConstraintIqctJqc.cpp + OndselSolver/ASMTAllowRotation.cpp OndselSolver/Array.cpp OndselSolver/FullVector.cpp OndselSolver/RowTypeMatrix.cpp @@ -345,6 +348,9 @@ set(ONDSELSOLVER_SRC ) set(ONDSELSOLVER_HEADERS + OndselSolver/AllowZRotation.h + OndselSolver/AllowZRotationConstraintIqctJqc.h + OndselSolver/ASMTAllowRotation.h OndselSolver/Array.h OndselSolver/FullVector.h OndselSolver/RowTypeMatrix.h diff --git a/OndselSolver/ASMTAllowRotation.cpp b/OndselSolver/ASMTAllowRotation.cpp new file mode 100644 index 0000000..8f4c871 --- /dev/null +++ b/OndselSolver/ASMTAllowRotation.cpp @@ -0,0 +1,76 @@ +/*************************************************************************** + * Copyright (c) 2023 Ondsel, Inc. * + * * + * This file is part of OndselSolver. * + * * + * See LICENSE file for details about copyright. * + ***************************************************************************/ + +#include "ASMTAllowRotation.h" +#include "ASMTAssembly.h" +#include "ASMTJoint.h" +#include "AllowZRotation.h" + +using namespace MbD; + +std::shared_ptr MbD::ASMTAllowRotation::With() +{ + auto asmtAllowRotation = std::make_shared(); + return asmtAllowRotation; +} + +void MbD::ASMTAllowRotation::parseASMT(std::vector& lines) +{ + readName(lines); + if (lines[0].find("MarkerI") != std::string::npos) { + readMarkerI(lines); + readMarkerJ(lines); + } + readMotionJoint(lines); +} + +void MbD::ASMTAllowRotation::readMotionJoint(std::vector& lines) +{ + assert(lines[0].find("MotionJoint") != std::string::npos); + lines.erase(lines.begin()); + motionJoint = readString(lines[0]); + lines.erase(lines.begin()); +} + +void MbD::ASMTAllowRotation::initMarkers() +{ + if (motionJoint == "") { + assert(markerI != ""); + assert(markerJ != ""); + } + else { + auto jt = root()->jointAt(motionJoint); + markerI = jt->markerI; + markerJ = jt->markerJ; + } +} + +std::shared_ptr MbD::ASMTAllowRotation::mbdClassNew() +{ + return AllowZRotation::With(); +} + +void MbD::ASMTAllowRotation::setMotionJoint(std::string motionJoint) +{ +} + +void MbD::ASMTAllowRotation::storeOnLevel(std::ofstream& os, size_t level) +{ + storeOnLevelString(os, level, "AllowRotation"); + storeOnLevelString(os, level + 1, "Name"); + storeOnLevelString(os, level + 2, name); + ASMTItemIJ::storeOnLevel(os, level); + storeOnLevelString(os, level + 1, "MotionJoint"); + storeOnLevelString(os, level + 2, motionJoint); +} + +void MbD::ASMTAllowRotation::storeOnTimeSeries(std::ofstream& os) +{ + os << "AllowRotationSeries\t" << fullName("") << std::endl; + ASMTItemIJ::storeOnTimeSeries(os); +} diff --git a/OndselSolver/ASMTAllowRotation.h b/OndselSolver/ASMTAllowRotation.h new file mode 100644 index 0000000..16983d5 --- /dev/null +++ b/OndselSolver/ASMTAllowRotation.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * Copyright (c) 2023 Ondsel, Inc. * + * * + * This file is part of OndselSolver. * + * * + * See LICENSE file for details about copyright. * + ***************************************************************************/ + +#pragma once + +#include "ASMTMotion.h" + +namespace MbD { + class ASMTAllowRotation : public ASMTMotion + { + // + public: + static std::shared_ptr With(); + void parseASMT(std::vector& lines) override; + void readMotionJoint(std::vector& lines); + void initMarkers() override; + std::shared_ptr mbdClassNew() override; + void setMotionJoint(std::string motionJoint); + void storeOnLevel(std::ofstream& os, size_t level) override; + void storeOnTimeSeries(std::ofstream& os) override; + + std::string motionJoint, rotationZ; + }; +} diff --git a/OndselSolver/ASMTAngleJoint.cpp b/OndselSolver/ASMTAngleJoint.cpp index baac675..e546809 100644 --- a/OndselSolver/ASMTAngleJoint.cpp +++ b/OndselSolver/ASMTAngleJoint.cpp @@ -42,7 +42,7 @@ void MbD::ASMTAngleJoint::createMbD(std::shared_ptr mbdSys, std::shared_ angleJoint->theIzJz = theIzJz; } -void MbD::ASMTAngleJoint::storeOnLevel(std::ofstream& os, int level) +void MbD::ASMTAngleJoint::storeOnLevel(std::ofstream& os, size_t level) { ASMTJoint::storeOnLevel(os, level); storeOnLevelString(os, level + 1, "theIzJz"); diff --git a/OndselSolver/ASMTAngleJoint.h b/OndselSolver/ASMTAngleJoint.h index f49618a..3e57e9a 100644 --- a/OndselSolver/ASMTAngleJoint.h +++ b/OndselSolver/ASMTAngleJoint.h @@ -19,7 +19,7 @@ namespace MbD { void parseASMT(std::vector& lines) override; void readTheIzJz(std::vector& lines); void createMbD(std::shared_ptr mbdSys, std::shared_ptr mbdUnits) override; - void storeOnLevel(std::ofstream& os, int level) override; + void storeOnLevel(std::ofstream& os, size_t level) override; double theIzJz = 0.0; }; diff --git a/OndselSolver/ASMTAnimationParameters.cpp b/OndselSolver/ASMTAnimationParameters.cpp index 853f115..2fd9e8b 100644 --- a/OndselSolver/ASMTAnimationParameters.cpp +++ b/OndselSolver/ASMTAnimationParameters.cpp @@ -12,9 +12,9 @@ using namespace MbD; void MbD::ASMTAnimationParameters::parseASMT(std::vector& lines) { - //int nframe, icurrent, istart, iend, framesPerSecond; + //size_t nframe, icurrent, istart, iend, framesPerSecond; //bool isForward; - int pos = (int)lines[0].find_first_not_of("\t"); + auto pos = lines[0].find_first_not_of("\t"); auto leadingTabs = lines[0].substr(0, pos); assert(lines[0] == (leadingTabs + "nframe")); lines.erase(lines.begin()); @@ -43,7 +43,7 @@ void MbD::ASMTAnimationParameters::parseASMT(std::vector& lines) } -void MbD::ASMTAnimationParameters::storeOnLevel(std::ofstream& os, int level) +void MbD::ASMTAnimationParameters::storeOnLevel(std::ofstream& os, size_t level) { storeOnLevelString(os, level, "AnimationParameters"); storeOnLevelString(os, level + 1, "nframe"); diff --git a/OndselSolver/ASMTAnimationParameters.h b/OndselSolver/ASMTAnimationParameters.h index 181a0f8..03703a6 100644 --- a/OndselSolver/ASMTAnimationParameters.h +++ b/OndselSolver/ASMTAnimationParameters.h @@ -16,9 +16,9 @@ namespace MbD { // public: void parseASMT(std::vector& lines) override; - void storeOnLevel(std::ofstream& os, int level) override; + void storeOnLevel(std::ofstream& os, size_t level) override; - int nframe = 1000000, icurrent = 1, istart = 1, iend = 1000000, framesPerSecond = 30; + size_t nframe = 1000000, icurrent = 1, istart = 1, iend = 1000000, framesPerSecond = 30; bool isForward = true; diff --git a/OndselSolver/ASMTAssembly.cpp b/OndselSolver/ASMTAssembly.cpp index 68194b7..00dc9e0 100644 --- a/OndselSolver/ASMTAssembly.cpp +++ b/OndselSolver/ASMTAssembly.cpp @@ -25,6 +25,7 @@ #include "ASMTSphericalJoint.h" #include "ASMTFixedJoint.h" #include "ASMTGeneralMotion.h" +#include "ASMTAllowRotation.h" #include "ASMTUniversalJoint.h" #include "ASMTPointInPlaneJoint.h" #include "ASMTPrincipalMassMarker.h" @@ -692,6 +693,9 @@ void MbD::ASMTAssembly::readMotions(std::vector& lines) else if (motionsLines[0] == "\t\t\tGeneralMotion") { motion = CREATE::With(); } + else if (motionsLines[0] == "\t\t\tAllowRotation") { + motion = CREATE::With(); + } else { assert(false); } @@ -809,7 +813,7 @@ void MbD::ASMTAssembly::readJointSeriesMany(std::vector& lines) if (lines.empty()) return; assert(lines[0].find("JointSeries") != std::string::npos); auto it = std::find_if(lines.begin(), lines.end(), [](const std::string& s) { - return s.find("MotionSeries") != std::string::npos; + return s.find("tionSeries") != std::string::npos; }); std::vector jointSeriesLines(lines.begin(), it); while (!jointSeriesLines.empty()) { @@ -885,7 +889,7 @@ void MbD::ASMTAssembly::readJointSeries(std::vector& lines) void MbD::ASMTAssembly::readMotionSeriesMany(std::vector& lines) { while (!lines.empty()) { - assert(lines[0].find("MotionSeries") != std::string::npos); + assert(lines[0].find("tionSeries") != std::string::npos); readMotionSeries(lines); } } @@ -894,7 +898,7 @@ void MbD::ASMTAssembly::readMotionSeries(std::vector& lines) { if (lines.empty()) return; std::string str = lines[0]; - std::string substr = "MotionSeries"; + std::string substr = "tionSeries"; auto pos = str.find(substr); assert(pos != std::string::npos); str.erase(0, pos + substr.length()); @@ -941,9 +945,9 @@ double MbD::ASMTAssembly::calcCharacteristicTime() double MbD::ASMTAssembly::calcCharacteristicMass() { - auto n = (int)parts->size(); + auto n = parts->size(); double sumOfSquares = 0.0; - for (int i = 0; i < n; i++) + for (size_t i = 0; i < n; i++) { auto mass = parts->at(i)->principalMassMarker->mass; sumOfSquares += mass * mass; @@ -964,9 +968,9 @@ double MbD::ASMTAssembly::calcCharacteristicLength() auto& mkrJ = markerMap->at(connector->markerJ); lengths->push_back(mkrJ->rpmp()->length()); } - auto n = (int)lengths->size(); + auto n = lengths->size(); double sumOfSquares = std::accumulate(lengths->begin(), lengths->end(), 0.0, [](double sum, double l) { return sum + l * l; }); - auto unitLength = std::sqrt(sumOfSquares / std::max((int)n, 1)); + auto unitLength = std::sqrt(sumOfSquares / std::max(n, size_t(1))); if (unitLength <= 0) unitLength = 1.0; return unitLength; } @@ -1062,7 +1066,7 @@ void MbD::ASMTAssembly::outputFile(std::string filename) // } } -void MbD::ASMTAssembly::storeOnLevel(std::ofstream& os, int level) +void MbD::ASMTAssembly::storeOnLevel(std::ofstream& os, size_t level) { storeOnLevelString(os, level, "Assembly"); storeOnLevelNotes(os, level + 1); @@ -1291,13 +1295,13 @@ std::shared_ptr MbD::ASMTAssembly::partPartialNamed(std::string partia return part; } -void MbD::ASMTAssembly::storeOnLevelNotes(std::ofstream& os, int level) +void MbD::ASMTAssembly::storeOnLevelNotes(std::ofstream& os, size_t level) { storeOnLevelString(os, level, "Notes"); storeOnLevelString(os, level + 1, notes); } -void MbD::ASMTAssembly::storeOnLevelParts(std::ofstream& os, int level) +void MbD::ASMTAssembly::storeOnLevelParts(std::ofstream& os, size_t level) { storeOnLevelString(os, level, "Parts"); for (auto& part : *parts) { @@ -1305,7 +1309,7 @@ void MbD::ASMTAssembly::storeOnLevelParts(std::ofstream& os, int level) } } -void MbD::ASMTAssembly::storeOnLevelKinematicIJs(std::ofstream& os, int level) +void MbD::ASMTAssembly::storeOnLevelKinematicIJs(std::ofstream& os, size_t level) { storeOnLevelString(os, level, "KinematicIJs"); for (auto& kinematicIJ : *kinematicIJs) { @@ -1313,7 +1317,7 @@ void MbD::ASMTAssembly::storeOnLevelKinematicIJs(std::ofstream& os, int level) } } -void MbD::ASMTAssembly::storeOnLevelConstraintSets(std::ofstream& os, int level) +void MbD::ASMTAssembly::storeOnLevelConstraintSets(std::ofstream& os, size_t level) { storeOnLevelString(os, level, "ConstraintSets"); storeOnLevelJoints(os, level + 1); @@ -1321,7 +1325,7 @@ void MbD::ASMTAssembly::storeOnLevelConstraintSets(std::ofstream& os, int level) storeOnLevelGeneralConstraintSets(os, level + 1); } -void MbD::ASMTAssembly::storeOnLevelForceTorques(std::ofstream& os, int level) +void MbD::ASMTAssembly::storeOnLevelForceTorques(std::ofstream& os, size_t level) { storeOnLevelString(os, level, "ForceTorques"); for (auto& forceTorque : *forcesTorques) { @@ -1329,7 +1333,7 @@ void MbD::ASMTAssembly::storeOnLevelForceTorques(std::ofstream& os, int level) } } -void MbD::ASMTAssembly::storeOnLevelJoints(std::ofstream& os, int level) +void MbD::ASMTAssembly::storeOnLevelJoints(std::ofstream& os, size_t level) { storeOnLevelString(os, level, "Joints"); for (auto& joint : *joints) { @@ -1337,7 +1341,7 @@ void MbD::ASMTAssembly::storeOnLevelJoints(std::ofstream& os, int level) } } -void MbD::ASMTAssembly::storeOnLevelMotions(std::ofstream& os, int level) +void MbD::ASMTAssembly::storeOnLevelMotions(std::ofstream& os, size_t level) { storeOnLevelString(os, level, "Motions"); for (auto& motion : *motions) { @@ -1345,7 +1349,7 @@ void MbD::ASMTAssembly::storeOnLevelMotions(std::ofstream& os, int level) } } -void MbD::ASMTAssembly::storeOnLevelGeneralConstraintSets(std::ofstream& os, int level) +void MbD::ASMTAssembly::storeOnLevelGeneralConstraintSets(std::ofstream& os, size_t level) { storeOnLevelString(os, level, "GeneralConstraintSets"); //for (auto& generalConstraintSet : *generalConstraintSets) { @@ -1358,13 +1362,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 < (int)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 < (int)times->size(); i++) + for (size_t i = 1; i < times->size(); i++) { os << times->at(i) << '\t'; } diff --git a/OndselSolver/ASMTAssembly.h b/OndselSolver/ASMTAssembly.h index 3cf4af5..2c13679 100644 --- a/OndselSolver/ASMTAssembly.h +++ b/OndselSolver/ASMTAssembly.h @@ -81,7 +81,7 @@ namespace MbD { void deleteMbD() override; void createMbD(std::shared_ptr mbdSys, std::shared_ptr mbdUnits) override; void outputFile(std::string filename); - void storeOnLevel(std::ofstream& os, int level) override; + void storeOnLevel(std::ofstream& os, size_t level) override; /* This function performs a one shot solve of the assembly.*/ void solve(); @@ -109,14 +109,14 @@ namespace MbD { void setSimulationParameters(std::shared_ptr simulationParameters); std::shared_ptr partNamed(std::string partName); std::shared_ptr partPartialNamed(std::string partialName); - void storeOnLevelNotes(std::ofstream& os, int level); - void storeOnLevelParts(std::ofstream& os, int level); - void storeOnLevelKinematicIJs(std::ofstream& os, int level); - void storeOnLevelConstraintSets(std::ofstream& os, int level); - void storeOnLevelForceTorques(std::ofstream& os, int level); - void storeOnLevelJoints(std::ofstream& os, int level); - void storeOnLevelMotions(std::ofstream& os, int level); - void storeOnLevelGeneralConstraintSets(std::ofstream& os, int level); + void storeOnLevelNotes(std::ofstream& os, size_t level); + void storeOnLevelParts(std::ofstream& os, size_t level); + void storeOnLevelKinematicIJs(std::ofstream& os, size_t level); + void storeOnLevelConstraintSets(std::ofstream& os, size_t level); + void storeOnLevelForceTorques(std::ofstream& os, size_t level); + void storeOnLevelJoints(std::ofstream& os, size_t level); + void storeOnLevelMotions(std::ofstream& os, size_t level); + void storeOnLevelGeneralConstraintSets(std::ofstream& os, size_t level); void storeOnTimeSeries(std::ofstream& os) override; void setFilename(std::string filename); diff --git a/OndselSolver/ASMTCompoundJoint.cpp b/OndselSolver/ASMTCompoundJoint.cpp index d74d059..904f3dc 100644 --- a/OndselSolver/ASMTCompoundJoint.cpp +++ b/OndselSolver/ASMTCompoundJoint.cpp @@ -37,7 +37,7 @@ void MbD::ASMTCompoundJoint::createMbD(std::shared_ptr mbdSys, std::shar compoundJoint->distanceIJ = distanceIJ; } -void MbD::ASMTCompoundJoint::storeOnLevel(std::ofstream& os, int level) +void MbD::ASMTCompoundJoint::storeOnLevel(std::ofstream& os, size_t level) { ASMTJoint::storeOnLevel(os, level); storeOnLevelString(os, level + 1, "distanceIJ"); diff --git a/OndselSolver/ASMTCompoundJoint.h b/OndselSolver/ASMTCompoundJoint.h index 1c48359..671776e 100644 --- a/OndselSolver/ASMTCompoundJoint.h +++ b/OndselSolver/ASMTCompoundJoint.h @@ -18,7 +18,7 @@ namespace MbD { void parseASMT(std::vector& lines) override; void readDistanceIJ(std::vector& lines); void createMbD(std::shared_ptr mbdSys, std::shared_ptr mbdUnits) override; - void storeOnLevel(std::ofstream& os, int level) override; + void storeOnLevel(std::ofstream& os, size_t level) override; double distanceIJ = 0.0; diff --git a/OndselSolver/ASMTConstantGravity.cpp b/OndselSolver/ASMTConstantGravity.cpp index fb74c8c..8678f94 100644 --- a/OndselSolver/ASMTConstantGravity.cpp +++ b/OndselSolver/ASMTConstantGravity.cpp @@ -44,7 +44,7 @@ void MbD::ASMTConstantGravity::setg(double a, double b, double c) g = std::make_shared>(ListD{ a, b, c }); } -void MbD::ASMTConstantGravity::storeOnLevel(std::ofstream& os, int level) +void MbD::ASMTConstantGravity::storeOnLevel(std::ofstream& os, size_t level) { storeOnLevelString(os, level, "ConstantGravity"); storeOnLevelArray(os, level + 1, *g); diff --git a/OndselSolver/ASMTConstantGravity.h b/OndselSolver/ASMTConstantGravity.h index 1d9dbe2..460231c 100644 --- a/OndselSolver/ASMTConstantGravity.h +++ b/OndselSolver/ASMTConstantGravity.h @@ -25,7 +25,7 @@ namespace MbD { void setg(FColDsptr g); void setg(double a, double b, double c); - void storeOnLevel(std::ofstream& os, int level) override; + void storeOnLevel(std::ofstream& os, size_t level) override; FColDsptr g = std::make_shared>(ListD{ 0.,0.,0. }); }; diff --git a/OndselSolver/ASMTGearJoint.cpp b/OndselSolver/ASMTGearJoint.cpp index bf08097..7fa1aee 100644 --- a/OndselSolver/ASMTGearJoint.cpp +++ b/OndselSolver/ASMTGearJoint.cpp @@ -56,7 +56,7 @@ void MbD::ASMTGearJoint::createMbD(std::shared_ptr mbdSys, std::shared_p gearJoint->radiusJ = radiusJ; } -void MbD::ASMTGearJoint::storeOnLevel(std::ofstream& os, int level) +void MbD::ASMTGearJoint::storeOnLevel(std::ofstream& os, size_t level) { ASMTJoint::storeOnLevel(os, level); storeOnLevelString(os, level + 1, "radiusI"); diff --git a/OndselSolver/ASMTGearJoint.h b/OndselSolver/ASMTGearJoint.h index 9fbd9c5..084ac93 100644 --- a/OndselSolver/ASMTGearJoint.h +++ b/OndselSolver/ASMTGearJoint.h @@ -20,7 +20,7 @@ namespace MbD { void readRadiusI(std::vector& lines); void readRadiusJ(std::vector& lines); void createMbD(std::shared_ptr mbdSys, std::shared_ptr mbdUnits) override; - void storeOnLevel(std::ofstream& os, int level) override; + void storeOnLevel(std::ofstream& os, size_t level) override; double radiusI = 0.0, radiusJ = 0.0, aConstant = 0.0; }; diff --git a/OndselSolver/ASMTGeneralMotion.cpp b/OndselSolver/ASMTGeneralMotion.cpp index e6aa45d..c661af9 100644 --- a/OndselSolver/ASMTGeneralMotion.cpp +++ b/OndselSolver/ASMTGeneralMotion.cpp @@ -70,8 +70,8 @@ void MbD::ASMTGeneralMotion::readRotationOrder(std::vector& lines) assert(lines[0].find("RotationOrder") != std::string::npos); lines.erase(lines.begin()); std::istringstream iss(lines[0]); - rotationOrder = std::make_shared>(); - int i; + rotationOrder = std::make_shared>(); + size_t i; while (iss >> i) { rotationOrder->push_back(i); } @@ -146,7 +146,7 @@ void MbD::ASMTGeneralMotion::createMbD(std::shared_ptr mbdSys, std::shar fullMotion->fangIJJ = fangIJJ; } -void MbD::ASMTGeneralMotion::storeOnLevel(std::ofstream& os, int level) +void MbD::ASMTGeneralMotion::storeOnLevel(std::ofstream& os, size_t level) { storeOnLevelString(os, level, "GeneralMotion"); storeOnLevelString(os, level + 1, "Name"); diff --git a/OndselSolver/ASMTGeneralMotion.h b/OndselSolver/ASMTGeneralMotion.h index f87c7ec..da925aa 100644 --- a/OndselSolver/ASMTGeneralMotion.h +++ b/OndselSolver/ASMTGeneralMotion.h @@ -21,12 +21,12 @@ namespace MbD { void readRotationOrder(std::vector& lines); std::shared_ptr mbdClassNew() override; void createMbD(std::shared_ptr mbdSys, std::shared_ptr mbdUnits) override; - void storeOnLevel(std::ofstream& os, int level) override; + void storeOnLevel(std::ofstream& os, size_t level) override; void storeOnTimeSeries(std::ofstream& os) override; std::shared_ptr> rIJI = std::make_shared>(3); std::shared_ptr> angIJJ = std::make_shared>(3); - std::shared_ptr> rotationOrder = std::make_shared>(std::initializer_list{ 1, 2, 3 }); + std::shared_ptr> rotationOrder = std::make_shared>(std::initializer_list{ 1, 2, 3 }); }; } diff --git a/OndselSolver/ASMTInPlaneJoint.cpp b/OndselSolver/ASMTInPlaneJoint.cpp index b15371d..23b2a2f 100644 --- a/OndselSolver/ASMTInPlaneJoint.cpp +++ b/OndselSolver/ASMTInPlaneJoint.cpp @@ -29,7 +29,7 @@ void MbD::ASMTInPlaneJoint::createMbD(std::shared_ptr mbdSys, std::share inPlaneJoint->offset = offset; } -void MbD::ASMTInPlaneJoint::storeOnLevel(std::ofstream& os, int level) +void MbD::ASMTInPlaneJoint::storeOnLevel(std::ofstream& os, size_t level) { ASMTJoint::storeOnLevel(os, level); storeOnLevelString(os, level + 1, "offset"); diff --git a/OndselSolver/ASMTInPlaneJoint.h b/OndselSolver/ASMTInPlaneJoint.h index d6bdf3d..7c08de0 100644 --- a/OndselSolver/ASMTInPlaneJoint.h +++ b/OndselSolver/ASMTInPlaneJoint.h @@ -18,7 +18,7 @@ namespace MbD { void parseASMT(std::vector& lines) override; void readOffset(std::vector& lines); void createMbD(std::shared_ptr mbdSys, std::shared_ptr mbdUnits) override; - void storeOnLevel(std::ofstream& os, int level) override; + void storeOnLevel(std::ofstream& os, size_t level) override; double offset = 0.0; diff --git a/OndselSolver/ASMTItem.cpp b/OndselSolver/ASMTItem.cpp index a56f3a6..4cbf03f 100644 --- a/OndselSolver/ASMTItem.cpp +++ b/OndselSolver/ASMTItem.cpp @@ -199,39 +199,39 @@ std::shared_ptr MbD::ASMTItem::sptrConstant(double value) return std::make_shared(value); } -void MbD::ASMTItem::storeOnLevel(std::ofstream&, int) +void MbD::ASMTItem::storeOnLevel(std::ofstream&, size_t) { noop(); assert(false); } -void MbD::ASMTItem::storeOnLevelTabs(std::ofstream& os, int level) +void MbD::ASMTItem::storeOnLevelTabs(std::ofstream& os, size_t level) { - for (int i = 0; i < level; i++) + for (size_t i = 0; i < level; i++) { os << '\t'; } } -void MbD::ASMTItem::storeOnLevelString(std::ofstream& os, int level, std::string str) +void MbD::ASMTItem::storeOnLevelString(std::ofstream& os, size_t level, std::string str) { storeOnLevelTabs(os, level); os << str << std::endl; } -void MbD::ASMTItem::storeOnLevelDouble(std::ofstream& os, int level, double value) +void MbD::ASMTItem::storeOnLevelDouble(std::ofstream& os, size_t level, double value) { storeOnLevelTabs(os, level); os << value << std::endl; } -void MbD::ASMTItem::storeOnLevelInt(std::ofstream& os, int level, int i) +void MbD::ASMTItem::storeOnLevelInt(std::ofstream& os, size_t level, int i) { storeOnLevelTabs(os, level); os << i << std::endl; } -void MbD::ASMTItem::storeOnLevelBool(std::ofstream& os, int level, bool value) +void MbD::ASMTItem::storeOnLevelBool(std::ofstream& os, size_t level, bool value) { storeOnLevelTabs(os, level); if (value) { @@ -242,17 +242,17 @@ void MbD::ASMTItem::storeOnLevelBool(std::ofstream& os, int level, bool value) } } -void MbD::ASMTItem::storeOnLevelArray(std::ofstream& os, int level, std::vector array) +void MbD::ASMTItem::storeOnLevelArray(std::ofstream& os, size_t level, std::vector array) { storeOnLevelTabs(os, level); - for (int i = 0; i < (int)array.size(); i++) + for (size_t i = 0; i < array.size(); i++) { os << array[i] << '\t'; } os << std::endl; } -void MbD::ASMTItem::storeOnLevelName(std::ofstream& os, int level) +void MbD::ASMTItem::storeOnLevelName(std::ofstream& os, size_t level) { storeOnLevelString(os, level, "Name"); storeOnLevelString(os, level + 1, name); diff --git a/OndselSolver/ASMTItem.h b/OndselSolver/ASMTItem.h index 848cc7b..8dbb145 100644 --- a/OndselSolver/ASMTItem.h +++ b/OndselSolver/ASMTItem.h @@ -48,16 +48,16 @@ namespace MbD { virtual void outputResults(AnalysisType type); std::shared_ptr mbdUnits(); std::shared_ptr sptrConstant(double value); - virtual void storeOnLevel(std::ofstream& os, int level); - virtual void storeOnLevelTabs(std::ofstream& os, int level); - virtual void storeOnLevelString(std::ofstream& os, int level, std::string str); - virtual void storeOnLevelDouble(std::ofstream& os, int level, double value); - virtual void storeOnLevelInt(std::ofstream& os, int level, int i); - virtual void storeOnLevelBool(std::ofstream& os, int level, bool value); + virtual void storeOnLevel(std::ofstream& os, size_t level); + virtual void storeOnLevelTabs(std::ofstream& os, size_t level); + virtual void storeOnLevelString(std::ofstream& os, size_t level, std::string str); + virtual void storeOnLevelDouble(std::ofstream& os, size_t level, double value); + virtual void storeOnLevelInt(std::ofstream& os, size_t level, int i); + virtual void storeOnLevelBool(std::ofstream& os, size_t level, bool value); //template - //void storeOnLevelArray(std::ofstream& os, int level, std::vector array); - void storeOnLevelArray(std::ofstream& os, int level, std::vector array); - void storeOnLevelName(std::ofstream& os, int level); + //void storeOnLevelArray(std::ofstream& os, size_t level, std::vector array); + void storeOnLevelArray(std::ofstream& os, size_t level, std::vector array); + void storeOnLevelName(std::ofstream& os, size_t level); virtual void storeOnTimeSeries(std::ofstream& os); void logString(std::string& str); void logString(const char* chars); @@ -67,10 +67,10 @@ namespace MbD { std::shared_ptr mbdObject; }; //template - //inline void ASMTItem::storeOnLevelArray(std::ofstream& os, int level, std::vector array) + //inline void ASMTItem::storeOnLevelArray(std::ofstream& os, size_t 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 c5e0f9a..6b73621 100644 --- a/OndselSolver/ASMTItemIJ.cpp +++ b/OndselSolver/ASMTItemIJ.cpp @@ -97,7 +97,7 @@ void MbD::ASMTItemIJ::readTZonIs(std::vector& lines) lines.erase(lines.begin()); } -void MbD::ASMTItemIJ::storeOnLevel(std::ofstream& os, int level) +void MbD::ASMTItemIJ::storeOnLevel(std::ofstream& os, size_t level) { storeOnLevelString(os, level + 1, "MarkerI"); storeOnLevelString(os, level + 2, markerI); @@ -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 < (int)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 < (int)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 < (int)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 < (int)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 < (int)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 < (int)tzs->size(); i++) + for (size_t i = 0; i < tzs->size(); i++) { os << tzs->at(i) << '\t'; } diff --git a/OndselSolver/ASMTItemIJ.h b/OndselSolver/ASMTItemIJ.h index 4788499..c1118db 100644 --- a/OndselSolver/ASMTItemIJ.h +++ b/OndselSolver/ASMTItemIJ.h @@ -27,7 +27,7 @@ namespace MbD { void readTXonIs(std::vector& lines); void readTYonIs(std::vector& lines); void readTZonIs(std::vector& lines); - void storeOnLevel(std::ofstream& os, int level) override; + void storeOnLevel(std::ofstream& os, size_t level) override; void storeOnTimeSeries(std::ofstream& os) override; std::string markerI, markerJ; diff --git a/OndselSolver/ASMTJoint.cpp b/OndselSolver/ASMTJoint.cpp index 148852a..79e3372 100644 --- a/OndselSolver/ASMTJoint.cpp +++ b/OndselSolver/ASMTJoint.cpp @@ -36,7 +36,7 @@ void MbD::ASMTJoint::readJointSeries(std::vector& lines) readTZonIs(lines); } -void MbD::ASMTJoint::storeOnLevel(std::ofstream& os, int level) +void MbD::ASMTJoint::storeOnLevel(std::ofstream& os, size_t level) { auto jointType = classname(); jointType = jointType.substr(4, jointType.size() - 4); //Remove ASMT in name diff --git a/OndselSolver/ASMTJoint.h b/OndselSolver/ASMTJoint.h index 647ef23..fc02378 100644 --- a/OndselSolver/ASMTJoint.h +++ b/OndselSolver/ASMTJoint.h @@ -19,7 +19,7 @@ namespace MbD { public: void parseASMT(std::vector& lines) override; void readJointSeries(std::vector& lines); - void storeOnLevel(std::ofstream& os, int level) override; + void storeOnLevel(std::ofstream& os, size_t level) override; void storeOnTimeSeries(std::ofstream& os) override; std::shared_ptr>> jointSeries; diff --git a/OndselSolver/ASMTMarker.cpp b/OndselSolver/ASMTMarker.cpp index 3355652..720a902 100644 --- a/OndselSolver/ASMTMarker.cpp +++ b/OndselSolver/ASMTMarker.cpp @@ -62,7 +62,7 @@ void ASMTMarker::createMbD(std::shared_ptr, std::shared_ptr mbdUn mbdObject = mkr->endFrames->at(0); } -void ASMTMarker::storeOnLevel(std::ofstream& os, int level) +void ASMTMarker::storeOnLevel(std::ofstream& os, size_t level) { storeOnLevelString(os, level, "Marker"); storeOnLevelString(os, level + 1, "Name"); diff --git a/OndselSolver/ASMTMarker.h b/OndselSolver/ASMTMarker.h index fd06052..9677319 100644 --- a/OndselSolver/ASMTMarker.h +++ b/OndselSolver/ASMTMarker.h @@ -22,7 +22,7 @@ namespace MbD { FColDsptr rpmp(); FMatDsptr aApm(); void createMbD(std::shared_ptr mbdSys, std::shared_ptr mbdUnits) override; - void storeOnLevel(std::ofstream& os, int level) override; + void storeOnLevel(std::ofstream& os, size_t level) override; }; } diff --git a/OndselSolver/ASMTMotion.cpp b/OndselSolver/ASMTMotion.cpp index 7967d99..8432ec7 100644 --- a/OndselSolver/ASMTMotion.cpp +++ b/OndselSolver/ASMTMotion.cpp @@ -14,7 +14,7 @@ using namespace MbD; void ASMTMotion::readMotionSeries(std::vector& lines) { std::string str = lines[0]; - std::string substr = "MotionSeries"; + std::string substr = "tionSeries"; auto pos = str.find(substr); assert(pos != std::string::npos); str.erase(0, pos + substr.length()); @@ -33,7 +33,7 @@ void ASMTMotion::initMarkers() { } -void ASMTMotion::storeOnLevel(std::ofstream&, int) +void ASMTMotion::storeOnLevel(std::ofstream&, size_t) { assert(false); } diff --git a/OndselSolver/ASMTMotion.h b/OndselSolver/ASMTMotion.h index 3b3b911..f388ece 100644 --- a/OndselSolver/ASMTMotion.h +++ b/OndselSolver/ASMTMotion.h @@ -18,7 +18,7 @@ namespace MbD { public: void readMotionSeries(std::vector& lines); virtual void initMarkers(); - void storeOnLevel(std::ofstream& os, int level) override; + void storeOnLevel(std::ofstream& os, size_t level) override; void storeOnTimeSeries(std::ofstream& os) override; std::shared_ptr>> motionSeries; diff --git a/OndselSolver/ASMTPart.cpp b/OndselSolver/ASMTPart.cpp index 7731884..be9a1fc 100644 --- a/OndselSolver/ASMTPart.cpp +++ b/OndselSolver/ASMTPart.cpp @@ -118,7 +118,7 @@ void MbD::ASMTPart::createMbD(std::shared_ptr mbdSys, std::shared_ptr(mbdObject)->asFixed(); } -void MbD::ASMTPart::storeOnLevel(std::ofstream& os, int level) +void MbD::ASMTPart::storeOnLevel(std::ofstream& os, size_t level) { storeOnLevelString(os, level, "Part"); storeOnLevelName(os, level + 1); @@ -133,7 +133,7 @@ void MbD::ASMTPart::storeOnLevel(std::ofstream& os, int level) storeOnLevelRefSurfaces(os, level + 1); } -void MbD::ASMTPart::storeOnLevelMassMarker(std::ofstream& os, int level) +void MbD::ASMTPart::storeOnLevelMassMarker(std::ofstream& os, size_t level) { principalMassMarker->storeOnLevel(os, level); } diff --git a/OndselSolver/ASMTPart.h b/OndselSolver/ASMTPart.h index c52f5ae..fca1860 100644 --- a/OndselSolver/ASMTPart.h +++ b/OndselSolver/ASMTPart.h @@ -25,8 +25,8 @@ namespace MbD { FColDsptr omeOpO() override; ASMTPart* part() override; void createMbD(std::shared_ptr mbdSys, std::shared_ptr mbdUnits) override; - void storeOnLevel(std::ofstream& os, int level) override; - void storeOnLevelMassMarker(std::ofstream& os, int level); + void storeOnLevel(std::ofstream& os, size_t level) override; + void storeOnLevelMassMarker(std::ofstream& os, size_t level); void storeOnTimeSeries(std::ofstream& os) override; //std::shared_ptr>> featureOrder; diff --git a/OndselSolver/ASMTPrincipalMassMarker.cpp b/OndselSolver/ASMTPrincipalMassMarker.cpp index 662a9c8..77c206c 100644 --- a/OndselSolver/ASMTPrincipalMassMarker.cpp +++ b/OndselSolver/ASMTPrincipalMassMarker.cpp @@ -19,7 +19,7 @@ MbD::ASMTPrincipalMassMarker::ASMTPrincipalMassMarker() void MbD::ASMTPrincipalMassMarker::parseASMT(std::vector& lines) { - int pos = (int)lines[0].find_first_not_of("\t"); + auto pos = lines[0].find_first_not_of("\t"); auto leadingTabs = lines[0].substr(0, pos); assert(lines[0] == (leadingTabs + "Name")); lines.erase(lines.begin()); @@ -32,7 +32,7 @@ void MbD::ASMTPrincipalMassMarker::parseASMT(std::vector& lines) assert(lines[0] == (leadingTabs + "RotationMatrix")); lines.erase(lines.begin()); rotationMatrix = std::make_shared>(3); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto row = readRowOfDoubles(lines[0]); rotationMatrix->atiput(i, row); @@ -47,7 +47,7 @@ void MbD::ASMTPrincipalMassMarker::parseASMT(std::vector& lines) momentOfInertias = std::make_shared>(3); auto row = readRowOfDoubles(lines[0]); lines.erase(lines.begin()); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { momentOfInertias->atiput(i, row->at(i)); } @@ -78,7 +78,7 @@ void MbD::ASMTPrincipalMassMarker::setMomentOfInertias(double a, double b, doubl momentOfInertias = std::make_shared>(ListD{ a, b, c }); } -void MbD::ASMTPrincipalMassMarker::storeOnLevel(std::ofstream& os, int level) +void MbD::ASMTPrincipalMassMarker::storeOnLevel(std::ofstream& os, size_t level) { storeOnLevelString(os, level, "PrincipalMassMarker"); storeOnLevelString(os, level + 1, "Name"); diff --git a/OndselSolver/ASMTPrincipalMassMarker.h b/OndselSolver/ASMTPrincipalMassMarker.h index e2f09a9..0385e96 100644 --- a/OndselSolver/ASMTPrincipalMassMarker.h +++ b/OndselSolver/ASMTPrincipalMassMarker.h @@ -23,7 +23,7 @@ namespace MbD { // Overloads to simplify syntax. void setMomentOfInertias(double a, double b, double c); - void storeOnLevel(std::ofstream& os, int level) override; + void storeOnLevel(std::ofstream& os, size_t level) override; double mass = 1.0; double density = 10.0; diff --git a/OndselSolver/ASMTRackPinionJoint.cpp b/OndselSolver/ASMTRackPinionJoint.cpp index 727d540..d52accd 100644 --- a/OndselSolver/ASMTRackPinionJoint.cpp +++ b/OndselSolver/ASMTRackPinionJoint.cpp @@ -42,7 +42,7 @@ void MbD::ASMTRackPinionJoint::createMbD(std::shared_ptr mbdSys, std::sh rackPinJoint->pitchRadius = pitchRadius; } -void MbD::ASMTRackPinionJoint::storeOnLevel(std::ofstream& os, int level) +void MbD::ASMTRackPinionJoint::storeOnLevel(std::ofstream& os, size_t level) { ASMTJoint::storeOnLevel(os, level); storeOnLevelString(os, level + 1, "pitchRadius"); diff --git a/OndselSolver/ASMTRackPinionJoint.h b/OndselSolver/ASMTRackPinionJoint.h index b439a46..6c2e0e7 100644 --- a/OndselSolver/ASMTRackPinionJoint.h +++ b/OndselSolver/ASMTRackPinionJoint.h @@ -19,7 +19,7 @@ namespace MbD { void parseASMT(std::vector& lines) override; void readPitchRadius(std::vector& lines); void createMbD(std::shared_ptr mbdSys, std::shared_ptr mbdUnits) override; - void storeOnLevel(std::ofstream& os, int level) override; + void storeOnLevel(std::ofstream& os, size_t level) override; double pitchRadius = 0.0, aConstant = 0.0; }; diff --git a/OndselSolver/ASMTRefCurve.cpp b/OndselSolver/ASMTRefCurve.cpp index 3846491..f418be9 100644 --- a/OndselSolver/ASMTRefCurve.cpp +++ b/OndselSolver/ASMTRefCurve.cpp @@ -16,7 +16,7 @@ void MbD::ASMTRefCurve::parseASMT(std::vector&) assert(false); } -void MbD::ASMTRefCurve::storeOnLevel(std::ofstream&, int) +void MbD::ASMTRefCurve::storeOnLevel(std::ofstream&, size_t) { assert(false); } diff --git a/OndselSolver/ASMTRefCurve.h b/OndselSolver/ASMTRefCurve.h index 695b7a0..bb21464 100644 --- a/OndselSolver/ASMTRefCurve.h +++ b/OndselSolver/ASMTRefCurve.h @@ -16,7 +16,7 @@ namespace MbD { // public: void parseASMT(std::vector& lines) override; - void storeOnLevel(std::ofstream& os, int level) override; + void storeOnLevel(std::ofstream& os, size_t level) override; }; diff --git a/OndselSolver/ASMTRefItem.cpp b/OndselSolver/ASMTRefItem.cpp index 40be210..0367e7b 100644 --- a/OndselSolver/ASMTRefItem.cpp +++ b/OndselSolver/ASMTRefItem.cpp @@ -43,7 +43,7 @@ void MbD::ASMTRefItem::readMarker(std::vector& lines) marker->owner = this; } -void MbD::ASMTRefItem::storeOnLevel(std::ofstream& os, int level) +void MbD::ASMTRefItem::storeOnLevel(std::ofstream& os, size_t level) { storeOnLevelString(os, level, "RefPoints"); ASMTSpatialItem::storeOnLevel(os, level+1); diff --git a/OndselSolver/ASMTRefItem.h b/OndselSolver/ASMTRefItem.h index c536b41..e60881c 100644 --- a/OndselSolver/ASMTRefItem.h +++ b/OndselSolver/ASMTRefItem.h @@ -20,7 +20,7 @@ namespace MbD { void addMarker(std::shared_ptr marker); void readMarkers(std::vector& lines); void readMarker(std::vector& lines); - void storeOnLevel(std::ofstream& os, int level) override; + void storeOnLevel(std::ofstream& os, size_t level) override; std::shared_ptr>> markers = std::make_shared>>(); diff --git a/OndselSolver/ASMTRefPoint.cpp b/OndselSolver/ASMTRefPoint.cpp index dc87576..3adc1c1 100644 --- a/OndselSolver/ASMTRefPoint.cpp +++ b/OndselSolver/ASMTRefPoint.cpp @@ -31,7 +31,7 @@ void MbD::ASMTRefPoint::createMbD(std::shared_ptr mbdSys, std::shared_pt } } -void MbD::ASMTRefPoint::storeOnLevel(std::ofstream& os, int level) +void MbD::ASMTRefPoint::storeOnLevel(std::ofstream& os, size_t level) { storeOnLevelString(os, level, "RefPoint"); ASMTSpatialItem::storeOnLevel(os, level); diff --git a/OndselSolver/ASMTRefPoint.h b/OndselSolver/ASMTRefPoint.h index 9c1897f..72eacaf 100644 --- a/OndselSolver/ASMTRefPoint.h +++ b/OndselSolver/ASMTRefPoint.h @@ -20,7 +20,7 @@ namespace MbD { void parseASMT(std::vector& lines) override; std::string fullName(std::string partialName) override; void createMbD(std::shared_ptr mbdSys, std::shared_ptr mbdUnits) override; - void storeOnLevel(std::ofstream& os, int level) override; + void storeOnLevel(std::ofstream& os, size_t level) override; }; diff --git a/OndselSolver/ASMTRefSurface.cpp b/OndselSolver/ASMTRefSurface.cpp index 980f0a6..2f02744 100644 --- a/OndselSolver/ASMTRefSurface.cpp +++ b/OndselSolver/ASMTRefSurface.cpp @@ -16,7 +16,7 @@ void MbD::ASMTRefSurface::parseASMT(std::vector&) assert(false); } -void MbD::ASMTRefSurface::storeOnLevel(std::ofstream&, int) +void MbD::ASMTRefSurface::storeOnLevel(std::ofstream&, size_t) { assert(false); } diff --git a/OndselSolver/ASMTRefSurface.h b/OndselSolver/ASMTRefSurface.h index 034c8d1..4b65016 100644 --- a/OndselSolver/ASMTRefSurface.h +++ b/OndselSolver/ASMTRefSurface.h @@ -16,7 +16,7 @@ namespace MbD { // public: void parseASMT(std::vector& lines) override; - void storeOnLevel(std::ofstream& os, int level) override; + void storeOnLevel(std::ofstream& os, size_t level) override; }; diff --git a/OndselSolver/ASMTRotationalMotion.cpp b/OndselSolver/ASMTRotationalMotion.cpp index 34819c8..fbb130a 100644 --- a/OndselSolver/ASMTRotationalMotion.cpp +++ b/OndselSolver/ASMTRotationalMotion.cpp @@ -92,7 +92,7 @@ void MbD::ASMTRotationalMotion::setRotationZ(std::string rotZ) rotationZ = rotZ; } -void MbD::ASMTRotationalMotion::storeOnLevel(std::ofstream& os, int level) +void MbD::ASMTRotationalMotion::storeOnLevel(std::ofstream& os, size_t level) { storeOnLevelString(os, level, "RotationalMotion"); storeOnLevelString(os, level + 1, "Name"); diff --git a/OndselSolver/ASMTRotationalMotion.h b/OndselSolver/ASMTRotationalMotion.h index f991d68..c9ecc6f 100644 --- a/OndselSolver/ASMTRotationalMotion.h +++ b/OndselSolver/ASMTRotationalMotion.h @@ -24,7 +24,7 @@ namespace MbD { std::shared_ptr mbdClassNew() override; void setMotionJoint(std::string motionJoint); void setRotationZ(std::string rotZ); - void storeOnLevel(std::ofstream& os, int level) override; + void storeOnLevel(std::ofstream& os, size_t level) override; void storeOnTimeSeries(std::ofstream& os) override; std::string motionJoint, rotationZ; diff --git a/OndselSolver/ASMTScrewJoint.cpp b/OndselSolver/ASMTScrewJoint.cpp index 9d582e7..9499196 100644 --- a/OndselSolver/ASMTScrewJoint.cpp +++ b/OndselSolver/ASMTScrewJoint.cpp @@ -42,7 +42,7 @@ void MbD::ASMTScrewJoint::createMbD(std::shared_ptr mbdSys, std::shared_ screwJoint->pitch = pitch; } -void MbD::ASMTScrewJoint::storeOnLevel(std::ofstream& os, int level) +void MbD::ASMTScrewJoint::storeOnLevel(std::ofstream& os, size_t level) { ASMTJoint::storeOnLevel(os, level); storeOnLevelString(os, level + 1, "pitch"); diff --git a/OndselSolver/ASMTScrewJoint.h b/OndselSolver/ASMTScrewJoint.h index a5962c6..e60bced 100644 --- a/OndselSolver/ASMTScrewJoint.h +++ b/OndselSolver/ASMTScrewJoint.h @@ -19,7 +19,7 @@ namespace MbD { void parseASMT(std::vector& lines) override; void readPitch(std::vector& lines); void createMbD(std::shared_ptr mbdSys, std::shared_ptr mbdUnits) override; - void storeOnLevel(std::ofstream& os, int level) override; + void storeOnLevel(std::ofstream& os, size_t level) override; double pitch = 0.0, aConstant = 0.0; }; diff --git a/OndselSolver/ASMTSimulationParameters.cpp b/OndselSolver/ASMTSimulationParameters.cpp index 8f10a3a..7597ed5 100644 --- a/OndselSolver/ASMTSimulationParameters.cpp +++ b/OndselSolver/ASMTSimulationParameters.cpp @@ -14,7 +14,7 @@ void MbD::ASMTSimulationParameters::parseASMT(std::vector& lines) { //tstart, tend, hmin, hmax, hout, errorTol; - int pos = (int)lines[0].find_first_not_of("\t"); + auto pos = lines[0].find_first_not_of("\t"); auto leadingTabs = lines[0].substr(0, pos); assert(lines[0] == (leadingTabs + "tstart")); lines.erase(lines.begin()); @@ -73,13 +73,13 @@ void MbD::ASMTSimulationParameters::seterrorTol(double tol) errorTol = tol; } -void MbD::ASMTSimulationParameters::setmaxIter(int maxIter) +void MbD::ASMTSimulationParameters::setmaxIter(size_t maxIter) { iterMaxPosKine = maxIter; iterMaxAccKine = maxIter; } -void MbD::ASMTSimulationParameters::storeOnLevel(std::ofstream& os, int level) +void MbD::ASMTSimulationParameters::storeOnLevel(std::ofstream& os, size_t level) { storeOnLevelString(os, level, "SimulationParameters"); storeOnLevelString(os, level + 1, "tstart"); diff --git a/OndselSolver/ASMTSimulationParameters.h b/OndselSolver/ASMTSimulationParameters.h index 8083a3f..60c3410 100644 --- a/OndselSolver/ASMTSimulationParameters.h +++ b/OndselSolver/ASMTSimulationParameters.h @@ -22,13 +22,13 @@ namespace MbD { void sethmax(double hmax); void sethout(double hout); void seterrorTol(double errorTol); - void setmaxIter(int maxIter); - void storeOnLevel(std::ofstream& os, int level) override; + void setmaxIter(size_t maxIter); + void storeOnLevel(std::ofstream& os, size_t level) override; double tstart = 0.0, tend = 1.0, hmin = 1.0e-9, hmax = 1.0e9, hout = 0.1, errorTol = 1.0e-6; double errorTolPosKine = 1.0e-6, errorTolAccKine = 1.0e-6, corAbsTol = 1.0e-6, corRelTol = 1.0e-6; double intAbsTol = 1.0e-6, intRelTol = 1.0e-6, translationLimit = 1.0e9, rotationLimit = 1.0e9; - int iterMaxPosKine = 25, iterMaxAccKine = 25, iterMaxDyn = 4, orderMax = 5; + size_t iterMaxPosKine = 25, iterMaxAccKine = 25, iterMaxDyn = 4, orderMax = 5; }; } diff --git a/OndselSolver/ASMTSpatialContainer.cpp b/OndselSolver/ASMTSpatialContainer.cpp index 21bf372..7492d91 100644 --- a/OndselSolver/ASMTSpatialContainer.cpp +++ b/OndselSolver/ASMTSpatialContainer.cpp @@ -501,7 +501,7 @@ std::shared_ptr>> MbD::ASMTSpatialContai return markers; } -void MbD::ASMTSpatialContainer::storeOnLevel(std::ofstream& os, int level) +void MbD::ASMTSpatialContainer::storeOnLevel(std::ofstream& os, size_t level) { ASMTSpatialItem::storeOnLevel(os, level); storeOnLevelVelocity(os, level + 1); @@ -557,7 +557,7 @@ void MbD::ASMTSpatialContainer::setOmega3D(double a, double b, double c) omega3D = std::make_shared>(ListD{ a, b, c }); } -void MbD::ASMTSpatialContainer::storeOnLevelVelocity(std::ofstream& os, int level) +void MbD::ASMTSpatialContainer::storeOnLevelVelocity(std::ofstream& os, size_t level) { storeOnLevelString(os, level, "Velocity3D"); if (vxs == nullptr || vxs->empty()) { @@ -569,7 +569,7 @@ void MbD::ASMTSpatialContainer::storeOnLevelVelocity(std::ofstream& os, int leve } } -void MbD::ASMTSpatialContainer::storeOnLevelOmega(std::ofstream& os, int level) +void MbD::ASMTSpatialContainer::storeOnLevelOmega(std::ofstream& os, size_t level) { storeOnLevelString(os, level, "Omega3D"); if (omexs == nullptr || omexs->empty()) { @@ -581,7 +581,7 @@ void MbD::ASMTSpatialContainer::storeOnLevelOmega(std::ofstream& os, int level) } } -void MbD::ASMTSpatialContainer::storeOnLevelRefPoints(std::ofstream& os, int level) +void MbD::ASMTSpatialContainer::storeOnLevelRefPoints(std::ofstream& os, size_t level) { storeOnLevelString(os, level, "RefPoints"); for (auto& refPoint : *refPoints) @@ -590,7 +590,7 @@ void MbD::ASMTSpatialContainer::storeOnLevelRefPoints(std::ofstream& os, int lev } } -void MbD::ASMTSpatialContainer::storeOnLevelRefCurves(std::ofstream& os, int level) +void MbD::ASMTSpatialContainer::storeOnLevelRefCurves(std::ofstream& os, size_t level) { storeOnLevelString(os, level, "RefCurves"); for (auto& refCurve : *refCurves) @@ -599,7 +599,7 @@ void MbD::ASMTSpatialContainer::storeOnLevelRefCurves(std::ofstream& os, int lev } } -void MbD::ASMTSpatialContainer::storeOnLevelRefSurfaces(std::ofstream& os, int level) +void MbD::ASMTSpatialContainer::storeOnLevelRefSurfaces(std::ofstream& os, size_t level) { storeOnLevelString(os, level, "RefSurfaces"); for (auto& refSurface : *refSurfaces) @@ -611,116 +611,116 @@ void MbD::ASMTSpatialContainer::storeOnLevelRefSurfaces(std::ofstream& os, int l void MbD::ASMTSpatialContainer::storeOnTimeSeries(std::ofstream& os) { os << "X\t"; - for (int i = 0; i < (int)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 < (int)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 < (int)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 < (int)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 < (int)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 < (int)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 < (int)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 < (int)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 < (int)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 < (int)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 < (int)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 < (int)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 < (int)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 < (int)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 < (int)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 < (int)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 < (int)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 < (int)alpzs->size(); i++) + for (size_t i = 0; i < alpzs->size(); i++) { os << alpzs->at(i) << '\t'; } os << std::endl; } -FColDsptr MbD::ASMTSpatialContainer::getVelocity3D(int i) +FColDsptr MbD::ASMTSpatialContainer::getVelocity3D(size_t i) { auto vec3 = std::make_shared>(3); vec3->atiput(0, vxs->at(i)); @@ -729,7 +729,7 @@ FColDsptr MbD::ASMTSpatialContainer::getVelocity3D(int i) return vec3; } -FColDsptr MbD::ASMTSpatialContainer::getOmega3D(int i) +FColDsptr MbD::ASMTSpatialContainer::getOmega3D(size_t i) { auto vec3 = std::make_shared>(3); vec3->atiput(0, omexs->at(i)); diff --git a/OndselSolver/ASMTSpatialContainer.h b/OndselSolver/ASMTSpatialContainer.h index 3581726..ca651d3 100644 --- a/OndselSolver/ASMTSpatialContainer.h +++ b/OndselSolver/ASMTSpatialContainer.h @@ -80,15 +80,15 @@ namespace MbD { void readOmega3D(std::vector& lines); void setVelocity3D(double a, double b, double c); void setOmega3D(double a, double b, double c); - void storeOnLevel(std::ofstream& os, int level) override; - void storeOnLevelVelocity(std::ofstream& os, int level); - void storeOnLevelOmega(std::ofstream& os, int level); - void storeOnLevelRefPoints(std::ofstream& os, int level); - void storeOnLevelRefCurves(std::ofstream& os, int level); - void storeOnLevelRefSurfaces(std::ofstream& os, int level); + void storeOnLevel(std::ofstream& os, size_t level) override; + void storeOnLevelVelocity(std::ofstream& os, size_t level); + void storeOnLevelOmega(std::ofstream& os, size_t level); + void storeOnLevelRefPoints(std::ofstream& os, size_t level); + void storeOnLevelRefCurves(std::ofstream& os, size_t level); + void storeOnLevelRefSurfaces(std::ofstream& os, size_t level); void storeOnTimeSeries(std::ofstream& os) override; - FColDsptr getVelocity3D(int i); - FColDsptr getOmega3D(int i); + FColDsptr getVelocity3D(size_t i); + FColDsptr getOmega3D(size_t i); FColDsptr velocity3D = std::make_shared>(3); FColDsptr omega3D = std::make_shared>(3); diff --git a/OndselSolver/ASMTSpatialItem.cpp b/OndselSolver/ASMTSpatialItem.cpp index 91bf043..d317c1e 100644 --- a/OndselSolver/ASMTSpatialItem.cpp +++ b/OndselSolver/ASMTSpatialItem.cpp @@ -53,7 +53,7 @@ void MbD::ASMTSpatialItem::readRotationMatrix(std::vector& lines) assert(lines[0].find("RotationMatrix") != std::string::npos); lines.erase(lines.begin()); rotationMatrix = std::make_shared>(3, 0); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto& row = rotationMatrix->at(i); std::istringstream iss(lines[0]); @@ -98,13 +98,13 @@ void MbD::ASMTSpatialItem::setRotationMatrix(double v11, double v12, double v13, }); } -void MbD::ASMTSpatialItem::storeOnLevel(std::ofstream& os, int level) +void MbD::ASMTSpatialItem::storeOnLevel(std::ofstream& os, size_t level) { storeOnLevelPosition(os, level + 1); storeOnLevelRotationMatrix(os, level + 1); } -void MbD::ASMTSpatialItem::storeOnLevelPosition(std::ofstream& os, int level) +void MbD::ASMTSpatialItem::storeOnLevelPosition(std::ofstream& os, size_t level) { storeOnLevelString(os, level, "Position3D"); if (xs == nullptr || xs->empty()) { @@ -116,18 +116,18 @@ void MbD::ASMTSpatialItem::storeOnLevelPosition(std::ofstream& os, int level) } } -void MbD::ASMTSpatialItem::storeOnLevelRotationMatrix(std::ofstream& os, int level) +void MbD::ASMTSpatialItem::storeOnLevelRotationMatrix(std::ofstream& os, size_t level) { storeOnLevelString(os, level, "RotationMatrix"); if (xs == nullptr || xs->empty()) { - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { storeOnLevelArray(os, level + 1, *rotationMatrix->at(i)); } } else { auto rotMat = getRotationMatrix(0); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { storeOnLevelArray(os, level + 1, *rotMat->at(i)); } @@ -135,7 +135,7 @@ void MbD::ASMTSpatialItem::storeOnLevelRotationMatrix(std::ofstream& os, int lev } -FColDsptr MbD::ASMTSpatialItem::getPosition3D(int i) +FColDsptr MbD::ASMTSpatialItem::getPosition3D(size_t i) { auto vec3 = std::make_shared>(3); vec3->atiput(0, xs->at(i)); @@ -144,7 +144,7 @@ FColDsptr MbD::ASMTSpatialItem::getPosition3D(int i) return vec3; } -FMatDsptr MbD::ASMTSpatialItem::getRotationMatrix(int i) +FMatDsptr MbD::ASMTSpatialItem::getRotationMatrix(size_t i) { auto bryantAngles = std::make_shared>(); bryantAngles->setRotOrder(1, 2, 3); diff --git a/OndselSolver/ASMTSpatialItem.h b/OndselSolver/ASMTSpatialItem.h index acbf796..82721bb 100644 --- a/OndselSolver/ASMTSpatialItem.h +++ b/OndselSolver/ASMTSpatialItem.h @@ -29,11 +29,11 @@ namespace MbD { void setRotationMatrix(double v11, double v12, double v13, double v21, double v22, double v23, double v31, double v32, double v33); - void storeOnLevel(std::ofstream& os, int level) override; - void storeOnLevelPosition(std::ofstream& os, int level); - void storeOnLevelRotationMatrix(std::ofstream& os, int level); - FColDsptr getPosition3D(int i); - FMatDsptr getRotationMatrix(int i); + void storeOnLevel(std::ofstream& os, size_t level) override; + void storeOnLevelPosition(std::ofstream& os, size_t level); + void storeOnLevelRotationMatrix(std::ofstream& os, size_t level); + FColDsptr getPosition3D(size_t i); + FMatDsptr getRotationMatrix(size_t i); FColDsptr position3D = std::make_shared>(3); FMatDsptr rotationMatrix = std::make_shared>(ListListD{ diff --git a/OndselSolver/ASMTTranslationalMotion.cpp b/OndselSolver/ASMTTranslationalMotion.cpp index eb79467..4f3c52c 100644 --- a/OndselSolver/ASMTTranslationalMotion.cpp +++ b/OndselSolver/ASMTTranslationalMotion.cpp @@ -68,7 +68,7 @@ void MbD::ASMTTranslationalMotion::readTranslationZ(std::vector& li lines.erase(lines.begin()); } -void MbD::ASMTTranslationalMotion::storeOnLevel(std::ofstream& os, int level) +void MbD::ASMTTranslationalMotion::storeOnLevel(std::ofstream& os, size_t level) { storeOnLevelString(os, level, "TranslationalMotion"); storeOnLevelString(os, level + 1, "Name"); diff --git a/OndselSolver/ASMTTranslationalMotion.h b/OndselSolver/ASMTTranslationalMotion.h index 5aebf3d..9ea658a 100644 --- a/OndselSolver/ASMTTranslationalMotion.h +++ b/OndselSolver/ASMTTranslationalMotion.h @@ -21,7 +21,7 @@ namespace MbD { std::shared_ptr mbdClassNew() override; void readMotionJoint(std::vector& lines); void readTranslationZ(std::vector& lines); - void storeOnLevel(std::ofstream& os, int level) override; + void storeOnLevel(std::ofstream& os, size_t level) override; void storeOnTimeSeries(std::ofstream& os) override; std::string motionJoint, translationZ; diff --git a/OndselSolver/AbsConstraint.cpp b/OndselSolver/AbsConstraint.cpp index 53f2fd4..ca50d41 100644 --- a/OndselSolver/AbsConstraint.cpp +++ b/OndselSolver/AbsConstraint.cpp @@ -15,7 +15,7 @@ using namespace MbD; // //AbsConstraint::AbsConstraint(const char* str) : Constraint(str) {} -AbsConstraint::AbsConstraint(int i) +AbsConstraint::AbsConstraint(size_t i) { axis = i; } @@ -23,10 +23,10 @@ AbsConstraint::AbsConstraint(int i) void AbsConstraint::calcPostDynCorrectorIteration() { if (axis < 3) { - aG = static_cast(owner)->qX->at((int)axis); + aG = static_cast(owner)->qX->at(axis); } else { - aG = static_cast(owner)->qE->at((int)axis - 3); + aG = static_cast(owner)->qE->at(axis - 3); } } @@ -63,10 +63,10 @@ void AbsConstraint::fillAccICIterError(FColDsptr col) auto partFrame = static_cast(owner); double sum; if (axis < 3) { - sum = partFrame->qXddot->at((int)axis); + sum = partFrame->qXddot->at(axis); } else { - sum = partFrame->qEddot->at((int)axis - 3); + sum = partFrame->qEddot->at(axis - 3); } col->atiplusNumber(iG, sum); } diff --git a/OndselSolver/AbsConstraint.h b/OndselSolver/AbsConstraint.h index 992943d..eed9beb 100644 --- a/OndselSolver/AbsConstraint.h +++ b/OndselSolver/AbsConstraint.h @@ -16,7 +16,7 @@ namespace MbD { public: //AbsConstraint(); //AbsConstraint(const char* str); - AbsConstraint(int axis); + AbsConstraint(size_t axis); void calcPostDynCorrectorIteration() override; void fillAccICIterError(FColDsptr col) override; @@ -26,8 +26,8 @@ namespace MbD { void fillVelICJacob(SpMatDsptr mat) override; void useEquationNumbers() override; - int axis = -1; - int iqXminusOnePlusAxis = -1; + size_t axis = SIZE_MAX; + size_t iqXminusOnePlusAxis = SIZE_MAX; }; } diff --git a/OndselSolver/AccNewtonRaphson.cpp b/OndselSolver/AccNewtonRaphson.cpp index 89d485e..9a8f2ff 100644 --- a/OndselSolver/AccNewtonRaphson.cpp +++ b/OndselSolver/AccNewtonRaphson.cpp @@ -29,7 +29,7 @@ void AccNewtonRaphson::assignEquationNumbers() //auto contactEndFrames = system->contactEndFrames(); //auto uHolders = system->uHolders(); auto constraints = system->allConstraints(); - int eqnNo = 0; + size_t eqnNo = 0; for (auto& part : *parts) { part->iqX(eqnNo); eqnNo = eqnNo + 3; @@ -74,7 +74,8 @@ void AccNewtonRaphson::fillY() void AccNewtonRaphson::incrementIterNo() { - if (iterNo >= iterMax) + iterNo++; + if (iterNo > iterMax) { std::stringstream ss; ss << "MbD: No convergence after " << iterNo << " iterations."; @@ -91,8 +92,6 @@ void AccNewtonRaphson::incrementIterNo() throw SimulationStoppingError(""); } - - iterNo++; } void AccNewtonRaphson::initializeGlobally() diff --git a/OndselSolver/AllowZRotation.cpp b/OndselSolver/AllowZRotation.cpp new file mode 100644 index 0000000..e51739e --- /dev/null +++ b/OndselSolver/AllowZRotation.cpp @@ -0,0 +1,57 @@ +/*************************************************************************** + * Copyright (c) 2023 Ondsel, Inc. * + * * + * This file is part of OndselSolver. * + * * + * See LICENSE file for details about copyright. * + ***************************************************************************/ + +#include "System.h" +#include "AllowZRotation.h" +#include "FullColumn.h" +#include "AllowZRotationConstraintIqctJqc.h" +#include "EndFrameqc.h" +#include "EndFrameqct.h" +#include "CREATE.h" +#include "RedundantConstraint.h" + +using namespace MbD; + +MbD::AllowZRotation::AllowZRotation() +{ +} + +MbD::AllowZRotation::AllowZRotation(const char* str) : PrescribedMotion(str) +{ +} + +std::shared_ptr MbD::AllowZRotation::With() +{ + auto allowZRotation = std::make_shared(); + allowZRotation->initialize(); + return allowZRotation; +} + +void MbD::AllowZRotation::initializeGlobally() +{ + if (constraints->empty()) { + initMotions(); + auto dirCosCon = AllowZRotationConstraintIqctJqc::With(frmI, frmJ, 1, 0); + addConstraint(dirCosCon); + this->root()->hasChanged = true; + } + else { + PrescribedMotion::initializeGlobally(); + } +} + +void MbD::AllowZRotation::postPosIC() +{ + for (size_t i = 0; i < constraints->size(); i++) + { + auto& constraint = constraints->at(i); + auto redunCon = CREATE::With(); + redunCon->constraint = constraint; + constraints->at(i) = redunCon; + } +} diff --git a/OndselSolver/AllowZRotation.h b/OndselSolver/AllowZRotation.h new file mode 100644 index 0000000..b371234 --- /dev/null +++ b/OndselSolver/AllowZRotation.h @@ -0,0 +1,25 @@ +/*************************************************************************** + * Copyright (c) 2023 Ondsel, Inc. * + * * + * This file is part of OndselSolver. * + * * + * See LICENSE file for details about copyright. * + ***************************************************************************/ + +#pragma once + +#include "PrescribedMotion.h" + +namespace MbD { + class AllowZRotation : public PrescribedMotion + { + // + public: + AllowZRotation(); + AllowZRotation(const char* str); + static std::shared_ptr With(); + void initializeGlobally() override; + void postPosIC() override; + }; +} + diff --git a/OndselSolver/AllowZRotationConstraintIqctJqc.cpp b/OndselSolver/AllowZRotationConstraintIqctJqc.cpp new file mode 100644 index 0000000..fd73ed4 --- /dev/null +++ b/OndselSolver/AllowZRotationConstraintIqctJqc.cpp @@ -0,0 +1,53 @@ +/*************************************************************************** + * Copyright (c) 2023 Ondsel, Inc. * + * * + * This file is part of OndselSolver. * + * * + * See LICENSE file for details about copyright. * + ***************************************************************************/ + +#include "AllowZRotationConstraintIqctJqc.h" +#include "EndFramec.h" +#include "MarkerFrame.h" +#include "EndFrameqc.h" +#include "CREATE.h" +#include "Symbolic.h" +#include "Constant.h" + #include "EulerAngleszxz.h" + +using namespace MbD; + +MbD::AllowZRotationConstraintIqctJqc::AllowZRotationConstraintIqctJqc(EndFrmsptr frmi, EndFrmsptr frmj, size_t axisi, size_t axisj) : + DirectionCosineConstraintIqctJqc(frmi, frmj, axisi, axisj) +{ +} + +std::shared_ptr MbD::AllowZRotationConstraintIqctJqc::With(EndFrmsptr frmi, EndFrmsptr frmj, size_t axisi, size_t axisj) +{ + auto con = std::make_shared(frmi, frmj, axisi, axisj); + con->initialize(); + return con; +} + +void MbD::AllowZRotationConstraintIqctJqc::postInput() +{ + auto eqctI = std::static_pointer_cast(frmI); + auto aAImJe = eqctI->getMarkerFrame()->aAOm->transposeTimesFullMatrix(frmJ->aAOe); + auto aEulerAngleszxz = aAImJe->eulerAngleszxz(); + auto the1z = aEulerAngleszxz->at(1); + auto the2x = aEulerAngleszxz->at(2); + if (std::abs(the2x) < (OS_M_PI / 2.0)) { + eqctI->phiThePsiBlks->at(1) = std::make_shared(the1z); + } + else { + eqctI->phiThePsiBlks->at(1) = std::make_shared(OS_M_PI + the1z); + } + eqctI->postInput(); + DirectionCosineConstraintIqctJqc::postInput(); +} + +void MbD::AllowZRotationConstraintIqctJqc::postPosIC() +{ + //self becomeRedundantConstraint + assert(false); +} diff --git a/OndselSolver/AllowZRotationConstraintIqctJqc.h b/OndselSolver/AllowZRotationConstraintIqctJqc.h new file mode 100644 index 0000000..e62bd38 --- /dev/null +++ b/OndselSolver/AllowZRotationConstraintIqctJqc.h @@ -0,0 +1,25 @@ +/*************************************************************************** + * Copyright (c) 2023 Ondsel, Inc. * + * * + * This file is part of OndselSolver. * + * * + * See LICENSE file for details about copyright. * + ***************************************************************************/ + +#pragma once + +#include "DirectionCosineConstraintIqctJqc.h" + +namespace MbD { + + class AllowZRotationConstraintIqctJqc : public DirectionCosineConstraintIqctJqc + { + public: + AllowZRotationConstraintIqctJqc(EndFrmsptr frmi, EndFrmsptr frmj, size_t axisi, size_t axisj); + static std::shared_ptr With(EndFrmsptr frmi, EndFrmsptr frmj, size_t axisi, size_t axisj); + + void postInput() override; + void postPosIC() override; + + }; +} \ No newline at end of file diff --git a/OndselSolver/AngleZIeqcJec.cpp b/OndselSolver/AngleZIeqcJec.cpp index e315ea3..d8d89c9 100644 --- a/OndselSolver/AngleZIeqcJec.cpp +++ b/OndselSolver/AngleZIeqcJec.cpp @@ -28,11 +28,11 @@ void MbD::AngleZIeqcJec::calcPostDynCorrectorIteration() psthezpEI = aA10IeJe->pvaluepEI(); auto ppcthezpEIpEI = aA00IeJe->ppvaluepEIpEI(); auto ppsthezpEIpEI = aA10IeJe->ppvaluepEIpEI(); - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { pthezpEI->atiput(i, (psthezpEI->at(i)) * cosOverSSq - ((pcthezpEI->at(i)) * sinOverSSq)); } - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto ppthezpEIpEIi = ppthezpEIpEI->at(i); auto ppcthezpEIpEIi = ppcthezpEIpEI->at(i); @@ -43,7 +43,7 @@ void MbD::AngleZIeqcJec::calcPostDynCorrectorIteration() auto term2 = ppsthezpEIpEIi->at(i) * cosOverSSq - (ppcthezpEIpEIi->at(i) * sinOverSSq); auto term3 = (psthezpEIi * pcthezpEIi + (pcthezpEIi * psthezpEIi)) * dSqOverSSqSq; ppthezpEIpEIi->atiput(i, term1 + term2 + term3); - for (int j = i + 1; j < 4; j++) + for (size_t j = i + 1; j < 4; j++) { auto pcthezpEIj = pcthezpEI->at(j); auto psthezpEIj = psthezpEI->at(j); diff --git a/OndselSolver/AngleZIeqcJeqc.cpp b/OndselSolver/AngleZIeqcJeqc.cpp index 6b50183..1328e57 100644 --- a/OndselSolver/AngleZIeqcJeqc.cpp +++ b/OndselSolver/AngleZIeqcJeqc.cpp @@ -32,18 +32,18 @@ void MbD::AngleZIeqcJeqc::calcPostDynCorrectorIteration() auto ppsthezpEIpEJ = aA10IeJe->ppvaluepEIpEJ(); auto ppcthezpEJpEJ = aA00IeJe->ppvaluepEJpEJ(); auto ppsthezpEJpEJ = aA10IeJe->ppvaluepEJpEJ(); - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { pthezpEJ->atiput(i, (psthezpEJ->at(i)) * cosOverSSq - ((pcthezpEJ->at(i)) * sinOverSSq)); } - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto ppthezpEIpEJi = ppthezpEIpEJ->at(i); auto ppcthezpEIpEJi = ppcthezpEIpEJ->at(i); auto ppsthezpEIpEJi = ppsthezpEIpEJ->at(i); auto pcthezpEIi = pcthezpEI->at(i); auto psthezpEIi = psthezpEI->at(i); - for (int j = 0; j < 4; j++) + for (size_t j = 0; j < 4; j++) { auto pcthezpEJj = pcthezpEJ->at(j); auto psthezpEJj = psthezpEJ->at(j); @@ -53,7 +53,7 @@ void MbD::AngleZIeqcJeqc::calcPostDynCorrectorIteration() ppthezpEIpEJi->atiput(j, term1 + term2 + term3); } } - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto ppthezpEJpEJi = ppthezpEJpEJ->at(i); auto ppcthezpEJpEJi = ppcthezpEJpEJ->at(i); @@ -64,7 +64,7 @@ void MbD::AngleZIeqcJeqc::calcPostDynCorrectorIteration() auto term2 = ppsthezpEJpEJi->at(i) * cosOverSSq - (ppcthezpEJpEJi->at(i) * sinOverSSq); auto term3 = (psthezpEJi * pcthezpEJi + (pcthezpEJi * psthezpEJi)) * dSqOverSSqSq; ppthezpEJpEJi->atiput(i, term1 + term2 + term3); - for (int j = i + 1; j < 4; j++) + for (size_t j = i + 1; j < 4; j++) { auto pcthezpEJj = pcthezpEJ->at(j); auto psthezpEJj = psthezpEJ->at(j); diff --git a/OndselSolver/AnyPosICNewtonRaphson.h b/OndselSolver/AnyPosICNewtonRaphson.h index 6ce1a84..244963e 100644 --- a/OndselSolver/AnyPosICNewtonRaphson.h +++ b/OndselSolver/AnyPosICNewtonRaphson.h @@ -26,10 +26,10 @@ namespace MbD { void passRootToSystem() override; void assignEquationNumbers() override = 0; - int nqsu = -1; + size_t nqsu = SIZE_MAX; FColDsptr qsuOld; DiagMatDsptr qsuWeights; - int nSingularMatrixError = -1; + size_t nSingularMatrixError = SIZE_MAX; }; } diff --git a/OndselSolver/Array.h b/OndselSolver/Array.h index a3aca4c..636e9a5 100644 --- a/OndselSolver/Array.h +++ b/OndselSolver/Array.h @@ -13,6 +13,8 @@ #include #include #include +#include "Numeric.h" +#include //#include "Symbolic.h" @@ -38,15 +40,15 @@ namespace MbD { virtual void zeroSelf(); virtual double sumOfSquares() = 0; double rootMeanSquare(); - virtual int numberOfElements(); - void swapElems(int i, int ii); + virtual size_t numberOfElements(); + void swapElems(size_t i, size_t ii); virtual double maxMagnitude() = 0; double maxMagnitudeOfVector(); - void equalArrayAt(std::shared_ptr> array, int i); - void atiput(int i, T value); + void equalArrayAt(std::shared_ptr> array, size_t i); + void atiput(size_t i, T value); void magnifySelf(T factor); void negateSelf(); - void atitimes(int i, double factor); + void atitimes(size_t i, double factor); virtual std::ostream& printOn(std::ostream& s) const { std::string str = typeid(*this).name(); @@ -72,14 +74,14 @@ namespace MbD { template inline void Array::copyFrom(std::shared_ptr> x) { - for (int i = 0; i < (int)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 < (int)this->size(); i++) { + for (size_t i = 0; i < this->size(); i++) { this->at(i) = (T)0; } } @@ -89,12 +91,12 @@ namespace MbD { return std::sqrt(this->sumOfSquares() / this->numberOfElements()); } template - inline int Array::numberOfElements() + inline size_t Array::numberOfElements() { - return (int)this->size(); + return this->size(); } template - inline void Array::swapElems(int i, int ii) + inline void Array::swapElems(size_t i, size_t ii) { auto temp = this->at(i); this->at(i) = this->at(ii); @@ -104,7 +106,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; @@ -116,7 +118,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; @@ -124,11 +126,11 @@ namespace MbD { return answer; } template - inline void Array::equalArrayAt(std::shared_ptr> array, int i) + inline void Array::equalArrayAt(std::shared_ptr> array, size_t i) { - for (int ii = 0; ii < (int)this->size(); ii++) + for (size_t ii = 0; ii < this->size(); ii++) { - this->at(ii) = array->at((int)i + ii); + this->at(ii) = array->at(i + ii); } } //template<> @@ -148,7 +150,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; @@ -156,7 +158,7 @@ namespace MbD { // } //} template - inline void Array::atiput(int i, T value) + inline void Array::atiput(size_t i, T value) { this->at(i) = value; } @@ -164,7 +166,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; @@ -174,7 +176,7 @@ namespace MbD { template inline void Array::magnifySelf(T factor) { - for (int i = 0; i < (int)this->size(); i++) + for (size_t i = 0; i < this->size(); i++) { this->atitimes(i, factor); } @@ -185,7 +187,7 @@ namespace MbD { magnifySelf(-1); } template - inline void Array::atitimes(int i, double factor) + inline void Array::atitimes(size_t i, double factor) { this->at(i) *= factor; } diff --git a/OndselSolver/AtPointConstraintIJ.cpp b/OndselSolver/AtPointConstraintIJ.cpp index 9af2427..6fec67a 100644 --- a/OndselSolver/AtPointConstraintIJ.cpp +++ b/OndselSolver/AtPointConstraintIJ.cpp @@ -12,7 +12,7 @@ using namespace MbD; -AtPointConstraintIJ::AtPointConstraintIJ(EndFrmsptr frmi, EndFrmsptr frmj, int axisi) : +AtPointConstraintIJ::AtPointConstraintIJ(EndFrmsptr frmi, EndFrmsptr frmj, size_t axisi) : ConstraintIJ(frmi, frmj), axis(axisi) { } diff --git a/OndselSolver/AtPointConstraintIJ.h b/OndselSolver/AtPointConstraintIJ.h index f8e6919..55ea1a6 100644 --- a/OndselSolver/AtPointConstraintIJ.h +++ b/OndselSolver/AtPointConstraintIJ.h @@ -17,7 +17,7 @@ namespace MbD { { //axis riIeJeO public: - AtPointConstraintIJ(EndFrmsptr frmi, EndFrmsptr frmj, int axisi); + AtPointConstraintIJ(EndFrmsptr frmi, EndFrmsptr frmj, size_t axisi); void calcPostDynCorrectorIteration() override; void initialize() override; @@ -32,7 +32,7 @@ namespace MbD { ConstraintType type() override; - int axis; + size_t axis; std::shared_ptr riIeJeO; }; } diff --git a/OndselSolver/AtPointConstraintIqcJc.cpp b/OndselSolver/AtPointConstraintIqcJc.cpp index 07e858d..03cfc46 100644 --- a/OndselSolver/AtPointConstraintIqcJc.cpp +++ b/OndselSolver/AtPointConstraintIqcJc.cpp @@ -13,7 +13,7 @@ using namespace MbD; -AtPointConstraintIqcJc::AtPointConstraintIqcJc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi) : +AtPointConstraintIqcJc::AtPointConstraintIqcJc(EndFrmsptr frmi, EndFrmsptr frmj, size_t axisi) : AtPointConstraintIJ(frmi, frmj, axisi) { } @@ -97,7 +97,7 @@ void AtPointConstraintIqcJc::addToJointTorqueI(FColDsptr jointTorque) auto pAOIppEI = frmI->pAOppE(); auto aBOIp = frmI->aBOp(); auto fpAOIppEIrIpIeIp = std::make_shared>(4, 0.0); - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto dum = cForceT->timesFullColumn(pAOIppEI->at(i)->timesFullColumn(rIpIeIp)); fpAOIppEIrIpIeIp->atiput(i, dum); diff --git a/OndselSolver/AtPointConstraintIqcJc.h b/OndselSolver/AtPointConstraintIqcJc.h index 05795ab..8b35076 100644 --- a/OndselSolver/AtPointConstraintIqcJc.h +++ b/OndselSolver/AtPointConstraintIqcJc.h @@ -15,7 +15,7 @@ namespace MbD { { //pGpEI ppGpEIpEI iqXIminusOnePlusAxis iqEI public: - AtPointConstraintIqcJc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi); + AtPointConstraintIqcJc(EndFrmsptr frmi, EndFrmsptr frmj, size_t axisi); void addToJointForceI(FColDsptr col) override; void addToJointTorqueI(FColDsptr col) override; @@ -31,8 +31,8 @@ namespace MbD { FRowDsptr pGpEI; FMatDsptr ppGpEIpEI; - int iqXIminusOnePlusAxis = -1; - int iqEI = -1; + size_t iqXIminusOnePlusAxis = SIZE_MAX; + size_t iqEI = SIZE_MAX; }; } diff --git a/OndselSolver/AtPointConstraintIqcJqc.cpp b/OndselSolver/AtPointConstraintIqcJqc.cpp index 1adb3db..eb670b2 100644 --- a/OndselSolver/AtPointConstraintIqcJqc.cpp +++ b/OndselSolver/AtPointConstraintIqcJqc.cpp @@ -13,7 +13,7 @@ using namespace MbD; -AtPointConstraintIqcJqc::AtPointConstraintIqcJqc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi) : +AtPointConstraintIqcJqc::AtPointConstraintIqcJqc(EndFrmsptr frmi, EndFrmsptr frmj, size_t axisi) : AtPointConstraintIqcJc(frmi, frmj, axisi) { } diff --git a/OndselSolver/AtPointConstraintIqcJqc.h b/OndselSolver/AtPointConstraintIqcJqc.h index 04c3935..af92c92 100644 --- a/OndselSolver/AtPointConstraintIqcJqc.h +++ b/OndselSolver/AtPointConstraintIqcJqc.h @@ -15,7 +15,7 @@ namespace MbD { { //pGpEJ ppGpEJpEJ iqXJminusOnePlusAxis iqEJ public: - AtPointConstraintIqcJqc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi); + AtPointConstraintIqcJqc(EndFrmsptr frmi, EndFrmsptr frmj, size_t axisi); void calcPostDynCorrectorIteration() override; void initializeGlobally() override; @@ -29,7 +29,7 @@ namespace MbD { FRowDsptr pGpEJ; FMatDsptr ppGpEJpEJ; - int iqXJminusOnePlusAxis = -1, iqEJ = -1; + size_t iqXJminusOnePlusAxis = SIZE_MAX, iqEJ = SIZE_MAX; }; } diff --git a/OndselSolver/AtPointConstraintIqctJqc.cpp b/OndselSolver/AtPointConstraintIqctJqc.cpp index 21fa93c..528b030 100644 --- a/OndselSolver/AtPointConstraintIqctJqc.cpp +++ b/OndselSolver/AtPointConstraintIqctJqc.cpp @@ -12,7 +12,7 @@ using namespace MbD; -AtPointConstraintIqctJqc::AtPointConstraintIqctJqc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi) : +AtPointConstraintIqctJqc::AtPointConstraintIqctJqc(EndFrmsptr frmi, EndFrmsptr frmj, size_t axisi) : AtPointConstraintIqcJqc(frmi, frmj, axisi) { } diff --git a/OndselSolver/AtPointConstraintIqctJqc.h b/OndselSolver/AtPointConstraintIqctJqc.h index 1e6e0f0..cb83ce7 100644 --- a/OndselSolver/AtPointConstraintIqctJqc.h +++ b/OndselSolver/AtPointConstraintIqctJqc.h @@ -15,7 +15,7 @@ namespace MbD { { //pGpt ppGpEIpt ppGptpt public: - AtPointConstraintIqctJqc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi); + AtPointConstraintIqctJqc(EndFrmsptr frmi, EndFrmsptr frmj, size_t axisi); void calcPostDynCorrectorIteration() override; void fillAccICIterError(FColDsptr col) override; diff --git a/OndselSolver/BasicIntegrator.cpp b/OndselSolver/BasicIntegrator.cpp index 057be93..a897732 100644 --- a/OndselSolver/BasicIntegrator.cpp +++ b/OndselSolver/BasicIntegrator.cpp @@ -18,7 +18,7 @@ void BasicIntegrator::initializeLocally() _continue = true; } -void BasicIntegrator::iStep(int integer) +void BasicIntegrator::iStep(size_t integer) { istep = integer; opBDF->setiStep(integer); @@ -64,7 +64,7 @@ void BasicIntegrator::incrementTime() { tpast->insert(tpast->begin(), t); - if ((int)tpast->size() > (orderMax + 1)) { tpast->pop_back(); } + if (tpast->size() > (orderMax + 1)) { tpast->pop_back(); } auto istepNew = istep + 1; this->iStep(istepNew); this->setorder(orderNew); @@ -129,7 +129,7 @@ void BasicIntegrator::reportStats() { } -void BasicIntegrator::setorder(int o) +void BasicIntegrator::setorder(size_t o) { order = o; opBDF->setorder(o); diff --git a/OndselSolver/BasicIntegrator.h b/OndselSolver/BasicIntegrator.h index 8905ad4..88f2b3f 100644 --- a/OndselSolver/BasicIntegrator.h +++ b/OndselSolver/BasicIntegrator.h @@ -26,7 +26,7 @@ namespace MbD { void initialize() override; void initializeGlobally() override; void initializeLocally() override; - void iStep(int i) override; + void iStep(size_t i) override; void postFirstStep() override; void postStep() override; void postRun() override; @@ -40,17 +40,17 @@ namespace MbD { void setSystem(Solver* sys) override; void logString(std::string& str) override; - virtual void setorder(int o); + virtual void setorder(size_t o); virtual void settnew(double t); virtual void sett(double t); void settime(double t); double tprevious(); IntegratorInterface* system; - int istep = 0, iTry = 0, maxTry = 0; + size_t istep = 0, iTry = 0, maxTry = 0; std::shared_ptr> tpast; double t = 0.0, tnew = 0.0, h = 0, hnew = 0.0; - int order = 0, orderNew = 0, orderMax = 0; + size_t order = 0, orderNew = 0, orderMax = 0; std::shared_ptr opBDF; bool _continue = false; }; diff --git a/OndselSolver/CREATE.h b/OndselSolver/CREATE.h index e50d7a0..36b9ce3 100644 --- a/OndselSolver/CREATE.h +++ b/OndselSolver/CREATE.h @@ -38,12 +38,12 @@ namespace MbD { inst->initialize(); return inst; } - static std::shared_ptr With(int n) { + static std::shared_ptr With(size_t n) { auto inst = std::make_shared(n); inst->initialize(); return inst; } - static std::shared_ptr With(int m, int n) { + static std::shared_ptr With(size_t m, size_t n) { auto inst = std::make_shared(m, n); inst->initialize(); return inst; @@ -58,17 +58,17 @@ namespace MbD { inst->initialize(); return inst; } - static std::shared_ptr With(std::shared_ptr frmi, std::shared_ptr frmj, int axis) { + static std::shared_ptr With(std::shared_ptr frmi, std::shared_ptr frmj, size_t axis) { auto inst = std::make_shared(frmi, frmj, axis); inst->initialize(); return inst; } - static std::shared_ptr With(std::shared_ptr frmi, std::shared_ptr frmj, std::shared_ptr frmk, int axisk) { + static std::shared_ptr With(std::shared_ptr frmi, std::shared_ptr frmj, std::shared_ptr frmk, size_t axisk) { auto inst = std::make_shared(frmi, frmj, frmk, axisk); inst->initialize(); return inst; } - static std::shared_ptr ConstraintWith(std::shared_ptr frmi, std::shared_ptr frmj, int axis) { + static std::shared_ptr ConstraintWith(std::shared_ptr frmi, std::shared_ptr frmj, size_t axis) { std::shared_ptr inst; std::string str = typeid(T(frmi, frmj, axis)).name(); if (str.find("AtPointConstraintIJ") != std::string::npos) { @@ -90,12 +90,12 @@ namespace MbD { inst->initialize(); return inst; } - static std::shared_ptr With(std::shared_ptr frmi, std::shared_ptr frmj, int axisi, int axisj) { + static std::shared_ptr With(std::shared_ptr frmi, std::shared_ptr frmj, size_t axisi, size_t axisj) { auto inst = std::make_shared(frmi, frmj, axisi, axisj); inst->initialize(); return inst; } - static std::shared_ptr ConstraintWith(std::shared_ptr frmi, std::shared_ptr frmj, int axisi, int axisj) { + static std::shared_ptr ConstraintWith(std::shared_ptr frmi, std::shared_ptr frmj, size_t axisi, size_t axisj) { std::shared_ptr inst; std::string str = typeid(T(frmi, frmj, axisi, axisj)).name(); if (str.find("DirectionCosineConstraintIJ") != std::string::npos) { diff --git a/OndselSolver/ConstVelConstraintIqcJc.cpp b/OndselSolver/ConstVelConstraintIqcJc.cpp index 22379fe..48bd235 100644 --- a/OndselSolver/ConstVelConstraintIqcJc.cpp +++ b/OndselSolver/ConstVelConstraintIqcJc.cpp @@ -31,17 +31,17 @@ void MbD::ConstVelConstraintIqcJc::calcPostDynCorrectorIteration() auto aA10IeqcJec = std::dynamic_pointer_cast(aA10IeJe); auto& pA10IeJepEI = aA10IeqcJec->pAijIeJepEI; auto& ppA10IeJepEIpEI = aA10IeqcJec->ppAijIeJepEIpEI; - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { pGpEI->atiput(i, pA01IeJepEI->at(i) + pA10IeJepEI->at(i)); } - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto& ppGpEIpEIi = ppGpEIpEI->at(i); auto& ppA01IeJepEIpEIi = ppA01IeJepEIpEI->at(i); auto& ppA10IeJepEIpEIi = ppA10IeJepEIpEI->at(i); ppGpEIpEIi->atiput(i, ppA01IeJepEIpEIi->at(i) + ppA10IeJepEIpEIi->at(i)); - for (int j = i + 1; j < 4; j++) + for (size_t j = i + 1; j < 4; j++) { auto ppGpEIpEIij = ppA01IeJepEIpEIi->at(j) + ppA10IeJepEIpEIi->at(j); ppGpEIpEIi->atiput(j, ppGpEIpEIij); diff --git a/OndselSolver/ConstVelConstraintIqcJc.h b/OndselSolver/ConstVelConstraintIqcJc.h index 1435182..7f953d0 100644 --- a/OndselSolver/ConstVelConstraintIqcJc.h +++ b/OndselSolver/ConstVelConstraintIqcJc.h @@ -30,6 +30,6 @@ namespace MbD { FRowDsptr pGpEI; FMatDsptr ppGpEIpEI; - int iqEI = -1; + size_t iqEI = SIZE_MAX; }; } diff --git a/OndselSolver/ConstVelConstraintIqcJqc.cpp b/OndselSolver/ConstVelConstraintIqcJqc.cpp index 0ea8950..16f02ff 100644 --- a/OndselSolver/ConstVelConstraintIqcJqc.cpp +++ b/OndselSolver/ConstVelConstraintIqcJqc.cpp @@ -31,28 +31,28 @@ void MbD::ConstVelConstraintIqcJqc::calcPostDynCorrectorIteration() auto& pA10IeJepEJ = aA10IeqcJeqc->pAijIeJepEJ; auto& ppA10IeJepEIpEJ = aA10IeqcJeqc->ppAijIeJepEIpEJ; auto& ppA10IeJepEJpEJ = aA10IeqcJeqc->ppAijIeJepEJpEJ; - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { pGpEJ->atiput(i, pA01IeJepEJ->at(i) + pA10IeJepEJ->at(i)); } - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto& ppGpEIpEJi = ppGpEIpEJ->at(i); auto& ppA01IeJepEIpEJi = ppA01IeJepEIpEJ->at(i); auto& ppA10IeJepEIpEJi = ppA10IeJepEIpEJ->at(i); - for (int j = 0; j < 4; j++) + for (size_t j = 0; j < 4; j++) { auto ppGpEIpEJij = ppA01IeJepEIpEJi->at(j) + ppA10IeJepEIpEJi->at(j); ppGpEIpEJi->atiput(j, ppGpEIpEJij); } } - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto& ppGpEJpEJi = ppGpEJpEJ->at(i); auto& ppA01IeJepEJpEJi = ppA01IeJepEJpEJ->at(i); auto& ppA10IeJepEJpEJi = ppA10IeJepEJpEJ->at(i); ppGpEJpEJi->atiput(i, ppA01IeJepEJpEJi->at(i) + ppA10IeJepEJpEJi->at(i)); - for (int j = i + 1; j < 4; j++) + for (size_t j = i + 1; j < 4; j++) { auto ppGpEJpEJij = ppA01IeJepEJpEJi->at(j) + ppA10IeJepEJpEJi->at(j); ppGpEJpEJi->atiput(j, ppGpEJpEJij); diff --git a/OndselSolver/ConstVelConstraintIqcJqc.h b/OndselSolver/ConstVelConstraintIqcJqc.h index 116549c..d483400 100644 --- a/OndselSolver/ConstVelConstraintIqcJqc.h +++ b/OndselSolver/ConstVelConstraintIqcJqc.h @@ -31,7 +31,7 @@ namespace MbD { FRowDsptr pGpEJ; FMatDsptr ppGpEIpEJ; FMatDsptr ppGpEJpEJ; - int iqEJ = -1; + size_t iqEJ = SIZE_MAX; }; } diff --git a/OndselSolver/Constraint.cpp b/OndselSolver/Constraint.cpp index 5b5c8ef..9ce4d86 100644 --- a/OndselSolver/Constraint.cpp +++ b/OndselSolver/Constraint.cpp @@ -40,7 +40,7 @@ void Constraint::postInput() void Constraint::prePosIC() { lam = 0.0; - iG = -1; + iG = SIZE_MAX; Item::prePosIC(); } @@ -108,7 +108,7 @@ void Constraint::fillPosICError(FColDsptr col) col->atiplusNumber(iG, aG); } -void Constraint::removeRedundantConstraints(std::shared_ptr>) +void Constraint::removeRedundantConstraints(std::shared_ptr>) { //My owner should handle this. assert(false); diff --git a/OndselSolver/Constraint.h b/OndselSolver/Constraint.h index 917e197..9365b0b 100644 --- a/OndselSolver/Constraint.h +++ b/OndselSolver/Constraint.h @@ -46,14 +46,14 @@ namespace MbD { void prePosIC() override; void prePosKine() override; void reactivateRedundantConstraints() override; - void removeRedundantConstraints(std::shared_ptr> redundantEqnNos) override; + void removeRedundantConstraints(std::shared_ptr> redundantEqnNos) override; void setConstant(double value); void setqsudotlam(FColDsptr col) override; void setqsuddotlam(FColDsptr col) override; void setqsulam(FColDsptr col) override; virtual ConstraintType type(); - int iG = -1; + size_t iG = SIZE_MAX; double aG = 0.0; //Constraint function double aConstant = 0.0; double lam = 0.0; //Lambda is Lagrange Multiplier diff --git a/OndselSolver/DiagonalMatrix.h b/OndselSolver/DiagonalMatrix.h index 9dfe7b7..b8efb97 100644 --- a/OndselSolver/DiagonalMatrix.h +++ b/OndselSolver/DiagonalMatrix.h @@ -28,18 +28,18 @@ namespace MbD { DiagonalMatrix(size_t count) : Array(count) {} DiagonalMatrix(size_t count, const T& value) : Array(count, value) {} DiagonalMatrix(std::initializer_list list) : Array{ list } {} - void atiputDiagonalMatrix(int i, std::shared_ptr> diagMat); + void atiputDiagonalMatrix(size_t i, std::shared_ptr> diagMat); DiagMatsptr times(T factor); FColsptr timesFullColumn(FColsptr fullCol); FMatsptr timesFullMatrix(FMatsptr fullMat); - int nrow() { - return (int)this->size(); + size_t nrow() { + return this->size(); } - int ncol() { - return (int)this->size(); + size_t ncol() { + return this->size(); } double sumOfSquares() override; - int numberOfElements() override; + size_t numberOfElements() override; void zeroSelf() override; double maxMagnitude() override; @@ -49,18 +49,18 @@ namespace MbD { template<> inline DiagMatDsptr DiagonalMatrix::times(double factor) { - auto nrow = (int)this->size(); + auto nrow = this->size(); auto answer = std::make_shared>(nrow); - for (int i = 0; i < nrow; i++) + for (size_t i = 0; i < nrow; i++) { answer->at(i) = this->at(i) * factor; } return answer; } template - inline void DiagonalMatrix::atiputDiagonalMatrix(int i, std::shared_ptr> diagMat) + inline void DiagonalMatrix::atiputDiagonalMatrix(size_t i, std::shared_ptr> diagMat) { - for (int ii = 0; ii < (int)diagMat->size(); ii++) + for (size_t ii = 0; ii < diagMat->size(); ii++) { this->at(i + ii) = diagMat->at(ii); } @@ -75,9 +75,9 @@ namespace MbD { { //"a*b = a(i,j)b(j) sum j." - auto nrow = (int)this->size(); + auto nrow = this->size(); auto answer = std::make_shared>(nrow); - for (int i = 0; i < nrow; i++) + for (size_t i = 0; i < nrow; i++) { answer->at(i) = this->at(i) * fullCol->at(i); } @@ -86,9 +86,9 @@ namespace MbD { template inline FMatsptr DiagonalMatrix::timesFullMatrix(FMatsptr fullMat) { - auto nrow = (int)this->size(); + auto nrow = this->size(); auto answer = std::make_shared>(nrow); - for (int i = 0; i < nrow; i++) + for (size_t i = 0; i < nrow; i++) { answer->at(i) = fullMat->at(i)->times(this->at(i)); } @@ -98,7 +98,7 @@ namespace MbD { inline double DiagonalMatrix::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; @@ -106,15 +106,15 @@ namespace MbD { return sum; } template - inline int DiagonalMatrix::numberOfElements() + inline size_t DiagonalMatrix::numberOfElements() { - auto n = (int)this->size(); + auto n = this->size(); return n * n; } template<> inline void DiagonalMatrix::zeroSelf() { - for (int i = 0; i < (int)this->size(); i++) { + for (size_t i = 0; i < this->size(); i++) { this->at(i) = 0.0; } } @@ -122,7 +122,7 @@ namespace MbD { inline double DiagonalMatrix::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; @@ -141,7 +141,7 @@ namespace MbD { { s << "DiagMat["; 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/DifferenceOperator.cpp b/OndselSolver/DifferenceOperator.cpp index d7aa7fc..4951ac6 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 < (int)oneOverFactorials->size(); i++) + for (size_t i = 0; i < oneOverFactorials->size(); i++) { oneOverFactorials->at(i) = 1.0 / std::tgamma(i + 1); } @@ -50,12 +50,12 @@ void MbD::DifferenceOperator::initializeLocally() assert(false); } -void DifferenceOperator::setiStep(int i) +void DifferenceOperator::setiStep(size_t i) { iStep = i; } -void DifferenceOperator::setorder(int o) +void DifferenceOperator::setorder(size_t o) { order = o; } @@ -67,21 +67,21 @@ void DifferenceOperator::instantiateTaylorMatrix() } } -void DifferenceOperator::formTaylorRowwithTimeNodederivative(int i, int ii, int k) +void DifferenceOperator::formTaylorRowwithTimeNodederivative(size_t i, size_t ii, size_t k) { //| rowi hi hipower aij | auto& rowi = taylorMatrix->at(i); - for (int j = 0; j < k; j++) + for (size_t j = 0; j < k; j++) { rowi->at(j) = 0.0; } rowi->at(k) = 1.0; auto hi = timeNodes->at(ii) - time; auto hipower = 1.0; - for (int j = k + 1; j < order + 1; j++) + for (size_t j = k + 1; j < order + 1; j++) { hipower = hipower * hi; - auto aij = hipower * OneOverFactorials->at((int)j - k); + auto aij = hipower * OneOverFactorials->at(j - k); rowi->atiput(j, aij); } } diff --git a/OndselSolver/DifferenceOperator.h b/OndselSolver/DifferenceOperator.h index 910a6ee..117ec2b 100644 --- a/OndselSolver/DifferenceOperator.h +++ b/OndselSolver/DifferenceOperator.h @@ -21,14 +21,14 @@ namespace MbD { void calcOperatorMatrix(); virtual void initialize(); virtual void initializeLocally(); - virtual void setiStep(int i); - virtual void setorder(int o); + virtual void setiStep(size_t i); + virtual void setorder(size_t o); virtual void formTaylorMatrix() = 0; virtual void instantiateTaylorMatrix(); - virtual void formTaylorRowwithTimeNodederivative(int i, int ii, int k); + virtual void formTaylorRowwithTimeNodederivative(size_t i, size_t ii, size_t k); void settime(double t); - int iStep = 0, order = 0; + size_t iStep = 0, order = 0; FMatDsptr taylorMatrix, operatorMatrix; double time = 0.0; std::shared_ptr> timeNodes; //"Row of past times in order of increasing past." diff --git a/OndselSolver/DifferentiatedGeneralSpline.cpp b/OndselSolver/DifferentiatedGeneralSpline.cpp index 0d9d256..6138b30 100644 --- a/OndselSolver/DifferentiatedGeneralSpline.cpp +++ b/OndselSolver/DifferentiatedGeneralSpline.cpp @@ -11,7 +11,7 @@ using namespace MbD; -MbD::DifferentiatedGeneralSpline::DifferentiatedGeneralSpline(Symsptr arg, Symsptr spline, int derivOrder) : AnyGeneralSpline(arg), generalSpline(spline), derivativeOrder(derivOrder) +MbD::DifferentiatedGeneralSpline::DifferentiatedGeneralSpline(Symsptr arg, Symsptr spline, size_t derivOrder) : AnyGeneralSpline(arg), generalSpline(spline), derivativeOrder(derivOrder) { } diff --git a/OndselSolver/DifferentiatedGeneralSpline.h b/OndselSolver/DifferentiatedGeneralSpline.h index 17003a1..bcaace8 100644 --- a/OndselSolver/DifferentiatedGeneralSpline.h +++ b/OndselSolver/DifferentiatedGeneralSpline.h @@ -16,7 +16,7 @@ namespace MbD { //derivativeOrder public: DifferentiatedGeneralSpline() = default; - DifferentiatedGeneralSpline(Symsptr arg, Symsptr spline, int derivOrder); + DifferentiatedGeneralSpline(Symsptr arg, Symsptr spline, size_t derivOrder); double getValue() override; Symsptr differentiateWRTx() override; Symsptr clonesptr() override; @@ -24,6 +24,6 @@ namespace MbD { std::ostream& printOn(std::ostream& s) const override; Symsptr generalSpline; - int derivativeOrder; + size_t derivativeOrder; }; } diff --git a/OndselSolver/DirectionCosineConstraintIJ.cpp b/OndselSolver/DirectionCosineConstraintIJ.cpp index d75482d..bc4cb73 100644 --- a/OndselSolver/DirectionCosineConstraintIJ.cpp +++ b/OndselSolver/DirectionCosineConstraintIJ.cpp @@ -13,7 +13,7 @@ using namespace MbD; -DirectionCosineConstraintIJ::DirectionCosineConstraintIJ(EndFrmsptr frmi, EndFrmsptr frmj, int axisi, int axisj) : +DirectionCosineConstraintIJ::DirectionCosineConstraintIJ(EndFrmsptr frmi, EndFrmsptr frmj, size_t axisi, size_t axisj) : ConstraintIJ(frmi, frmj), axisI(axisi), axisJ(axisj) { } diff --git a/OndselSolver/DirectionCosineConstraintIJ.h b/OndselSolver/DirectionCosineConstraintIJ.h index 38348bd..cb69bc8 100644 --- a/OndselSolver/DirectionCosineConstraintIJ.h +++ b/OndselSolver/DirectionCosineConstraintIJ.h @@ -17,7 +17,7 @@ namespace MbD { { //axisI axisJ aAijIeJe public: - DirectionCosineConstraintIJ(EndFrmsptr frmi, EndFrmsptr frmj, int axisi, int axisj); + DirectionCosineConstraintIJ(EndFrmsptr frmi, EndFrmsptr frmj, size_t axisi, size_t axisj); void calcPostDynCorrectorIteration() override; virtual void initaAijIeJe(); @@ -32,7 +32,7 @@ namespace MbD { void simUpdateAll() override; ConstraintType type() override; - int axisI, axisJ; + size_t axisI, axisJ; std::shared_ptr aAijIeJe; }; } diff --git a/OndselSolver/DirectionCosineConstraintIqcJc.cpp b/OndselSolver/DirectionCosineConstraintIqcJc.cpp index 4f14081..37acc6d 100644 --- a/OndselSolver/DirectionCosineConstraintIqcJc.cpp +++ b/OndselSolver/DirectionCosineConstraintIqcJc.cpp @@ -13,7 +13,7 @@ using namespace MbD; -DirectionCosineConstraintIqcJc::DirectionCosineConstraintIqcJc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi, int axisj) : +DirectionCosineConstraintIqcJc::DirectionCosineConstraintIqcJc(EndFrmsptr frmi, EndFrmsptr frmj, size_t axisi, size_t axisj) : DirectionCosineConstraintIJ(frmi, frmj, axisi, axisj) { } diff --git a/OndselSolver/DirectionCosineConstraintIqcJc.h b/OndselSolver/DirectionCosineConstraintIqcJc.h index 286dfe6..f520af6 100644 --- a/OndselSolver/DirectionCosineConstraintIqcJc.h +++ b/OndselSolver/DirectionCosineConstraintIqcJc.h @@ -15,7 +15,7 @@ namespace MbD { { //pGpEI ppGpEIpEI iqEI public: - DirectionCosineConstraintIqcJc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi, int axisj); + DirectionCosineConstraintIqcJc(EndFrmsptr frmi, EndFrmsptr frmj, size_t axisi, size_t axisj); void addToJointTorqueI(FColDsptr col) override; void calcPostDynCorrectorIteration() override; @@ -29,7 +29,7 @@ namespace MbD { FRowDsptr pGpEI; FMatDsptr ppGpEIpEI; - int iqEI = -1; + size_t iqEI = SIZE_MAX; }; } diff --git a/OndselSolver/DirectionCosineConstraintIqcJqc.cpp b/OndselSolver/DirectionCosineConstraintIqcJqc.cpp index 5061c0e..aee00bc 100644 --- a/OndselSolver/DirectionCosineConstraintIqcJqc.cpp +++ b/OndselSolver/DirectionCosineConstraintIqcJqc.cpp @@ -13,7 +13,7 @@ using namespace MbD; -DirectionCosineConstraintIqcJqc::DirectionCosineConstraintIqcJqc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi, int axisj) : +DirectionCosineConstraintIqcJqc::DirectionCosineConstraintIqcJqc(EndFrmsptr frmi, EndFrmsptr frmj, size_t axisi, size_t axisj) : DirectionCosineConstraintIqcJc(frmi, frmj, axisi, axisj) { } diff --git a/OndselSolver/DirectionCosineConstraintIqcJqc.h b/OndselSolver/DirectionCosineConstraintIqcJqc.h index 0265aae..5d68fcd 100644 --- a/OndselSolver/DirectionCosineConstraintIqcJqc.h +++ b/OndselSolver/DirectionCosineConstraintIqcJqc.h @@ -15,7 +15,7 @@ namespace MbD { { //pGpEJ ppGpEIpEJ ppGpEJpEJ iqEJ public: - DirectionCosineConstraintIqcJqc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi, int axisj); + DirectionCosineConstraintIqcJqc(EndFrmsptr frmi, EndFrmsptr frmj, size_t axisi, size_t axisj); void calcPostDynCorrectorIteration() override; void fillAccICIterError(FColDsptr col) override; @@ -29,7 +29,7 @@ namespace MbD { FRowDsptr pGpEJ; FMatDsptr ppGpEIpEJ; FMatDsptr ppGpEJpEJ; - int iqEJ = -1; + size_t iqEJ = SIZE_MAX; }; } diff --git a/OndselSolver/DirectionCosineConstraintIqctJqc.cpp b/OndselSolver/DirectionCosineConstraintIqctJqc.cpp index e41b309..cc4c800 100644 --- a/OndselSolver/DirectionCosineConstraintIqctJqc.cpp +++ b/OndselSolver/DirectionCosineConstraintIqctJqc.cpp @@ -12,7 +12,7 @@ using namespace MbD; -DirectionCosineConstraintIqctJqc::DirectionCosineConstraintIqctJqc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi, int axisj) : +DirectionCosineConstraintIqctJqc::DirectionCosineConstraintIqctJqc(EndFrmsptr frmi, EndFrmsptr frmj, size_t axisi, size_t axisj) : DirectionCosineConstraintIqcJqc(frmi, frmj, axisi, axisj) { } diff --git a/OndselSolver/DirectionCosineConstraintIqctJqc.h b/OndselSolver/DirectionCosineConstraintIqctJqc.h index ce3781a..2738722 100644 --- a/OndselSolver/DirectionCosineConstraintIqctJqc.h +++ b/OndselSolver/DirectionCosineConstraintIqctJqc.h @@ -15,7 +15,7 @@ namespace MbD { { //pGpt ppGpEIpt ppGpEJpt ppGptpt public: - DirectionCosineConstraintIqctJqc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi, int axisj); + DirectionCosineConstraintIqctJqc(EndFrmsptr frmi, EndFrmsptr frmj, size_t axisi, size_t axisj); void fillAccICIterError(FColDsptr col) override; void fillVelICError(FColDsptr col) override; @@ -24,9 +24,9 @@ namespace MbD { void preVelIC() override; ConstraintType type() override; - double pGpt; + double pGpt = std::numeric_limits::min(); FRowDsptr ppGpEIpt; FRowDsptr ppGpEJpt; - double ppGptpt; + double ppGptpt = std::numeric_limits::min(); }; } diff --git a/OndselSolver/DirectionCosineIecJec.cpp b/OndselSolver/DirectionCosineIecJec.cpp index 1c3e89e..025a917 100644 --- a/OndselSolver/DirectionCosineIecJec.cpp +++ b/OndselSolver/DirectionCosineIecJec.cpp @@ -16,7 +16,7 @@ using namespace MbD; DirectionCosineIecJec::DirectionCosineIecJec() = default; -DirectionCosineIecJec::DirectionCosineIecJec(EndFrmsptr frmi, EndFrmsptr frmj, int axisi, int axisj) : +DirectionCosineIecJec::DirectionCosineIecJec(EndFrmsptr frmi, EndFrmsptr frmj, size_t axisi, size_t axisj) : KinematicIeJe(frmi, frmj), axisI(axisi), axisJ(axisj) { diff --git a/OndselSolver/DirectionCosineIecJec.h b/OndselSolver/DirectionCosineIecJec.h index 1bf0257..9c4a3ca 100644 --- a/OndselSolver/DirectionCosineIecJec.h +++ b/OndselSolver/DirectionCosineIecJec.h @@ -20,12 +20,12 @@ namespace MbD { //aAijIeJe axisI axisJ aAjOIe aAjOJe public: DirectionCosineIecJec(); - DirectionCosineIecJec(EndFrmsptr frmi, EndFrmsptr frmj, int axisi, int axisj); + DirectionCosineIecJec(EndFrmsptr frmi, EndFrmsptr frmj, size_t axisi, size_t axisj); void calcPostDynCorrectorIteration() override; double value() override; - int axisI{}, axisJ{}; //0, 1, 2 = x, y, z + size_t axisI{}, axisJ{}; //0, 1, 2 = x, y, z double aAijIeJe{}; FColDsptr aAjOIe, aAjOJe; }; diff --git a/OndselSolver/DirectionCosineIeqcJec.cpp b/OndselSolver/DirectionCosineIeqcJec.cpp index 6e4423b..54f02e0 100644 --- a/OndselSolver/DirectionCosineIeqcJec.cpp +++ b/OndselSolver/DirectionCosineIeqcJec.cpp @@ -15,7 +15,7 @@ DirectionCosineIeqcJec::DirectionCosineIeqcJec() { } -DirectionCosineIeqcJec::DirectionCosineIeqcJec(EndFrmsptr frmi, EndFrmsptr frmj, int axisi, int axisj) : +DirectionCosineIeqcJec::DirectionCosineIeqcJec(EndFrmsptr frmi, EndFrmsptr frmj, size_t axisi, size_t axisj) : DirectionCosineIecJec(frmi, frmj, axisi, axisj) { } @@ -46,15 +46,15 @@ void DirectionCosineIeqcJec::calcPostDynCorrectorIteration() { DirectionCosineIecJec::calcPostDynCorrectorIteration(); pAjOIepEIT = std::static_pointer_cast(frmI)->pAjOepET(axisI); - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { pAijIeJepEI->at(i) = pAjOIepEIT->at(i)->dot(aAjOJe); } - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto& ppAijIeJepEIipEI = ppAijIeJepEIpEI->at(i); auto& ppAjOIepEIipEI = ppAjOIepEIpEI->at(i); - for (int j = 0; j < 4; j++) + for (size_t j = 0; j < 4; j++) { ppAijIeJepEIipEI->at(j) = ppAjOIepEIipEI->at(j)->dot(aAjOJe); } diff --git a/OndselSolver/DirectionCosineIeqcJec.h b/OndselSolver/DirectionCosineIeqcJec.h index d829b27..2fd271a 100644 --- a/OndselSolver/DirectionCosineIeqcJec.h +++ b/OndselSolver/DirectionCosineIeqcJec.h @@ -16,7 +16,7 @@ namespace MbD { //pAijIeJepEI ppAijIeJepEIpEI pAjOIepEIT ppAjOIepEIpEI public: DirectionCosineIeqcJec(); - DirectionCosineIeqcJec(EndFrmsptr frmi, EndFrmsptr frmj, int axisi, int axisj); + DirectionCosineIeqcJec(EndFrmsptr frmi, EndFrmsptr frmj, size_t axisi, size_t axisj); void calcPostDynCorrectorIteration() override; void initialize() override; diff --git a/OndselSolver/DirectionCosineIeqcJeqc.cpp b/OndselSolver/DirectionCosineIeqcJeqc.cpp index 92598c9..72182f4 100644 --- a/OndselSolver/DirectionCosineIeqcJeqc.cpp +++ b/OndselSolver/DirectionCosineIeqcJeqc.cpp @@ -15,7 +15,7 @@ DirectionCosineIeqcJeqc::DirectionCosineIeqcJeqc() { } -DirectionCosineIeqcJeqc::DirectionCosineIeqcJeqc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi, int axisj) : +DirectionCosineIeqcJeqc::DirectionCosineIeqcJeqc(EndFrmsptr frmi, EndFrmsptr frmj, size_t axisi, size_t axisj) : DirectionCosineIeqcJec(frmi, frmj, axisi, axisj) { } @@ -43,23 +43,23 @@ void DirectionCosineIeqcJeqc::calcPostDynCorrectorIteration() { DirectionCosineIeqcJec::calcPostDynCorrectorIteration(); pAjOJepEJT = std::static_pointer_cast(frmJ)->pAjOepET(axisJ); - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { pAijIeJepEJ->at(i) = aAjOIe->dot(pAjOJepEJT->at(i)); } - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto& ppAijIeJepEIipEJ = ppAijIeJepEIpEJ->at(i); - for (int j = 0; j < 4; j++) + for (size_t j = 0; j < 4; j++) { ppAijIeJepEIipEJ->at(j) = pAjOIepEIT->at(i)->dot(pAjOJepEJT->at(j)); } } - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto& ppAijIeJepEJipEJ = ppAijIeJepEJpEJ->at(i); auto& ppAjOJepEJipEJ = ppAjOJepEJpEJ->at(i); - for (int j = 0; j < 4; j++) + for (size_t j = 0; j < 4; j++) { ppAijIeJepEJipEJ->at(j) = aAjOIe->dot(ppAjOJepEJipEJ->at(j)); } diff --git a/OndselSolver/DirectionCosineIeqcJeqc.h b/OndselSolver/DirectionCosineIeqcJeqc.h index ed43677..b4ee11a 100644 --- a/OndselSolver/DirectionCosineIeqcJeqc.h +++ b/OndselSolver/DirectionCosineIeqcJeqc.h @@ -16,7 +16,7 @@ namespace MbD { //pAijIeJepEJ ppAijIeJepEIpEJ ppAijIeJepEJpEJ pAjOJepEJT ppAjOJepEJpEJ public: DirectionCosineIeqcJeqc(); - DirectionCosineIeqcJeqc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi, int axisj); + DirectionCosineIeqcJeqc(EndFrmsptr frmi, EndFrmsptr frmj, size_t axisi, size_t axisj); void calcPostDynCorrectorIteration() override; void initialize() override; diff --git a/OndselSolver/DirectionCosineIeqctJeqc.cpp b/OndselSolver/DirectionCosineIeqctJeqc.cpp index 6fb505c..57a8a0e 100644 --- a/OndselSolver/DirectionCosineIeqctJeqc.cpp +++ b/OndselSolver/DirectionCosineIeqctJeqc.cpp @@ -16,7 +16,7 @@ DirectionCosineIeqctJeqc::DirectionCosineIeqctJeqc() { } -DirectionCosineIeqctJeqc::DirectionCosineIeqctJeqc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi, int axisj) : +DirectionCosineIeqctJeqc::DirectionCosineIeqctJeqc(EndFrmsptr frmi, EndFrmsptr frmj, size_t axisi, size_t axisj) : DirectionCosineIeqcJeqc(frmi, frmj, axisi, axisj) { } @@ -75,12 +75,12 @@ void DirectionCosineIeqctJeqc::preAccIC() auto pAjOIept = std::static_pointer_cast(frmI)->pAjOept(axisI); auto ppAjOIepEITpt = std::static_pointer_cast(frmI)->ppAjOepETpt(axisI); auto ppAjOIeptpt = std::static_pointer_cast(frmI)->ppAjOeptpt(axisI); - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto& ppAjOIepEITpti = ppAjOIepEITpt->at(i); ppAijIeJepEIpt->atiput(i, ppAjOIepEITpti->dot(aAjOJe)); } - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { ppAijIeJepEJpt->atiput(i, pAjOIept->dot(pAjOJepEJT->at(i))); } diff --git a/OndselSolver/DirectionCosineIeqctJeqc.h b/OndselSolver/DirectionCosineIeqctJeqc.h index 3f73528..f82b645 100644 --- a/OndselSolver/DirectionCosineIeqctJeqc.h +++ b/OndselSolver/DirectionCosineIeqctJeqc.h @@ -16,7 +16,7 @@ namespace MbD { //pAijIeJept ppAijIeJepEIpt ppAijIeJepEJpt ppAijIeJeptpt public: DirectionCosineIeqctJeqc(); - DirectionCosineIeqctJeqc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi, int axisj); + DirectionCosineIeqctJeqc(EndFrmsptr frmi, EndFrmsptr frmj, size_t axisi, size_t axisj); void calcPostDynCorrectorIteration() override; void initialize() override; diff --git a/OndselSolver/DispCompIecJecIe.cpp b/OndselSolver/DispCompIecJecIe.cpp index 213a0ff..cdfdef7 100644 --- a/OndselSolver/DispCompIecJecIe.cpp +++ b/OndselSolver/DispCompIecJecIe.cpp @@ -15,7 +15,7 @@ MbD::DispCompIecJecIe::DispCompIecJecIe() { } -MbD::DispCompIecJecIe::DispCompIecJecIe(EndFrmsptr frmi, EndFrmsptr frmj, int axis) : KinematicIeJe(frmi, frmj), axis(axis) +MbD::DispCompIecJecIe::DispCompIecJecIe(EndFrmsptr frmi, EndFrmsptr frmj, size_t axis) : KinematicIeJe(frmi, frmj), axis(axis) { } diff --git a/OndselSolver/DispCompIecJecIe.h b/OndselSolver/DispCompIecJecIe.h index b06862c..04bd9fc 100644 --- a/OndselSolver/DispCompIecJecIe.h +++ b/OndselSolver/DispCompIecJecIe.h @@ -16,13 +16,13 @@ namespace MbD { //axis riIeJeIe aAjOIe rIeJeO public: DispCompIecJecIe(); - DispCompIecJecIe(EndFrmsptr frmi, EndFrmsptr frmj, int axis); + DispCompIecJecIe(EndFrmsptr frmi, EndFrmsptr frmj, size_t axis); void calc_value() override; void calcPostDynCorrectorIteration() override; double value() override; - int axis; + size_t axis; double riIeJeIe; FColDsptr aAjOIe, rIeJeO; }; diff --git a/OndselSolver/DispCompIecJecKec.cpp b/OndselSolver/DispCompIecJecKec.cpp index f9f6285..06b03b6 100644 --- a/OndselSolver/DispCompIecJecKec.cpp +++ b/OndselSolver/DispCompIecJecKec.cpp @@ -14,7 +14,7 @@ DispCompIecJecKec::DispCompIecJecKec() { } -DispCompIecJecKec::DispCompIecJecKec(EndFrmsptr frmi, EndFrmsptr frmj, EndFrmsptr frmk, int axisk): KinematicIeJe(frmi, frmj), efrmK(frmk), axisK(axisk) +DispCompIecJecKec::DispCompIecJecKec(EndFrmsptr frmi, EndFrmsptr frmj, EndFrmsptr frmk, size_t axisk): KinematicIeJe(frmi, frmj), efrmK(frmk), axisK(axisk) { } diff --git a/OndselSolver/DispCompIecJecKec.h b/OndselSolver/DispCompIecJecKec.h index 5531de7..af34bfa 100644 --- a/OndselSolver/DispCompIecJecKec.h +++ b/OndselSolver/DispCompIecJecKec.h @@ -16,12 +16,12 @@ namespace MbD { //efrmK axisK riIeJeKe aAjOKe rIeJeO public: DispCompIecJecKec(); - DispCompIecJecKec(EndFrmsptr frmi, EndFrmsptr frmj, EndFrmsptr frmk, int axisk); + DispCompIecJecKec(EndFrmsptr frmi, EndFrmsptr frmj, EndFrmsptr frmk, size_t axisk); double value() override; EndFrmsptr efrmK; - int axisK; + size_t axisK; double riIeJeKe; FColDsptr aAjOKe; FColDsptr rIeJeO; diff --git a/OndselSolver/DispCompIecJecKeqc.cpp b/OndselSolver/DispCompIecJecKeqc.cpp index efe61f5..56212bd 100644 --- a/OndselSolver/DispCompIecJecKeqc.cpp +++ b/OndselSolver/DispCompIecJecKeqc.cpp @@ -15,7 +15,7 @@ DispCompIecJecKeqc::DispCompIecJecKeqc() { } -DispCompIecJecKeqc::DispCompIecJecKeqc(EndFrmsptr frmi, EndFrmsptr frmj, EndFrmsptr frmk, int axisk) : DispCompIecJecKec(frmi, frmj, frmk, axisk) +DispCompIecJecKeqc::DispCompIecJecKeqc(EndFrmsptr frmi, EndFrmsptr frmj, EndFrmsptr frmk, size_t axisk) : DispCompIecJecKec(frmi, frmj, frmk, axisk) { } @@ -40,13 +40,13 @@ void DispCompIecJecKeqc::calcPostDynCorrectorIteration() riIeJeKe = aAjOKe->dot(rIeJeO); pAjOKepEKT = efrmKqc->pAjOepET(axisK); ppAjOKepEKpEK = efrmKqc->ppAjOepEpE(axisK); - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { priIeJeKepEK->at(i) = ((pAjOKepEKT->at(i))->dot(rIeJeO)); auto& ppAjOKepEKipEK = ppAjOKepEKpEK->at(i); auto& ppriIeJeKepEKipEK = ppriIeJeKepEKpEK->at(i); ppriIeJeKepEKipEK->at(i) = ((ppAjOKepEKipEK->at(i))->dot(rIeJeO)); - for (int j = i + 1; j < 4; j++) + for (size_t j = i + 1; j < 4; j++) { auto ppriIeJeKepEKipEKj = (ppAjOKepEKipEK->at(i))->dot(rIeJeO); ppriIeJeKepEKipEK->at(j) = ppriIeJeKepEKipEKj; diff --git a/OndselSolver/DispCompIecJecKeqc.h b/OndselSolver/DispCompIecJecKeqc.h index cb689bc..86b55f1 100644 --- a/OndselSolver/DispCompIecJecKeqc.h +++ b/OndselSolver/DispCompIecJecKeqc.h @@ -16,7 +16,7 @@ namespace MbD { //priIeJeKepEK ppriIeJeKepEKpEK pAjOKepEKT ppAjOKepEKpEK public: DispCompIecJecKeqc(); - DispCompIecJecKeqc(EndFrmsptr frmi, EndFrmsptr frmj, EndFrmsptr frmk, int axisk); + DispCompIecJecKeqc(EndFrmsptr frmi, EndFrmsptr frmj, EndFrmsptr frmk, size_t axisk); void calcPostDynCorrectorIteration() override; void initialize() override; diff --git a/OndselSolver/DispCompIecJecO.cpp b/OndselSolver/DispCompIecJecO.cpp index 2b3e111..1b64a0b 100644 --- a/OndselSolver/DispCompIecJecO.cpp +++ b/OndselSolver/DispCompIecJecO.cpp @@ -15,7 +15,7 @@ DispCompIecJecO::DispCompIecJecO() { } -DispCompIecJecO::DispCompIecJecO(EndFrmsptr frmi, EndFrmsptr frmj, int axis) : KinematicIeJe(frmi, frmj), axis(axis) +DispCompIecJecO::DispCompIecJecO(EndFrmsptr frmi, EndFrmsptr frmj, size_t axis) : KinematicIeJe(frmi, frmj), axis(axis) { } diff --git a/OndselSolver/DispCompIecJecO.h b/OndselSolver/DispCompIecJecO.h index ab8e5f3..74a1ca4 100644 --- a/OndselSolver/DispCompIecJecO.h +++ b/OndselSolver/DispCompIecJecO.h @@ -16,12 +16,12 @@ namespace MbD { //axis riIeJeO public: DispCompIecJecO(); - DispCompIecJecO(EndFrmsptr frmi, EndFrmsptr frmj, int axis); + DispCompIecJecO(EndFrmsptr frmi, EndFrmsptr frmj, size_t axis); void calcPostDynCorrectorIteration() override; double value() override; - int axis = -1; + size_t axis = SIZE_MAX; double riIeJeO; }; } diff --git a/OndselSolver/DispCompIeqcJecIe.cpp b/OndselSolver/DispCompIeqcJecIe.cpp index 8a684a7..d8de04e 100644 --- a/OndselSolver/DispCompIeqcJecIe.cpp +++ b/OndselSolver/DispCompIeqcJecIe.cpp @@ -15,7 +15,7 @@ MbD::DispCompIeqcJecIe::DispCompIeqcJecIe() { } -MbD::DispCompIeqcJecIe::DispCompIeqcJecIe(EndFrmsptr frmi, EndFrmsptr frmj, int axis) : DispCompIecJecIe(frmi, frmj, axis) +MbD::DispCompIeqcJecIe::DispCompIeqcJecIe(EndFrmsptr frmi, EndFrmsptr frmj, size_t axis) : DispCompIecJecIe(frmi, frmj, axis) { priIeJeIepXI = std::make_shared>(3); priIeJeIepEI = std::make_shared>(4); @@ -28,12 +28,12 @@ void MbD::DispCompIeqcJecIe::calc_ppvaluepEIpEI() auto frmIeqc = std::static_pointer_cast(frmI); auto mprIeJeOpEIT = frmIeqc->prOeOpE->transpose(); auto mpprIeJeOpEIpEI = frmIeqc->pprOeOpEpE; - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto ppAjOIepEIipEI = ppAjOIepEIpEI->at(i); auto mpprIeJeOpEIipEI = mpprIeJeOpEIpEI->at(i); auto ppriIeJeIepEIipEI = ppriIeJeIepEIpEI->at(i); - for (int j = i; j < 4; j++) + for (size_t j = i; j < 4; j++) { auto term1 = ppAjOIepEIipEI->at(j)->dot(rIeJeO); auto mterm2 = pAjOIepEIT->at(i)->dot(mprIeJeOpEIT->at(j)); @@ -47,10 +47,10 @@ void MbD::DispCompIeqcJecIe::calc_ppvaluepEIpEI() void MbD::DispCompIeqcJecIe::calc_ppvaluepXIpEI() { - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto ppriIeJeIepXIipEI = ppriIeJeIepXIpEI->at(i); - for (int j = 0; j < 4; j++) + for (size_t j = 0; j < 4; j++) { ppriIeJeIepXIipEI->atiput(j, -pAjOIepEIT->at(j)->at(i)); } @@ -62,7 +62,7 @@ void MbD::DispCompIeqcJecIe::calc_pvaluepEI() auto frmIeqc = std::static_pointer_cast(frmI); pAjOIepEIT = frmIeqc->pAjOepET(axis); auto mprIeJeOpEIT = frmIeqc->prOeOpE->transpose(); - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { priIeJeIepEI->atiput(i, pAjOIepEIT->at(i)->dot(rIeJeO) - aAjOIe->dot(mprIeJeOpEIT->at(i))); } @@ -70,7 +70,7 @@ void MbD::DispCompIeqcJecIe::calc_pvaluepEI() void MbD::DispCompIeqcJecIe::calc_pvaluepXI() { - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { priIeJeIepXI->atiput(i, -aAjOIe->at(i)); } diff --git a/OndselSolver/DispCompIeqcJecIe.h b/OndselSolver/DispCompIeqcJecIe.h index 8f2b4d7..889b411 100644 --- a/OndselSolver/DispCompIeqcJecIe.h +++ b/OndselSolver/DispCompIeqcJecIe.h @@ -16,7 +16,7 @@ namespace MbD { //priIeJeIepXI priIeJeIepEI ppriIeJeIepXIpEI ppriIeJeIepEIpEI pAjOIepEIT ppAjOIepEIpEI public: DispCompIeqcJecIe(); - DispCompIeqcJecIe(EndFrmsptr frmi, EndFrmsptr frmj, int axis); + DispCompIeqcJecIe(EndFrmsptr frmi, EndFrmsptr frmj, size_t axis); void calc_ppvaluepEIpEI() override; void calc_ppvaluepXIpEI() override; diff --git a/OndselSolver/DispCompIeqcJecKeqc.cpp b/OndselSolver/DispCompIeqcJecKeqc.cpp index c25efc1..9733b27 100644 --- a/OndselSolver/DispCompIeqcJecKeqc.cpp +++ b/OndselSolver/DispCompIeqcJecKeqc.cpp @@ -15,7 +15,7 @@ DispCompIeqcJecKeqc::DispCompIeqcJecKeqc() { } -DispCompIeqcJecKeqc::DispCompIeqcJecKeqc(EndFrmsptr frmi, EndFrmsptr frmj, EndFrmsptr frmk, int axisk) : DispCompIecJecKeqc(frmi, frmj, frmk, axisk) +DispCompIeqcJecKeqc::DispCompIeqcJecKeqc(EndFrmsptr frmi, EndFrmsptr frmj, EndFrmsptr frmk, size_t axisk) : DispCompIecJecKeqc(frmi, frmj, frmk, axisk) { } @@ -35,39 +35,39 @@ void DispCompIeqcJecKeqc::calcPostDynCorrectorIteration() auto frmIqc = std::static_pointer_cast(frmI); auto mprIeJeOpEIT = frmIqc->prOeOpE->transpose(); auto& mpprIeJeOpEIpEI = frmIqc->pprOeOpEpE; - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { priIeJeKepXI->at(i) = 0.0 - (aAjOKe->at(i)); } - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { priIeJeKepEI->at(i) = 0.0 - (aAjOKe->dot(mprIeJeOpEIT->at(i))); } - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto& ppriIeJeKepXIipEK = ppriIeJeKepXIpEK->at(i); - for (int j = 0; j < 4; j++) + for (size_t j = 0; j < 4; j++) { ppriIeJeKepXIipEK->at(j) = 0.0 - (pAjOKepEKT->at(j)->at(i)); } } - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto& mpprIeJeOpEIipEI = mpprIeJeOpEIpEI->at(i); auto& ppriIeJeKepEIipEI = ppriIeJeKepEIpEI->at(i); ppriIeJeKepEIipEI->at(i) = 0.0 - (aAjOKe->dot(mpprIeJeOpEIipEI->at(i))); - for (int j = 0; j < 4; j++) + for (size_t j = 0; j < 4; j++) { auto ppriIeJeKepEIipEIj = 0.0 - (aAjOKe->dot(mpprIeJeOpEIipEI->at(j))); ppriIeJeKepEIipEI->at(j) = ppriIeJeKepEIipEIj; ppriIeJeKepEIpEI->at(j)->at(i) = ppriIeJeKepEIipEIj; } } - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto& mprIeJeOpEITi = mprIeJeOpEIT->at(i); auto& ppriIeJeKepEIipEK = ppriIeJeKepEIpEK->at(i); - for (int j = 0; j < 4; j++) + for (size_t j = 0; j < 4; j++) { ppriIeJeKepEIipEK->at(j) = 0.0 - (pAjOKepEKT->at(j)->dot(mprIeJeOpEITi)); } diff --git a/OndselSolver/DispCompIeqcJecKeqc.h b/OndselSolver/DispCompIeqcJecKeqc.h index b53de97..9b5fe7f 100644 --- a/OndselSolver/DispCompIeqcJecKeqc.h +++ b/OndselSolver/DispCompIeqcJecKeqc.h @@ -16,7 +16,7 @@ namespace MbD { //priIeJeKepXI priIeJeKepEI ppriIeJeKepXIpEK ppriIeJeKepEIpEI ppriIeJeKepEIpEK public: DispCompIeqcJecKeqc(); - DispCompIeqcJecKeqc(EndFrmsptr frmi, EndFrmsptr frmj, EndFrmsptr frmk, int axisk); + DispCompIeqcJecKeqc(EndFrmsptr frmi, EndFrmsptr frmj, EndFrmsptr frmk, size_t axisk); void calcPostDynCorrectorIteration() override; void initialize() override; diff --git a/OndselSolver/DispCompIeqcJecO.cpp b/OndselSolver/DispCompIeqcJecO.cpp index 87960a0..1cc410f 100644 --- a/OndselSolver/DispCompIeqcJecO.cpp +++ b/OndselSolver/DispCompIeqcJecO.cpp @@ -15,7 +15,7 @@ DispCompIeqcJecO::DispCompIeqcJecO() { } -DispCompIeqcJecO::DispCompIeqcJecO(EndFrmsptr frmi, EndFrmsptr frmj, int axis) : DispCompIecJecO(frmi, frmj, axis) +DispCompIeqcJecO::DispCompIeqcJecO(EndFrmsptr frmi, EndFrmsptr frmj, size_t axis) : DispCompIecJecO(frmi, frmj, axis) { } diff --git a/OndselSolver/DispCompIeqcJecO.h b/OndselSolver/DispCompIeqcJecO.h index 3ca7553..2d1f33d 100644 --- a/OndselSolver/DispCompIeqcJecO.h +++ b/OndselSolver/DispCompIeqcJecO.h @@ -16,7 +16,7 @@ namespace MbD { //priIeJeOpXI priIeJeOpEI ppriIeJeOpEIpEI public: DispCompIeqcJecO(); - DispCompIeqcJecO(EndFrmsptr frmi, EndFrmsptr frmj, int axis); + DispCompIeqcJecO(EndFrmsptr frmi, EndFrmsptr frmj, size_t axis); void calcPostDynCorrectorIteration() override; void initializeGlobally() override; diff --git a/OndselSolver/DispCompIeqcJeqcIe.cpp b/OndselSolver/DispCompIeqcJeqcIe.cpp index 662b43e..0eeab22 100644 --- a/OndselSolver/DispCompIeqcJeqcIe.cpp +++ b/OndselSolver/DispCompIeqcJeqcIe.cpp @@ -15,7 +15,7 @@ MbD::DispCompIeqcJeqcIe::DispCompIeqcJeqcIe() { } -MbD::DispCompIeqcJeqcIe::DispCompIeqcJeqcIe(EndFrmsptr frmi, EndFrmsptr frmj, int axis) : DispCompIeqcJecIe(frmi, frmj, axis) +MbD::DispCompIeqcJeqcIe::DispCompIeqcJeqcIe(EndFrmsptr frmi, EndFrmsptr frmj, size_t axis) : DispCompIeqcJecIe(frmi, frmj, axis) { priIeJeIepXJ = std::make_shared>(3); priIeJeIepEJ = std::make_shared>(4); @@ -40,11 +40,11 @@ void MbD::DispCompIeqcJeqcIe::calc_ppvaluepEJpEJ() { auto frmJeqc = std::static_pointer_cast(frmJ); auto pprIeJeOpEJpEJ = frmJeqc->pprOeOpEpE; - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto pprIeJeOpEJipEJ = pprIeJeOpEJpEJ->at(i); auto ppriIeJeIepEJipEJ = ppriIeJeIepEJpEJ->at(i); - for (int j = i; j < 4; j++) + for (size_t j = i; j < 4; j++) { auto term1 = aAjOIe->dot(pprIeJeOpEJipEJ->at(j)); ppriIeJeIepEJipEJ->atiput(j, term1); @@ -57,7 +57,7 @@ void MbD::DispCompIeqcJeqcIe::calc_pvaluepEJ() { auto frmJeqc = std::static_pointer_cast(frmJ); auto prIeJeOpEJT = frmJeqc->prOeOpE->transpose(); - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { priIeJeIepEJ->atiput(i, aAjOIe->dot(prIeJeOpEJT->at(i))); } @@ -65,7 +65,7 @@ void MbD::DispCompIeqcJeqcIe::calc_pvaluepEJ() void MbD::DispCompIeqcJeqcIe::calc_pvaluepXJ() { - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { priIeJeIepXJ->atiput(i, aAjOIe->at(i)); } diff --git a/OndselSolver/DispCompIeqcJeqcIe.h b/OndselSolver/DispCompIeqcJeqcIe.h index f632b2f..cc15a9a 100644 --- a/OndselSolver/DispCompIeqcJeqcIe.h +++ b/OndselSolver/DispCompIeqcJeqcIe.h @@ -16,7 +16,7 @@ namespace MbD { //priIeJeIepXJ priIeJeIepEJ ppriIeJeIepEIpXJ ppriIeJeIepEIpEJ ppriIeJeIepEJpEJ public: DispCompIeqcJeqcIe(); - DispCompIeqcJeqcIe(EndFrmsptr frmi, EndFrmsptr frmj, int axis); + DispCompIeqcJeqcIe(EndFrmsptr frmi, EndFrmsptr frmj, size_t axis); void calc_ppvaluepEIpEJ() override; void calc_ppvaluepEIpXJ() override; diff --git a/OndselSolver/DispCompIeqcJeqcKeqc.cpp b/OndselSolver/DispCompIeqcJeqcKeqc.cpp index 61a6254..dcd8ceb 100644 --- a/OndselSolver/DispCompIeqcJeqcKeqc.cpp +++ b/OndselSolver/DispCompIeqcJeqcKeqc.cpp @@ -15,7 +15,7 @@ DispCompIeqcJeqcKeqc::DispCompIeqcJeqcKeqc() { } -DispCompIeqcJeqcKeqc::DispCompIeqcJeqcKeqc(EndFrmsptr frmi, EndFrmsptr frmj, EndFrmsptr frmk, int axisk) : DispCompIeqcJecKeqc(frmi, frmj, frmk, axisk) +DispCompIeqcJeqcKeqc::DispCompIeqcJeqcKeqc(EndFrmsptr frmi, EndFrmsptr frmj, EndFrmsptr frmk, size_t axisk) : DispCompIeqcJecKeqc(frmi, frmj, frmk, axisk) { } @@ -35,39 +35,39 @@ void DispCompIeqcJeqcKeqc::calcPostDynCorrectorIteration() auto frmJqc = std::static_pointer_cast(frmJ); auto prIeJeOpEJT = frmJqc->prOeOpE->transpose(); auto& pprIeJeOpEJpEJ = frmJqc->pprOeOpEpE; - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { priIeJeKepXJ->atiput(i, aAjOKe->at(i)); } - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { priIeJeKepEJ->atiput(i, aAjOKe->dot(prIeJeOpEJT->at(i))); } - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto& ppriIeJeKepXJipEK = ppriIeJeKepXJpEK->at(i); - for (int j = 0; j < 4; j++) + for (size_t j = 0; j < 4; j++) { ppriIeJeKepXJipEK->atiput(j, pAjOKepEKT->at(j)->at(i)); } } - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto& pprIeJeOpEJipEJ = pprIeJeOpEJpEJ->at(i); auto& ppriIeJeKepEJipEJ = ppriIeJeKepEJpEJ->at(i); ppriIeJeKepEJipEJ->atiput(i, aAjOKe->dot(pprIeJeOpEJipEJ->at(i))); - for (int j = 0; j < 4; j++) + for (size_t j = 0; j < 4; j++) { auto ppriIeJeKepEJipEJj = (aAjOKe->dot(pprIeJeOpEJipEJ->at(j))); ppriIeJeKepEJipEJ->atiput(j, ppriIeJeKepEJipEJj); ppriIeJeKepEJpEJ->atijput(j, i, ppriIeJeKepEJipEJj); } } - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto& prIeJeOpEJTi = prIeJeOpEJT->at(i); auto& ppriIeJeKepEJipEK = ppriIeJeKepEJpEK->at(i); - for (int j = 0; j < 4; j++) + for (size_t j = 0; j < 4; j++) { ppriIeJeKepEJipEK->atiput(j, pAjOKepEKT->at(j)->dot(prIeJeOpEJTi)); } diff --git a/OndselSolver/DispCompIeqcJeqcKeqc.h b/OndselSolver/DispCompIeqcJeqcKeqc.h index 4af5ac3..57213dc 100644 --- a/OndselSolver/DispCompIeqcJeqcKeqc.h +++ b/OndselSolver/DispCompIeqcJeqcKeqc.h @@ -16,7 +16,7 @@ namespace MbD { //priIeJeKepXJ priIeJeKepEJ ppriIeJeKepXJpEK ppriIeJeKepEJpEJ ppriIeJeKepEJpEK public: DispCompIeqcJeqcKeqc(); - DispCompIeqcJeqcKeqc(EndFrmsptr frmi, EndFrmsptr frmj, EndFrmsptr frmk, int axisk); + DispCompIeqcJeqcKeqc(EndFrmsptr frmi, EndFrmsptr frmj, EndFrmsptr frmk, size_t axisk); void calcPostDynCorrectorIteration() override; void initialize() override; diff --git a/OndselSolver/DispCompIeqcJeqcKeqct.cpp b/OndselSolver/DispCompIeqcJeqcKeqct.cpp index 0820af1..bd3987e 100644 --- a/OndselSolver/DispCompIeqcJeqcKeqct.cpp +++ b/OndselSolver/DispCompIeqcJeqcKeqct.cpp @@ -16,7 +16,7 @@ DispCompIeqcJeqcKeqct::DispCompIeqcJeqcKeqct() { } -DispCompIeqcJeqcKeqct::DispCompIeqcJeqcKeqct(EndFrmsptr frmi, EndFrmsptr frmj, EndFrmsptr frmk, int axisk) : DispCompIeqcJeqcKeqc(frmi, frmj, frmk, axisk) +DispCompIeqcJeqcKeqct::DispCompIeqcJeqcKeqct(EndFrmsptr frmi, EndFrmsptr frmj, EndFrmsptr frmk, size_t axisk) : DispCompIeqcJeqcKeqc(frmi, frmj, frmk, axisk) { } @@ -93,12 +93,12 @@ void DispCompIeqcJeqcKeqct::preAccIC() auto ppAjOKeptpt = std::static_pointer_cast(efrmK)->ppAjOeptpt(axisK); auto prIeJeOpEIT = std::static_pointer_cast(frmI)->prOeOpE->transpose()->negated(); auto prIeJeOpEJT = std::static_pointer_cast(frmJ)->prOeOpE->transpose(); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { ppriIeJeKepXIpt->atiput(i, -(pAjOKept->at(i))); ppriIeJeKepXJpt->atiput(i, pAjOKept->at(i)); } - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { ppriIeJeKepEIpt->atiput(i, pAjOKept->dot(prIeJeOpEIT->at(i))); ppriIeJeKepEJpt->atiput(i, pAjOKept->dot(prIeJeOpEJT->at(i))); diff --git a/OndselSolver/DispCompIeqcJeqcKeqct.h b/OndselSolver/DispCompIeqcJeqcKeqct.h index b555101..906319e 100644 --- a/OndselSolver/DispCompIeqcJeqcKeqct.h +++ b/OndselSolver/DispCompIeqcJeqcKeqct.h @@ -16,7 +16,7 @@ namespace MbD { //priIeJeKept ppriIeJeKepXIpt ppriIeJeKepEIpt ppriIeJeKepXJpt ppriIeJeKepEJpt ppriIeJeKepEKpt ppriIeJeKeptpt public: DispCompIeqcJeqcKeqct(); - DispCompIeqcJeqcKeqct(EndFrmsptr frmi, EndFrmsptr frmj, EndFrmsptr frmk, int axisk); + DispCompIeqcJeqcKeqct(EndFrmsptr frmi, EndFrmsptr frmj, EndFrmsptr frmk, size_t axisk); void calcPostDynCorrectorIteration() override; void initialize() override; diff --git a/OndselSolver/DispCompIeqcJeqcO.cpp b/OndselSolver/DispCompIeqcJeqcO.cpp index c16e333..9c8036d 100644 --- a/OndselSolver/DispCompIeqcJeqcO.cpp +++ b/OndselSolver/DispCompIeqcJeqcO.cpp @@ -15,7 +15,7 @@ DispCompIeqcJeqcO::DispCompIeqcJeqcO() { } -DispCompIeqcJeqcO::DispCompIeqcJeqcO(EndFrmsptr frmi, EndFrmsptr frmj, int axis) : DispCompIeqcJecO(frmi, frmj, axis) +DispCompIeqcJeqcO::DispCompIeqcJeqcO(EndFrmsptr frmi, EndFrmsptr frmj, size_t axis) : DispCompIeqcJecO(frmi, frmj, axis) { } diff --git a/OndselSolver/DispCompIeqcJeqcO.h b/OndselSolver/DispCompIeqcJeqcO.h index 0b58d70..57aecf1 100644 --- a/OndselSolver/DispCompIeqcJeqcO.h +++ b/OndselSolver/DispCompIeqcJeqcO.h @@ -16,7 +16,7 @@ namespace MbD { //priIeJeOpXJ priIeJeOpEJ ppriIeJeOpEJpEJ public: DispCompIeqcJeqcO(); - DispCompIeqcJeqcO(EndFrmsptr frmi, EndFrmsptr frmj, int axis); + DispCompIeqcJeqcO(EndFrmsptr frmi, EndFrmsptr frmj, size_t axis); void calcPostDynCorrectorIteration() override; void initializeGlobally() override; diff --git a/OndselSolver/DispCompIeqctJeqcIe.cpp b/OndselSolver/DispCompIeqctJeqcIe.cpp index 4b6b20d..1210186 100644 --- a/OndselSolver/DispCompIeqctJeqcIe.cpp +++ b/OndselSolver/DispCompIeqctJeqcIe.cpp @@ -15,7 +15,7 @@ MbD::DispCompIeqctJeqcIe::DispCompIeqctJeqcIe() { } -MbD::DispCompIeqctJeqcIe::DispCompIeqctJeqcIe(EndFrmsptr frmi, EndFrmsptr frmj, int axis) : DispCompIeqcJeqcIe(frmi, frmj, axis) +MbD::DispCompIeqctJeqcIe::DispCompIeqctJeqcIe(EndFrmsptr frmi, EndFrmsptr frmj, size_t axis) : DispCompIeqcJeqcIe(frmi, frmj, axis) { ppriIeJeIepXIpt = std::make_shared>(3); ppriIeJeIepEIpt = std::make_shared>(4); @@ -31,7 +31,7 @@ void MbD::DispCompIeqctJeqcIe::calc_ppvaluepEIpt() auto mprIeJeOpEIT = frmIeqct->prOeOpE->transpose(); auto mpprIeJeOpEITpt = frmIeqct->pprOeOpEpt->transpose(); auto mprIeJeOpt = frmIeqct->prOeOpt; - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto ppAjOIepEITpti = ppAjOIepEITpt->at(i); auto pAjOIepEITi = pAjOIepEIT->at(i); @@ -50,7 +50,7 @@ void MbD::DispCompIeqctJeqcIe::calc_ppvaluepEJpt() auto frmJeqct = std::static_pointer_cast(frmJ); auto pAjOIept = frmIeqct->pAjOept(axis); auto prIeJeOpEJT = frmJeqct->prOeOpE->transpose(); - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { ppriIeJeIepEJpt->atiput(i, pAjOIept->dot(prIeJeOpEJT->at(i))); } @@ -71,7 +71,7 @@ void MbD::DispCompIeqctJeqcIe::calc_ppvaluepXIpt() { auto frmIeqct = std::static_pointer_cast(frmI); auto pAjOIept = frmIeqct->pAjOept(axis); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { ppriIeJeIepXIpt->atiput(i, -pAjOIept->at(i)); } @@ -81,7 +81,7 @@ void MbD::DispCompIeqctJeqcIe::calc_ppvaluepXJpt() { auto frmIeqct = std::static_pointer_cast(frmI); auto pAjOIept = frmIeqct->pAjOept(axis); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { ppriIeJeIepXJpt->atiput(i, pAjOIept->at(i)); } diff --git a/OndselSolver/DispCompIeqctJeqcIe.h b/OndselSolver/DispCompIeqctJeqcIe.h index 42b4e34..bb4656f 100644 --- a/OndselSolver/DispCompIeqctJeqcIe.h +++ b/OndselSolver/DispCompIeqctJeqcIe.h @@ -16,7 +16,7 @@ namespace MbD { //priIeJeIept ppriIeJeIepXIpt ppriIeJeIepEIpt ppriIeJeIepXJpt ppriIeJeIepEJpt ppriIeJeIeptpt public: DispCompIeqctJeqcIe(); - DispCompIeqctJeqcIe(EndFrmsptr frmi, EndFrmsptr frmj, int axis); + DispCompIeqctJeqcIe(EndFrmsptr frmi, EndFrmsptr frmj, size_t axis); void calc_ppvaluepEIpt() override; void calc_ppvaluepEJpt() override; diff --git a/OndselSolver/DispCompIeqctJeqcKeqct.cpp b/OndselSolver/DispCompIeqctJeqcKeqct.cpp index 41ea675..7b303ca 100644 --- a/OndselSolver/DispCompIeqctJeqcKeqct.cpp +++ b/OndselSolver/DispCompIeqctJeqcKeqct.cpp @@ -15,7 +15,7 @@ DispCompIeqctJeqcKeqct::DispCompIeqctJeqcKeqct() { } -DispCompIeqctJeqcKeqct::DispCompIeqctJeqcKeqct(EndFrmsptr frmi, EndFrmsptr frmj, EndFrmsptr frmk, int axisk) : DispCompIeqcJeqcKeqct(frmi, frmj, frmk, axisk) +DispCompIeqctJeqcKeqct::DispCompIeqctJeqcKeqct(EndFrmsptr frmi, EndFrmsptr frmj, EndFrmsptr frmk, size_t axisk) : DispCompIeqcJeqcKeqct(frmi, frmj, frmk, axisk) { } @@ -34,7 +34,7 @@ void DispCompIeqctJeqcKeqct::preAccIC() auto& mprIeJeOpt = efrmIqct->prOeOpt; auto mpprIeJeOpEITpt = efrmIqct->pprOeOpEpt->transpose(); auto& mpprIeJeOptpt = efrmIqct->pprOeOptpt; - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { ppriIeJeKepEIpt->atiminusNumber(i, aAjOKe->dot(mpprIeJeOpEITpt->at(i))); ppriIeJeKepEKpt->atiminusNumber(i, pAjOKepEKT->at(i)->dot(mprIeJeOpt)); diff --git a/OndselSolver/DispCompIeqctJeqcKeqct.h b/OndselSolver/DispCompIeqctJeqcKeqct.h index 172ef5d..8c4b74f 100644 --- a/OndselSolver/DispCompIeqctJeqcKeqct.h +++ b/OndselSolver/DispCompIeqctJeqcKeqct.h @@ -16,7 +16,7 @@ namespace MbD { // public: DispCompIeqctJeqcKeqct(); - DispCompIeqctJeqcKeqct(EndFrmsptr frmi, EndFrmsptr frmj, EndFrmsptr frmk, int axisk); + DispCompIeqctJeqcKeqct(EndFrmsptr frmi, EndFrmsptr frmj, EndFrmsptr frmk, size_t axisk); void preAccIC() override; void preVelIC() override; diff --git a/OndselSolver/DispCompIeqctJeqcO.cpp b/OndselSolver/DispCompIeqctJeqcO.cpp index 56b2ec2..babf941 100644 --- a/OndselSolver/DispCompIeqctJeqcO.cpp +++ b/OndselSolver/DispCompIeqctJeqcO.cpp @@ -15,7 +15,7 @@ DispCompIeqctJeqcO::DispCompIeqctJeqcO() { } -DispCompIeqctJeqcO::DispCompIeqctJeqcO(EndFrmsptr frmi, EndFrmsptr frmj, int axis) : DispCompIeqcJeqcO(frmi, frmj, axis) +DispCompIeqctJeqcO::DispCompIeqctJeqcO(EndFrmsptr frmi, EndFrmsptr frmj, size_t axis) : DispCompIeqcJeqcO(frmi, frmj, axis) { } diff --git a/OndselSolver/DispCompIeqctJeqcO.h b/OndselSolver/DispCompIeqctJeqcO.h index 4a56ba5..01035e3 100644 --- a/OndselSolver/DispCompIeqctJeqcO.h +++ b/OndselSolver/DispCompIeqctJeqcO.h @@ -16,7 +16,7 @@ namespace MbD { //priIeJeOpt ppriIeJeOpEIpt ppriIeJeOptpt public: DispCompIeqctJeqcO(); - DispCompIeqctJeqcO(EndFrmsptr frmi, EndFrmsptr frmj, int axis); + DispCompIeqctJeqcO(EndFrmsptr frmi, EndFrmsptr frmj, size_t axis); void calcPostDynCorrectorIteration() override; void initializeGlobally() override; diff --git a/OndselSolver/DistIeqcJec.cpp b/OndselSolver/DistIeqcJec.cpp index 51948cb..1971586 100644 --- a/OndselSolver/DistIeqcJec.cpp +++ b/OndselSolver/DistIeqcJec.cpp @@ -30,11 +30,11 @@ void MbD::DistIeqcJec::calcPrivate() auto muIeJeOT = muIeJeO->transpose(); prIeJepXI = muIeJeOT; prIeJepEI = muIeJeOT->timesFullMatrix(mprIeJeOpEI); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto& pprIeJepXIipXI = pprIeJepXIpXI->at(i); auto& prIeJepXIi = prIeJepXI->at(i); - for (int j = 0; j < 3; j++) + for (size_t j = 0; j < 3; j++) { auto element = (i == j) ? 1.0 : 0.0; element -= prIeJepXIi * prIeJepXI->at(j); @@ -42,25 +42,25 @@ void MbD::DistIeqcJec::calcPrivate() } } pprIeJepXIpEI = std::make_shared>(3, 4); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto& pprIeJepXIipEI = pprIeJepXIpEI->at(i); auto& prIeJepXIi = prIeJepXI->at(i); auto& mprIeJeOipEI = mprIeJeOpEI->at(i); - for (int j = 0; j < 4; j++) + for (size_t j = 0; j < 4; j++) { auto element = mprIeJeOipEI->at(j) - prIeJepXIi * prIeJepEI->at(j); pprIeJepXIipEI->atiput(j, element / rIeJe); } } pprIeJepEIpEI = std::make_shared>(4, 4); - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto& pprIeJepEIipEI = pprIeJepEIpEI->at(i); auto& prIeJepEIi = prIeJepEI->at(i); auto& mpprIeJeOpEIipEI = mpprIeJeOpEIpEI->at(i); auto& mprIeJeOpEIiT = mprIeJeOpEIT->at(i); - for (int j = 0; j < 4; j++) + for (size_t j = 0; j < 4; j++) { auto element = mprIeJeOpEIiT->dot(mprIeJeOpEIT->at(j)) - mpprIeJeOpEIipEI->at(j)->dot(rIeJeO) - prIeJepEIi * prIeJepEI->at(j); diff --git a/OndselSolver/DistIeqcJeqc.cpp b/OndselSolver/DistIeqcJeqc.cpp index 8b8a3da..af78cfb 100644 --- a/OndselSolver/DistIeqcJeqc.cpp +++ b/OndselSolver/DistIeqcJeqc.cpp @@ -30,11 +30,11 @@ void MbD::DistIeqcJeqc::calcPrivate() auto uIeJeOT = uIeJeO->transpose(); prIeJepXJ = uIeJeOT; prIeJepEJ = uIeJeOT->timesFullMatrix(prIeJeOpEJ); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto& pprIeJepXIipXJ = pprIeJepXIpXJ->at(i); auto& prIeJepXIi = prIeJepXI->at(i); - for (int j = 0; j < 3; j++) + for (size_t j = 0; j < 3; j++) { auto element = (i == j) ? -1.0 : 0.0; element -= prIeJepXIi * prIeJepXJ->at(j); @@ -42,23 +42,23 @@ void MbD::DistIeqcJeqc::calcPrivate() } } - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto& pprIeJepEIipXJ = pprIeJepEIpXJ->at(i); auto& prIeJepEIi = prIeJepEI->at(i); auto& mprIeJeOpEIiT = mprIeJeOpEIT->at(i); - for (int j = 0; j < 3; j++) + for (size_t j = 0; j < 3; j++) { auto element = 0.0 - mprIeJeOpEIiT->at(j) - prIeJepEIi * prIeJepXJ->at(j); pprIeJepEIipXJ->atiput(j, element / rIeJe); } } - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto& pprIeJepXJipXJ = pprIeJepXJpXJ->at(i); auto& prIeJepXJi = prIeJepXJ->at(i); - for (int j = 0; j < 3; j++) + for (size_t j = 0; j < 3; j++) { auto element = (i == j) ? 1.0 : 0.0; element -= prIeJepXJi * prIeJepXJ->at(j); @@ -66,49 +66,49 @@ void MbD::DistIeqcJeqc::calcPrivate() } } - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto& pprIeJepXIipEJ = pprIeJepXIpEJ->at(i); auto& prIeJepXIi = prIeJepXI->at(i); auto& prIeJeOipEJ = prIeJeOpEJ->at(i); - for (int j = 0; j < 4; j++) + for (size_t j = 0; j < 4; j++) { auto element = 0.0 - prIeJeOipEJ->at(j) - prIeJepXIi * prIeJepEJ->at(j); pprIeJepXIipEJ->atiput(j, element / rIeJe); } } - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto& pprIeJepEIipEJ = pprIeJepEIpEJ->at(i); auto& prIeJepEIi = prIeJepEI->at(i); auto& mprIeJeOpEIiT = mprIeJeOpEIT->at(i); - for (int j = 0; j < 4; j++) + for (size_t j = 0; j < 4; j++) { auto element = 0.0 - mprIeJeOpEIiT->dot(prIeJeOpEJT->at(j)) - prIeJepEIi * prIeJepEJ->at(j); pprIeJepEIipEJ->atiput(j, element / rIeJe); } } - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto& pprIeJepXJipEJ = pprIeJepXJpEJ->at(i); auto& prIeJepXJi = prIeJepXJ->at(i); auto& prIeJeOipEJ = prIeJeOpEJ->at(i); - for (int j = 0; j < 4; j++) + for (size_t j = 0; j < 4; j++) { auto element = prIeJeOipEJ->at(j) - prIeJepXJi * prIeJepEJ->at(j); pprIeJepXJipEJ->atiput(j, element / rIeJe); } } - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto& pprIeJepEJipEJ = pprIeJepEJpEJ->at(i); auto& prIeJepEJi = prIeJepEJ->at(i); auto& pprIeJeOpEJipEJ = pprIeJeOpEJpEJ->at(i); auto& prIeJeOpEJiT = prIeJeOpEJT->at(i); - for (int j = 0; j < 4; j++) + for (size_t j = 0; j < 4; j++) { auto element = prIeJeOpEJiT->dot(prIeJeOpEJT->at(j)) + pprIeJeOpEJipEJ->at(j)->dot(rIeJeO) - prIeJepEJi * prIeJepEJ->at(j); diff --git a/OndselSolver/DistanceConstraintIqcJc.cpp b/OndselSolver/DistanceConstraintIqcJc.cpp index b92c7dc..7aeebfb 100644 --- a/OndselSolver/DistanceConstraintIqcJc.cpp +++ b/OndselSolver/DistanceConstraintIqcJc.cpp @@ -30,7 +30,7 @@ void MbD::DistanceConstraintIqcJc::addToJointTorqueI(FColDsptr jointTorque) auto pAOIppEI = frmIeqc->pAOppE(); auto aBOIp = frmIeqc->aBOp(); auto fpAOIppEIrIpIeIp = std::make_shared>(4, 0.0); - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto dum = cForceT->timesFullColumn(pAOIppEI->at(i)->timesFullColumn(rIpIeIp)); fpAOIppEIrIpIeIp->atiput(i, dum); diff --git a/OndselSolver/DistanceConstraintIqcJc.h b/OndselSolver/DistanceConstraintIqcJc.h index 4769199..fdec00f 100644 --- a/OndselSolver/DistanceConstraintIqcJc.h +++ b/OndselSolver/DistanceConstraintIqcJc.h @@ -30,7 +30,7 @@ namespace MbD { FRowDsptr pGpXI, pGpEI; FMatDsptr ppGpXIpXI, ppGpXIpEI, ppGpEIpEI; - int iqXI, iqEI; + size_t iqXI, iqEI; }; } diff --git a/OndselSolver/DistanceConstraintIqcJqc.h b/OndselSolver/DistanceConstraintIqcJqc.h index dbd3695..e788133 100644 --- a/OndselSolver/DistanceConstraintIqcJqc.h +++ b/OndselSolver/DistanceConstraintIqcJqc.h @@ -28,7 +28,7 @@ namespace MbD { FRowDsptr pGpXJ, pGpEJ; FMatDsptr ppGpXIpXJ, ppGpEIpXJ, ppGpXJpXJ, ppGpXIpEJ, ppGpEIpEJ, ppGpXJpEJ, ppGpEJpEJ; - int iqXJ, iqEJ; + size_t iqXJ, iqEJ; }; } diff --git a/OndselSolver/DistancexyConstraintIqcJc.cpp b/OndselSolver/DistancexyConstraintIqcJc.cpp index b60d526..18bb2aa 100644 --- a/OndselSolver/DistancexyConstraintIqcJc.cpp +++ b/OndselSolver/DistancexyConstraintIqcJc.cpp @@ -30,7 +30,7 @@ void MbD::DistancexyConstraintIqcJc::addToJointTorqueI(FColDsptr jointTorque) auto pAOIppEI = frmIeqc->pAOppE(); auto aBOIp = frmIeqc->aBOp(); auto fpAOIppEIrIpIeIp = std::make_shared>(4, 0.0); - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto dum = cForceT->timesFullColumn(pAOIppEI->at(i)->timesFullColumn(rIpIeIp)); fpAOIppEIrIpIeIp->atiput(i, dum); diff --git a/OndselSolver/DistancexyConstraintIqcJc.h b/OndselSolver/DistancexyConstraintIqcJc.h index c20e7fd..be02041 100644 --- a/OndselSolver/DistancexyConstraintIqcJc.h +++ b/OndselSolver/DistancexyConstraintIqcJc.h @@ -36,7 +36,7 @@ namespace MbD { FRowDsptr pGpXI, pGpEI; FMatDsptr ppGpXIpXI, ppGpXIpEI, ppGpEIpEI; - int iqXI, iqEI; + size_t iqXI, iqEI; }; } diff --git a/OndselSolver/DistancexyConstraintIqcJqc.h b/OndselSolver/DistancexyConstraintIqcJqc.h index 3662c66..4150533 100644 --- a/OndselSolver/DistancexyConstraintIqcJqc.h +++ b/OndselSolver/DistancexyConstraintIqcJqc.h @@ -37,7 +37,7 @@ namespace MbD { FRowDsptr pGpXJ, pGpEJ; FMatDsptr ppGpXIpXJ, ppGpEIpXJ, ppGpXJpXJ, ppGpXIpEJ, ppGpEIpEJ, ppGpXJpEJ, ppGpEJpEJ; - int iqXJ, iqEJ; + size_t iqXJ, iqEJ; }; } diff --git a/OndselSolver/DistxyIeqcJec.cpp b/OndselSolver/DistxyIeqcJec.cpp index 12436c2..49a985e 100644 --- a/OndselSolver/DistxyIeqcJec.cpp +++ b/OndselSolver/DistxyIeqcJec.cpp @@ -28,7 +28,7 @@ void MbD::DistxyIeqcJec::calc_ppdistxypEIpEI() auto pypEI = yIeJeIe->pvaluepEI(); auto ppxpEIpEI = xIeJeIe->ppvaluepEIpEI(); auto ppypEIpEI = yIeJeIe->ppvaluepEIpEI(); - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto& ppdistxypEIpEIi = ppdistxypEIpEI->at(i); auto& pdistxypEIi = pdistxypEI->at(i); @@ -36,7 +36,7 @@ void MbD::DistxyIeqcJec::calc_ppdistxypEIpEI() auto& ppypEIpEIi = ppypEIpEI->at(i); auto& pxpEIi = pxpEI->at(i); auto& pypEIi = pypEI->at(i); - for (int j = i; j < 4; j++) + for (size_t j = i; j < 4; j++) { auto pdistxypEIj = pdistxypEI->at(j); auto pxpEIj = pxpEI->at(j); @@ -61,7 +61,7 @@ void MbD::DistxyIeqcJec::calc_ppdistxypXIpEI() auto pypEI = yIeJeIe->pvaluepEI(); auto ppxpXIpEI = xIeJeIe->ppvaluepXIpEI(); auto ppypXIpEI = yIeJeIe->ppvaluepXIpEI(); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto& ppdistxypXIpEIi = ppdistxypXIpEI->at(i); auto& pdistxypXIi = pdistxypXI->at(i); @@ -69,7 +69,7 @@ void MbD::DistxyIeqcJec::calc_ppdistxypXIpEI() auto& ppypXIpEIi = ppypXIpEI->at(i); auto& pxpXIi = pxpXI->at(i); auto& pypXIi = pypXI->at(i); - for (int j = 0; j < 4; j++) + for (size_t j = 0; j < 4; j++) { auto& pdistxypEIj = pdistxypEI->at(j); auto& pxpEIj = pxpEI->at(j); @@ -91,7 +91,7 @@ void MbD::DistxyIeqcJec::calc_ppdistxypXIpXI() auto pypXI = yIeJeIe->pvaluepXI(); auto ppxpXIpXI = xIeJeIe->ppvaluepXIpXI(); auto ppypXIpXI = yIeJeIe->ppvaluepXIpXI(); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto& ppdistxypXIpXIi = ppdistxypXIpXI->at(i); auto& pdistxypXIi = pdistxypXI->at(i); @@ -99,7 +99,7 @@ void MbD::DistxyIeqcJec::calc_ppdistxypXIpXI() auto& ppypXIpXIi = ppypXIpXI->at(i); auto& pxpXIi = pxpXI->at(i); auto& pypXIi = pypXI->at(i); - for (int j = i; j < 3; j++) + for (size_t j = i; j < 3; j++) { auto pdistxypXIj = pdistxypXI->at(j); auto pxpXIj = pxpXI->at(j); @@ -120,7 +120,7 @@ void MbD::DistxyIeqcJec::calc_pdistxypEI() auto y = yIeJeIe->value(); auto pxpEI = xIeJeIe->pvaluepEI(); auto pypEI = yIeJeIe->pvaluepEI(); - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto term = pxpEI->at(i) * x + pypEI->at(i) * y; pdistxypEI->atiput(i, term / distxy); @@ -133,7 +133,7 @@ void MbD::DistxyIeqcJec::calc_pdistxypXI() auto y = yIeJeIe->value(); auto pxpXI = xIeJeIe->pvaluepXI(); auto pypXI = yIeJeIe->pvaluepXI(); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto term = pxpXI->at(i) * x + pypXI->at(i) * y; pdistxypXI->atiput(i, term / distxy); diff --git a/OndselSolver/DistxyIeqcJeqc.cpp b/OndselSolver/DistxyIeqcJeqc.cpp index 92140ff..dcbaa66 100644 --- a/OndselSolver/DistxyIeqcJeqc.cpp +++ b/OndselSolver/DistxyIeqcJeqc.cpp @@ -30,7 +30,7 @@ void MbD::DistxyIeqcJeqc::calc_ppdistxypEIpEJ() auto pypEJ = yIeJeIe->pvaluepEJ(); auto ppxpEIpEJ = xIeJeIe->ppvaluepEIpEJ(); auto ppypEIpEJ = yIeJeIe->ppvaluepEIpEJ(); - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto& ppdistxypEIpEJi = ppdistxypEIpEJ->at(i); auto& pdistxypEIi = pdistxypEI->at(i); @@ -38,7 +38,7 @@ void MbD::DistxyIeqcJeqc::calc_ppdistxypEIpEJ() auto& ppypEIpEJi = ppypEIpEJ->at(i); auto& pxpEIi = pxpEI->at(i); auto& pypEIi = pypEI->at(i); - for (int j = 0; j < 4; j++) + for (size_t j = 0; j < 4; j++) { auto& pdistxypEJj = pdistxypEJ->at(j); auto& pxpEJj = pxpEJ->at(j); @@ -62,7 +62,7 @@ void MbD::DistxyIeqcJeqc::calc_ppdistxypEIpXJ() auto pypXJ = yIeJeIe->pvaluepXJ(); auto ppxpEIpXJ = xIeJeIe->ppvaluepEIpXJ(); auto ppypEIpXJ = yIeJeIe->ppvaluepEIpXJ(); - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto& ppdistxypEIpXJi = ppdistxypEIpXJ->at(i); auto& pdistxypEIi = pdistxypEI->at(i); @@ -70,7 +70,7 @@ void MbD::DistxyIeqcJeqc::calc_ppdistxypEIpXJ() auto& ppypEIpXJi = ppypEIpXJ->at(i); auto& pxpEIi = pxpEI->at(i); auto& pypEIi = pypEI->at(i); - for (int j = 0; j < 3; j++) + for (size_t j = 0; j < 3; j++) { auto& pdistxypXJj = pdistxypXJ->at(j); auto& pxpXJj = pxpXJ->at(j); @@ -92,7 +92,7 @@ void MbD::DistxyIeqcJeqc::calc_ppdistxypEJpEJ() auto pypEJ = yIeJeIe->pvaluepEJ(); auto ppxpEJpEJ = xIeJeIe->ppvaluepEJpEJ(); auto ppypEJpEJ = yIeJeIe->ppvaluepEJpEJ(); - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto& ppdistxypEJpEJi = ppdistxypEJpEJ->at(i); auto& pdistxypEJi = pdistxypEJ->at(i); @@ -100,7 +100,7 @@ void MbD::DistxyIeqcJeqc::calc_ppdistxypEJpEJ() auto& ppypEJpEJi = ppypEJpEJ->at(i); auto& pxpEJi = pxpEJ->at(i); auto& pypEJi = pypEJ->at(i); - for (int j = i; j < 4; j++) + for (size_t j = i; j < 4; j++) { auto& pdistxypEJj = pdistxypEJ->at(j); auto& pxpEJj = pxpEJ->at(j); @@ -125,7 +125,7 @@ void MbD::DistxyIeqcJeqc::calc_ppdistxypXIpEJ() auto pypEJ = yIeJeIe->pvaluepEJ(); auto ppxpXIpEJ = xIeJeIe->ppvaluepXIpEJ(); auto ppypXIpEJ = yIeJeIe->ppvaluepXIpEJ(); - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto& ppdistxypXIpEJi = ppdistxypXIpEJ->at(i); auto& pdistxypXIi = pdistxypXI->at(i); @@ -133,7 +133,7 @@ void MbD::DistxyIeqcJeqc::calc_ppdistxypXIpEJ() auto& ppypXIpEJi = ppypXIpEJ->at(i); auto& pxpXIi = pxpXI->at(i); auto& pypXIi = pypXI->at(i); - for (int j = 0; j < 4; j++) + for (size_t j = 0; j < 4; j++) { auto& pdistxypEJj = pdistxypEJ->at(j); auto& pxpEJj = pxpEJ->at(j); @@ -157,7 +157,7 @@ void MbD::DistxyIeqcJeqc::calc_ppdistxypXIpXJ() auto pypXJ = yIeJeIe->pvaluepXJ(); auto ppxpXIpXJ = xIeJeIe->ppvaluepXIpXJ(); auto ppypXIpXJ = yIeJeIe->ppvaluepXIpXJ(); - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto& ppdistxypXIpXJi = ppdistxypXIpXJ->at(i); auto& pdistxypXIi = pdistxypXI->at(i); @@ -165,7 +165,7 @@ void MbD::DistxyIeqcJeqc::calc_ppdistxypXIpXJ() auto& ppypXIpXJi = ppypXIpXJ->at(i); auto& pxpXIi = pxpXI->at(i); auto& pypXIi = pypXI->at(i); - for (int j = 0; j < 4; j++) + for (size_t j = 0; j < 4; j++) { auto& pdistxypXJj = pdistxypXJ->at(j); auto& pxpXJj = pxpXJ->at(j); @@ -189,7 +189,7 @@ void MbD::DistxyIeqcJeqc::calc_ppdistxypXJpEJ() auto pypEJ = yIeJeIe->pvaluepEJ(); auto ppxpXJpEJ = xIeJeIe->ppvaluepXJpEJ(); auto ppypXJpEJ = yIeJeIe->ppvaluepXJpEJ(); - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto& ppdistxypXJpEJi = ppdistxypXJpEJ->at(i); auto& pdistxypXJi = pdistxypXJ->at(i); @@ -197,7 +197,7 @@ void MbD::DistxyIeqcJeqc::calc_ppdistxypXJpEJ() auto& ppypXJpEJi = ppypXJpEJ->at(i); auto& pxpXJi = pxpXJ->at(i); auto& pypXJi = pypXJ->at(i); - for (int j = 0; j < 4; j++) + for (size_t j = 0; j < 4; j++) { auto& pdistxypEJj = pdistxypEJ->at(j); auto& pxpEJj = pxpEJ->at(j); @@ -219,7 +219,7 @@ void MbD::DistxyIeqcJeqc::calc_ppdistxypXJpXJ() auto pypXJ = yIeJeIe->pvaluepXJ(); auto ppxpXJpXJ = xIeJeIe->ppvaluepXJpXJ(); auto ppypXJpXJ = yIeJeIe->ppvaluepXJpXJ(); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto& ppdistxypXJpXJi = ppdistxypXJpXJ->at(i); auto& pdistxypXJi = pdistxypXJ->at(i); @@ -227,7 +227,7 @@ void MbD::DistxyIeqcJeqc::calc_ppdistxypXJpXJ() auto& ppypXJpXJi = ppypXJpXJ->at(i); auto& pxpXJi = pxpXJ->at(i); auto& pypXJi = pypXJ->at(i); - for (int j = i; j < 3; j++) + for (size_t j = i; j < 3; j++) { auto& pdistxypXJj = pdistxypXJ->at(j); auto& pxpXJj = pxpXJ->at(j); @@ -248,7 +248,7 @@ void MbD::DistxyIeqcJeqc::calc_pdistxypEJ() auto y = yIeJeIe->value(); auto pxpEJ = xIeJeIe->pvaluepEJ(); auto pypEJ = yIeJeIe->pvaluepEJ(); - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto term = pxpEJ->at(i) * x + pypEJ->at(i) * y; pdistxypEJ->atiput(i, term / distxy); @@ -261,7 +261,7 @@ void MbD::DistxyIeqcJeqc::calc_pdistxypXJ() auto y = yIeJeIe->value(); auto pxpXJ = xIeJeIe->pvaluepXJ(); auto pypXJ = yIeJeIe->pvaluepXJ(); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto term = pxpXJ->at(i) * x + pypXJ->at(i) * y; pdistxypXJ->atiput(i, term / distxy); diff --git a/OndselSolver/EndFramec.cpp b/OndselSolver/EndFramec.cpp index 208039f..cde2b42 100644 --- a/OndselSolver/EndFramec.cpp +++ b/OndselSolver/EndFramec.cpp @@ -66,12 +66,12 @@ void EndFramec::calcPostDynCorrectorIteration() aAOe = markerFrame->aAOm; } -FColDsptr EndFramec::aAjOe(int j) +FColDsptr EndFramec::aAjOe(size_t j) { return aAOe->column(j); } -double EndFramec::riOeO(int i) +double EndFramec::riOeO(size_t i) { return rOeO->at(i); } diff --git a/OndselSolver/EndFramec.h b/OndselSolver/EndFramec.h index d370048..740150a 100644 --- a/OndselSolver/EndFramec.h +++ b/OndselSolver/EndFramec.h @@ -34,8 +34,8 @@ namespace MbD { virtual void initEndFrameqct(); virtual void initEndFrameqct2(); void calcPostDynCorrectorIteration() override; - FColDsptr aAjOe(int j); - double riOeO(int i); + FColDsptr aAjOe(size_t j); + double riOeO(size_t i); virtual FColDsptr rmeO(); virtual FColDsptr rpep(); virtual FColFMatDsptr pAOppE(); diff --git a/OndselSolver/EndFrameqc.cpp b/OndselSolver/EndFrameqc.cpp index f938f12..27f79a8 100644 --- a/OndselSolver/EndFrameqc.cpp +++ b/OndselSolver/EndFrameqc.cpp @@ -57,13 +57,13 @@ void MbD::EndFrameqc::initEndFrameqct2() endFrameqct->setMarkerFrame(markerFrame); } -FMatFColDsptr EndFrameqc::ppAjOepEpE(int jj) +FMatFColDsptr EndFrameqc::ppAjOepEpE(size_t jj) { auto answer = std::make_shared>(4, 4); - for (int i = 0; i < 4; i++) { + for (size_t i = 0; i < 4; i++) { auto& answeri = answer->at(i); auto& ppAOepEipE = ppAOepEpE->at(i); - for (int j = i; j < 4; j++) { + for (size_t j = i; j < 4; j++) { answeri->at(j) = ppAOepEipE->at(j)->column(jj); } } @@ -78,13 +78,13 @@ void EndFrameqc::calcPostDynCorrectorIteration() pAOepE = markerFrame->pAOmpE; } -FMatDsptr EndFrameqc::pAjOepET(int axis) +FMatDsptr EndFrameqc::pAjOepET(size_t axis) { auto answer = std::make_shared>(4, 3); - for (int i = 0; i < 4; i++) { + for (size_t i = 0; i < 4; i++) { auto& answeri = answer->at(i); auto& pAOepEi = pAOepE->at(i); - for (int j = 0; j < 3; j++) { + for (size_t j = 0; j < 3; j++) { auto& answerij = pAOepEi->at(j)->at(axis); answeri->at(j) = answerij; } @@ -92,13 +92,13 @@ FMatDsptr EndFrameqc::pAjOepET(int axis) return answer; } -FMatDsptr EndFrameqc::ppriOeOpEpE(int ii) +FMatDsptr EndFrameqc::ppriOeOpEpE(size_t ii) { auto answer = std::make_shared>(4, 4); - for (int i = 0; i < 4; i++) { + for (size_t i = 0; i < 4; i++) { auto& answeri = answer->at(i); auto& pprOeOpEipE = pprOeOpEpE->at(i); - for (int j = 0; j < 4; j++) { + for (size_t j = 0; j < 4; j++) { auto& answerij = pprOeOpEipE->at(j)->at(ii); answeri->at(j) = answerij; } @@ -106,17 +106,17 @@ FMatDsptr EndFrameqc::ppriOeOpEpE(int ii) return answer; } -int EndFrameqc::iqX() +size_t EndFrameqc::iqX() { return markerFrame->iqX(); } -int EndFrameqc::iqE() +size_t EndFrameqc::iqE() { return markerFrame->iqE(); } -FRowDsptr EndFrameqc::priOeOpE(int i) +FRowDsptr EndFrameqc::priOeOpE(size_t i) { return prOeOpE->at(i); } diff --git a/OndselSolver/EndFrameqc.h b/OndselSolver/EndFrameqc.h index c85ad8d..8447102 100644 --- a/OndselSolver/EndFrameqc.h +++ b/OndselSolver/EndFrameqc.h @@ -26,13 +26,13 @@ namespace MbD { void initializeGlobally() override; void initEndFrameqct() override; void initEndFrameqct2() override; - FMatFColDsptr ppAjOepEpE(int j); + FMatFColDsptr ppAjOepEpE(size_t j); void calcPostDynCorrectorIteration() override; - FMatDsptr pAjOepET(int j); - FMatDsptr ppriOeOpEpE(int i); - int iqX(); - int iqE(); - FRowDsptr priOeOpE(int i); + FMatDsptr pAjOepET(size_t j); + FMatDsptr ppriOeOpEpE(size_t i); + size_t iqX(); + size_t iqE(); + FRowDsptr priOeOpE(size_t i); FColDsptr qXdot(); std::shared_ptr> qEdot(); FColDsptr qXddot(); diff --git a/OndselSolver/EndFrameqct.cpp b/OndselSolver/EndFrameqct.cpp index efd7b34..23336aa 100644 --- a/OndselSolver/EndFrameqct.cpp +++ b/OndselSolver/EndFrameqct.cpp @@ -70,7 +70,7 @@ void EndFrameqct::initprmemptBlks() { auto& mbdTime = this->root()->time; prmemptBlks = std::make_shared< FullColumn>(3); - for (int i = 0; i < 3; i++) { + for (size_t i = 0; i < 3; i++) { auto& disp = rmemBlks->at(i); auto var = disp->differentiateWRT(mbdTime); auto vel = var->simplified(var); @@ -82,7 +82,7 @@ void EndFrameqct::initpprmemptptBlks() { auto& mbdTime = this->root()->time; pprmemptptBlks = std::make_shared< FullColumn>(3); - for (int i = 0; i < 3; i++) { + for (size_t i = 0; i < 3; i++) { auto& vel = prmemptBlks->at(i); auto var = vel->differentiateWRT(mbdTime); auto acc = var->simplified(var); @@ -94,7 +94,7 @@ void EndFrameqct::initpPhiThePsiptBlks() { auto& mbdTime = this->root()->time; pPhiThePsiptBlks = std::make_shared< FullColumn>(3); - for (int i = 0; i < 3; i++) { + for (size_t i = 0; i < 3; i++) { auto& angle = phiThePsiBlks->at(i); auto var = angle->differentiateWRT(mbdTime); //std::cout << "var " << *var << std::endl; @@ -108,7 +108,7 @@ void EndFrameqct::initppPhiThePsiptptBlks() { auto& mbdTime = this->root()->time; ppPhiThePsiptptBlks = std::make_shared< FullColumn>(3); - for (int i = 0; i < 3; i++) { + for (size_t i = 0; i < 3; i++) { auto& angleVel = pPhiThePsiptBlks->at(i); auto var = angleVel->differentiateWRT(mbdTime); auto angleAcc = var->simplified(var); @@ -130,11 +130,11 @@ void EndFrameqct::calcPostDynCorrectorIteration() rOeO = rOmO->plusFullColumn(aAOm->timesFullColumn(rmem)); auto& prOmOpE = markerFrame->prOmOpE; auto& pAOmpE = markerFrame->pAOmpE; - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto& prOmOpEi = prOmOpE->at(i); auto& prOeOpEi = prOeOpE->at(i); - for (int j = 0; j < 4; j++) + for (size_t j = 0; j < 4; j++) { auto prOeOpEij = prOmOpEi->at(j) + pAOmpE->at(j)->at(i)->timesFullColumn(rmem); prOeOpEi->at(j) = prOeOpEij; @@ -143,7 +143,7 @@ void EndFrameqct::calcPostDynCorrectorIteration() auto rpep = markerFrame->rpmp->plusFullColumn(markerFrame->aApm->timesFullColumn(rmem)); pprOeOpEpE = EulerParameters::ppApEpEtimesColumn(rpep); aAOe = aAOm->timesFullMatrix(aAme); - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { pAOepE->at(i) = pAOmpE->at(i)->timesFullMatrix(aAme); } @@ -162,7 +162,7 @@ void EndFrameqct::prePosIC() void EndFrameqct::evalrmem() { if (rmemBlks) { - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto& expression = rmemBlks->at(i); double value = expression->getValue(); @@ -175,7 +175,7 @@ void EndFrameqct::evalAme() { if (phiThePsiBlks) { auto phiThePsi = CREATE>::With(); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto& expression = phiThePsiBlks->at(i); auto value = expression->getValue(); @@ -202,34 +202,34 @@ void EndFrameqct::preVelIC() void EndFrameqct::postVelIC() { auto& pAOmpE = markerFrame->pAOmpE; - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto& pprOeOpEpti = pprOeOpEpt->at(i); - for (int j = 0; j < 4; j++) + for (size_t j = 0; j < 4; j++) { auto pprOeOpEptij = pAOmpE->at(j)->at(i)->dot(prmempt); pprOeOpEpti->atiput(j, pprOeOpEptij); } } - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { ppAOepEpt->atiput(i, pAOmpE->at(i)->timesFullMatrix(pAmept)); } } -FColDsptr EndFrameqct::pAjOept(int j) +FColDsptr EndFrameqct::pAjOept(size_t j) { return pAOept->column(j); } -FMatDsptr EndFrameqct::ppAjOepETpt(int jj) +FMatDsptr EndFrameqct::ppAjOepETpt(size_t jj) { auto answer = std::make_shared>(4, 3); - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto& answeri = answer->at(i); auto& ppAOepEipt = ppAOepEpt->at(i); - for (int j = 0; j < 3; j++) + for (size_t j = 0; j < 3; j++) { auto& answerij = ppAOepEipt->at(j)->at(jj); answeri->atiput(j, answerij); @@ -238,22 +238,22 @@ FMatDsptr EndFrameqct::ppAjOepETpt(int jj) return answer; } -FColDsptr EndFrameqct::ppAjOeptpt(int j) +FColDsptr EndFrameqct::ppAjOeptpt(size_t j) { return ppAOeptpt->column(j); } -double EndFrameqct::priOeOpt(int i) +double EndFrameqct::priOeOpt(size_t i) { return prOeOpt->at(i); } -FRowDsptr EndFrameqct::ppriOeOpEpt(int i) +FRowDsptr EndFrameqct::ppriOeOpEpt(size_t i) { return pprOeOpEpt->at(i); } -double EndFrameqct::ppriOeOptpt(int i) +double EndFrameqct::ppriOeOptpt(size_t i) { return pprOeOptpt->at(i); } @@ -261,7 +261,7 @@ double EndFrameqct::ppriOeOptpt(int i) void EndFrameqct::evalprmempt() { if (rmemBlks) { - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto& derivative = prmemptBlks->at(i); auto value = derivative->getValue(); @@ -276,7 +276,7 @@ void EndFrameqct::evalpAmept() auto phiThePsi = CREATE>::With(); auto phiThePsiDot = CREATE>::With(); phiThePsiDot->phiThePsi = phiThePsi; - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto& expression = phiThePsiBlks->at(i); auto& derivative = pPhiThePsiptBlks->at(i); @@ -294,7 +294,7 @@ void EndFrameqct::evalpAmept() void EndFrameqct::evalpprmemptpt() { if (rmemBlks) { - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto& secondDerivative = pprmemptptBlks->at(i); auto value = secondDerivative->getValue(); @@ -311,7 +311,7 @@ void EndFrameqct::evalppAmeptpt() phiThePsiDot->phiThePsi = phiThePsi; auto phiThePsiDDot = CREATE>::With(); phiThePsiDDot->phiThePsiDot = phiThePsiDot; - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto& expression = phiThePsiBlks->at(i); auto& derivative = pPhiThePsiptBlks->at(i); diff --git a/OndselSolver/EndFrameqct.h b/OndselSolver/EndFrameqct.h index 98966ab..415069e 100644 --- a/OndselSolver/EndFrameqct.h +++ b/OndselSolver/EndFrameqct.h @@ -36,13 +36,13 @@ namespace MbD { virtual void evalAme(); void preVelIC() override; void postVelIC() override; - FColDsptr pAjOept(int j); - FMatDsptr ppAjOepETpt(int j); - FColDsptr ppAjOeptpt(int j); + FColDsptr pAjOept(size_t j); + FMatDsptr ppAjOepETpt(size_t j); + FColDsptr ppAjOeptpt(size_t j); double time = 0.0; - double priOeOpt(int i); - FRowDsptr ppriOeOpEpt(int i); - double ppriOeOptpt(int i); + double priOeOpt(size_t i); + FRowDsptr ppriOeOpEpt(size_t i); + double ppriOeOptpt(size_t i); void evalprmempt(); virtual void evalpAmept(); void evalpprmemptpt(); diff --git a/OndselSolver/EulerAngles.h b/OndselSolver/EulerAngles.h index 65e05b4..abc6c38 100644 --- a/OndselSolver/EulerAngles.h +++ b/OndselSolver/EulerAngles.h @@ -30,9 +30,9 @@ namespace MbD { void initialize() override; void calc() override; std::shared_ptr> differentiateWRT(T var); - void setRotOrder(int i, int j, int k); + void setRotOrder(size_t i, size_t j, size_t k); - std::shared_ptr> rotOrder; + std::shared_ptr> rotOrder; FColFMatDsptr cA; FMatDsptr aA; @@ -46,7 +46,7 @@ namespace MbD { inline void EulerAngles::calc() { cA = std::make_shared>(3); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto axis = rotOrder->at(i); auto angle = this->at(i)->getValue(); @@ -69,7 +69,7 @@ namespace MbD { inline void EulerAngles::calc() { cA = std::make_shared>(3); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto axis = rotOrder->at(i); auto angle = this->at(i); @@ -104,9 +104,9 @@ namespace MbD { return derivatives; } template - inline void EulerAngles::setRotOrder(int i, int j, int k) + inline void EulerAngles::setRotOrder(size_t i, size_t j, size_t k) { - rotOrder = std::make_shared>(3); + rotOrder = std::make_shared>(3); rotOrder->at(0) = i; rotOrder->at(1) = j; rotOrder->at(2) = k; diff --git a/OndselSolver/EulerAnglesDDot.h b/OndselSolver/EulerAnglesDDot.h index 43f47be..b413525 100644 --- a/OndselSolver/EulerAnglesDDot.h +++ b/OndselSolver/EulerAnglesDDot.h @@ -40,7 +40,7 @@ namespace MbD { auto cA = aEulerAngles->cA; auto cAdot = aEulerAnglesDot->cAdot; cAddot = std::make_shared>(3); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto axis = rotOrder->at(i); auto angle = aEulerAngles->at(i)->getValue(); diff --git a/OndselSolver/EulerAnglesDot.h b/OndselSolver/EulerAnglesDot.h index 23a18cd..54f1f58 100644 --- a/OndselSolver/EulerAnglesDot.h +++ b/OndselSolver/EulerAnglesDot.h @@ -50,7 +50,7 @@ namespace MbD { auto& rotOrder = aEulerAngles->rotOrder; auto& cA = aEulerAngles->cA; cAdot = std::make_shared>(3); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto axis = rotOrder->at(i); auto angle = aEulerAngles->at(i)->getValue(); diff --git a/OndselSolver/EulerAngleszxz.h b/OndselSolver/EulerAngleszxz.h index 6bacdef..5a304eb 100644 --- a/OndselSolver/EulerAngleszxz.h +++ b/OndselSolver/EulerAngleszxz.h @@ -24,7 +24,8 @@ namespace MbD { void initialize() override; void calc() override; - FMatDsptr phiA, theA, psiA, aA; + //FMatDsptr phiA; + FMatsptr phiA, theA, psiA, aA; }; template inline void EulerAngleszxz::initialize() diff --git a/OndselSolver/EulerArray.h b/OndselSolver/EulerArray.h index 3225e9c..099a39f 100644 --- a/OndselSolver/EulerArray.h +++ b/OndselSolver/EulerArray.h @@ -22,7 +22,7 @@ namespace MbD { EulerArray(std::initializer_list list) : FullColumn{ list } {} void initialize() override; void equalFullColumn(FColsptr fullCol); - void equalFullColumnAt(FColsptr fullCol, int i); + void equalFullColumnAt(FColsptr fullCol, size_t i); virtual void calc() = 0; }; @@ -36,7 +36,7 @@ namespace MbD { this->equalArrayAt(fullCol, 0); } template - inline void EulerArray::equalFullColumnAt(FColsptr fullCol, int i) + inline void EulerArray::equalFullColumnAt(FColsptr fullCol, size_t i) { this->equalArrayAt(fullCol, i); } diff --git a/OndselSolver/EulerConstraint.cpp b/OndselSolver/EulerConstraint.cpp index 7e255c1..bce236b 100644 --- a/OndselSolver/EulerConstraint.cpp +++ b/OndselSolver/EulerConstraint.cpp @@ -31,7 +31,7 @@ void EulerConstraint::calcPostDynCorrectorIteration() { auto& qE = static_cast(owner)->qE; aG = qE->sumOfSquares() - 1.0; - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { pGpE->at(i) = 2.0 * qE->at(i); } @@ -54,7 +54,7 @@ void EulerConstraint::fillPosICJacob(SpMatDsptr mat) mat->atijplusFullRow(iG, iqE, pGpE); mat->atijplusFullColumn(iqE, iG, pGpE->transpose()); auto twolam = 2.0 * lam; - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto ii = iqE + i; mat->atijplusNumber(ii, ii, twolam); diff --git a/OndselSolver/EulerConstraint.h b/OndselSolver/EulerConstraint.h index e9685e9..c71a021 100644 --- a/OndselSolver/EulerConstraint.h +++ b/OndselSolver/EulerConstraint.h @@ -31,7 +31,7 @@ namespace MbD { void fillAccICIterError(FColDsptr col) override; FRowDsptr pGpE; //partial derivative of G wrt pE - int iqE = -1; + size_t iqE = SIZE_MAX; }; } diff --git a/OndselSolver/EulerParameters.h b/OndselSolver/EulerParameters.h index c9a1ba9..04693dd 100644 --- a/OndselSolver/EulerParameters.h +++ b/OndselSolver/EulerParameters.h @@ -216,7 +216,7 @@ namespace MbD { aB = std::make_shared>(3, 4); aC = std::make_shared>(3, 4); pApE = std::make_shared>(4); - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { pApE->at(i) = std::make_shared>(3, 3); } diff --git a/OndselSolver/EulerParametersDot.h b/OndselSolver/EulerParametersDot.h index 1224612..2d558cd 100644 --- a/OndselSolver/EulerParametersDot.h +++ b/OndselSolver/EulerParametersDot.h @@ -59,7 +59,7 @@ namespace MbD { aBdot = std::make_shared>(3, 4); aCdot = std::make_shared>(3, 4); pAdotpE = std::make_shared>(4); - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { pAdotpE->at(i) = std::make_shared>(3, 3); } diff --git a/OndselSolver/FullColumn.h b/OndselSolver/FullColumn.h index 630f8d9..936968d 100644 --- a/OndselSolver/FullColumn.h +++ b/OndselSolver/FullColumn.h @@ -39,14 +39,14 @@ namespace MbD { FColsptr minusFullColumn(FColsptr fullCol); FColsptr times(T a); FColsptr negated(); - void atiputFullColumn(int i, FColsptr fullCol); - void atiplusFullColumn(int i, FColsptr fullCol); - void equalSelfPlusFullColumnAt(FColsptr fullCol, int i); - void atiminusFullColumn(int i, FColsptr fullCol); - void equalFullColumnAt(FColsptr fullCol, int i); + void atiputFullColumn(size_t i, FColsptr fullCol); + void atiplusFullColumn(size_t i, FColsptr fullCol); + void equalSelfPlusFullColumnAt(FColsptr fullCol, size_t i); + void atiminusFullColumn(size_t i, FColsptr fullCol); + void equalFullColumnAt(FColsptr fullCol, size_t i); FColsptr copy(); FRowsptr transpose(); - void atiplusFullColumntimes(int i, FColsptr fullCol, T factor); + void atiplusFullColumntimes(size_t i, FColsptr fullCol, T factor); T transposeTimesFullColumn(const FColsptr fullCol); void equalSelfPlusFullColumntimes(FColsptr fullCol, T factor); FColsptr cross(FColsptr fullCol); @@ -59,9 +59,9 @@ namespace MbD { template inline FColsptr FullColumn::plusFullColumn(FColsptr fullCol) { - int n = (int) this->size(); + auto n = this->size(); auto answer = std::make_shared>(n); - for (int i = 0; i < n; i++) { + for (size_t i = 0; i < n; i++) { answer->at(i) = this->at(i) + fullCol->at(i); } return answer; @@ -69,9 +69,9 @@ namespace MbD { template inline FColsptr FullColumn::minusFullColumn(FColsptr fullCol) { - int n = (int) this->size(); + auto n = this->size(); auto answer = std::make_shared>(n); - for (int i = 0; i < n; i++) { + for (size_t i = 0; i < n; i++) { answer->at(i) = this->at(i) - fullCol->at(i); } return answer; @@ -79,9 +79,9 @@ namespace MbD { template<> inline FColDsptr FullColumn::times(double a) { - int n = (int)this->size(); + auto n = this->size(); auto answer = std::make_shared>(n); - for (int i = 0; i < n; i++) { + for (size_t i = 0; i < n; i++) { answer->at(i) = this->at(i) * a; } return answer; @@ -97,44 +97,44 @@ namespace MbD { return this->times(-1.0); } template - inline void FullColumn::atiputFullColumn(int i, FColsptr fullCol) + inline void FullColumn::atiputFullColumn(size_t i, FColsptr fullCol) { - for (int ii = 0; ii < (int)fullCol->size(); ii++) + for (size_t ii = 0; ii < fullCol->size(); ii++) { this->at(i + ii) = fullCol->at(ii); } } template - inline void FullColumn::atiplusFullColumn(int i, FColsptr fullCol) + inline void FullColumn::atiplusFullColumn(size_t i, FColsptr fullCol) { - for (int ii = 0; ii < (int)fullCol->size(); ii++) + for (size_t ii = 0; ii < fullCol->size(); ii++) { this->at(i + ii) += fullCol->at(ii); } } template - inline void FullColumn::equalSelfPlusFullColumnAt(FColsptr fullCol, int ii) + inline void FullColumn::equalSelfPlusFullColumnAt(FColsptr fullCol, size_t ii) { //self is subcolumn of fullCol - for (int i = 0; i < (int)this->size(); i++) + for (size_t i = 0; i < this->size(); i++) { this->at(i) += fullCol->at(ii + i); } } template - inline void FullColumn::atiminusFullColumn(int i1, FColsptr fullCol) + inline void FullColumn::atiminusFullColumn(size_t i1, FColsptr fullCol) { - for (int ii = 0; ii < (int)fullCol->size(); ii++) + for (size_t ii = 0; ii < fullCol->size(); ii++) { - int i = i1 + ii; + size_t i = i1 + ii; this->at(i) -= fullCol->at(ii); } } template - inline void FullColumn::equalFullColumnAt(FColsptr fullCol, int i) + inline void FullColumn::equalFullColumnAt(FColsptr fullCol, size_t 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); //} @@ -142,9 +142,9 @@ namespace MbD { template<> inline FColDsptr FullColumn::copy() { - auto n = (int) this->size(); + auto n = this->size(); auto answer = std::make_shared>(n); - for (int i = 0; i < n; i++) + for (size_t i = 0; i < n; i++) { answer->at(i) = this->at(i); } @@ -156,11 +156,11 @@ namespace MbD { return std::make_shared>(*this); } template - inline void FullColumn::atiplusFullColumntimes(int i1, FColsptr fullCol, T factor) + inline void FullColumn::atiplusFullColumntimes(size_t i1, FColsptr fullCol, T factor) { - for (int ii = 0; ii < (int)fullCol->size(); ii++) + for (size_t ii = 0; ii < fullCol->size(); ii++) { - int i = i1 + ii; + size_t i = i1 + ii; this->at(i) += fullCol->at(ii) * factor; } } @@ -194,7 +194,7 @@ namespace MbD { //{ // auto n = this->size(); // auto answer = std::make_shared>(n); - // for (int i = 0; i < n; i++) + // for (size_t i = 0; i < n; i++) // { // auto func = this->at(i); // answer->at(i) = func->simplified(func); @@ -210,9 +210,9 @@ namespace MbD { template inline double FullColumn::dot(std::shared_ptr> vec) { - int n = (int)this->size(); + auto n = this->size(); double answer = 0.0; - for (int i = 0; i < n; i++) { + for (size_t i = 0; i < n; i++) { answer += this->at(i) * vec->at(i); } return answer; @@ -220,12 +220,12 @@ namespace MbD { template inline std::shared_ptr> FullColumn::dot(std::shared_ptr>>> vecvec) { - int ncol = (int)this->size(); + auto ncol = this->size(); auto nelem = vecvec->at(0)->size(); auto answer = std::make_shared>(nelem); - for (int k = 0; k < nelem; k++) { + for (size_t k = 0; k < nelem; k++) { auto sum = 0.0; - for (int i = 0; i < ncol; i++) + for (size_t i = 0; i < ncol; i++) { sum += this->at(i) * vecvec->at(i)->at(k); } @@ -238,7 +238,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.h b/OndselSolver/FullMatrix.h index 958e2ab..693f92b 100644 --- a/OndselSolver/FullMatrix.h +++ b/OndselSolver/FullMatrix.h @@ -29,6 +29,8 @@ namespace MbD { template class EulerParameters; template + class EulerAngleszxz; + template class DiagonalMatrix; using FMatFColDsptr = std::shared_ptr>; @@ -40,11 +42,11 @@ namespace MbD { { public: FullMatrix() {} - FullMatrix(int m) : RowTypeMatrix>(m) + FullMatrix(size_t m) : RowTypeMatrix>(m) { } - FullMatrix(int m, int n) { - for (int i = 0; i < m; i++) { + FullMatrix(size_t m, size_t n) { + for (size_t i = 0; i < m; i++) { auto row = std::make_shared>(n); this->push_back(row); } @@ -71,10 +73,10 @@ namespace MbD { static FMatsptr rotatexrotDotrotDDot(T angle, T angleDot, T angleDDot); static FMatsptr rotateyrotDotrotDDot(T angle, T angleDot, T angleDDot); static FMatsptr rotatezrotDotrotDDot(T angle, T angleDot, T angleDDot); - static FMatsptr identitysptr(int n); + static FMatsptr identitysptr(size_t n); static FMatsptr tildeMatrix(FColDsptr col); void identity(); - FColsptr column(int j); + FColsptr column(size_t j); FColsptr timesFullColumn(FColsptr fullCol); FColsptr timesFullColumn(FullColumn* fullCol); FMatsptr timesFullMatrix(FMatsptr fullMat); @@ -86,12 +88,12 @@ namespace MbD { FMatsptr transpose(); FMatsptr negated(); void symLowerWithUpper(); - void atiput(int i, FRowsptr fullRow); - void atijput(int i, int j, T value); - void atijputFullColumn(int i, int j, FColsptr fullCol); - void atijplusFullRow(int i, int j, FRowsptr fullRow); - void atijplusNumber(int i, int j, T value); - void atijminusNumber(int i, int j, T value); + void atiput(size_t i, FRowsptr fullRow); + void atijput(size_t i, size_t j, T value); + void atijputFullColumn(size_t i, size_t j, FColsptr fullCol); + void atijplusFullRow(size_t i, size_t j, FRowsptr fullRow); + void atijplusNumber(size_t i, size_t j, T value); + void atijminusNumber(size_t i, size_t j, T value); double sumOfSquares() override; void zeroSelf() override; FMatsptr copy(); @@ -102,6 +104,7 @@ namespace MbD { T trace(); double maxMagnitude() override; FColsptr bryantAngles(); + std::shared_ptr> eulerAngleszxz(); bool isDiagonal(); bool isDiagonalToWithin(double ratio); bool equaltol(FMatsptr mat, double ratio); @@ -309,7 +312,7 @@ namespace MbD { return rotMat; } template - inline FMatsptr FullMatrix::identitysptr(int n) + inline FMatsptr FullMatrix::identitysptr(size_t n) { auto mat = std::make_shared>(n, n); mat->identity(); @@ -338,22 +341,22 @@ namespace MbD { template<> inline void FullMatrix::zeroSelf() { - for (int i = 0; i < (int)this->size(); i++) { + for (size_t i = 0; i < this->size(); i++) { this->at(i)->zeroSelf(); } } template<> inline void FullMatrix::identity() { this->zeroSelf(); - for (int i = 0; i < (int)this->size(); i++) { + for (size_t i = 0; i < this->size(); i++) { this->at(i)->at(i) = 1.0; } } template - inline FColsptr FullMatrix::column(int j) { - int n = (int)this->size(); + inline FColsptr FullMatrix::column(size_t j) { + auto n = this->size(); auto answer = std::make_shared>(n); - for (int i = 0; i < n; i++) { + for (size_t i = 0; i < n; i++) { answer->at(i) = this->at(i)->at(j); } return answer; @@ -361,9 +364,9 @@ namespace MbD { template inline FMatsptr FullMatrix::timesFullMatrix(FMatsptr fullMat) { - int m = this->nrow(); + size_t m = this->nrow(); auto answer = std::make_shared>(m); - for (int i = 0; i < m; i++) { + for (size_t i = 0; i < m; i++) { answer->at(i) = this->at(i)->timesFullMatrix(fullMat); } return answer; @@ -371,9 +374,9 @@ namespace MbD { template inline FMatsptr FullMatrix::timesTransposeFullMatrix(FMatsptr fullMat) { - int nrow = this->nrow(); + size_t nrow = this->nrow(); auto answer = std::make_shared>(nrow); - for (int i = 0; i < nrow; i++) { + for (size_t i = 0; i < nrow; i++) { answer->at(i) = this->at(i)->timesTransposeFullMatrix(fullMat); } return answer; @@ -381,9 +384,9 @@ namespace MbD { template<> inline FMatDsptr FullMatrix::times(double a) { - int m = this->nrow(); + size_t m = this->nrow(); auto answer = std::make_shared>(m); - for (int i = 0; i < m; i++) { + for (size_t i = 0; i < m; i++) { answer->at(i) = this->at(i)->times(a); } return answer; @@ -401,9 +404,9 @@ namespace MbD { template inline FMatsptr FullMatrix::plusFullMatrix(FMatsptr fullMat) { - int n = (int)this->size(); + auto n = this->size(); auto answer = std::make_shared>(n); - for (int i = 0; i < n; i++) { + for (size_t i = 0; i < n; i++) { answer->at(i) = this->at(i)->plusFullRow(fullMat->at(i)); } return answer; @@ -411,9 +414,9 @@ namespace MbD { template inline FMatsptr FullMatrix::minusFullMatrix(FMatsptr fullMat) { - int n = (int)this->size(); + auto n = this->size(); auto answer = std::make_shared>(n); - for (int i = 0; i < n; i++) { + for (size_t i = 0; i < n; i++) { answer->at(i) = this->at(i)->minusFullRow(fullMat->at(i)); } return answer; @@ -421,12 +424,12 @@ namespace MbD { template inline FMatsptr FullMatrix::transpose() { - int nrow = this->nrow(); + size_t nrow = this->nrow(); auto ncol = this->ncol(); auto answer = std::make_shared>(ncol, nrow); - for (int i = 0; i < nrow; i++) { + for (size_t i = 0; i < nrow; i++) { auto& row = this->at(i); - for (int j = 0; j < ncol; j++) { + for (size_t j = 0; j < ncol; j++) { answer->at(j)->at(i) = row->at(j); } } @@ -440,44 +443,44 @@ namespace MbD { template inline void FullMatrix::symLowerWithUpper() { - int n = (int)this->size(); - for (int i = 0; i < n; i++) { - for (int j = i + 1; j < n; j++) { + auto n = this->size(); + for (size_t i = 0; i < n; i++) { + for (size_t j = i + 1; j < n; j++) { this->at(j)->at(i) = this->at(i)->at(j); } } } template - inline void FullMatrix::atiput(int i, FRowsptr fullRow) + inline void FullMatrix::atiput(size_t i, FRowsptr fullRow) { this->at(i) = fullRow; } template - inline void FullMatrix::atijput(int i, int j, T value) + inline void FullMatrix::atijput(size_t i, size_t j, T value) { this->at(i)->atiput(j, value); } template - inline void FullMatrix::atijputFullColumn(int i1, int j1, FColsptr fullCol) + inline void FullMatrix::atijputFullColumn(size_t i1, size_t j1, FColsptr fullCol) { - for (int ii = 0; ii < (int)fullCol->size(); ii++) + for (size_t ii = 0; ii < fullCol->size(); ii++) { this->at(i1 + ii)->at(j1) = fullCol->at(ii); } } template - inline void FullMatrix::atijplusFullRow(int i, int j, FRowsptr fullRow) + inline void FullMatrix::atijplusFullRow(size_t i, size_t j, FRowsptr fullRow) { this->at(i)->atiplusFullRow(j, fullRow); } template - inline void FullMatrix::atijplusNumber(int i, int j, T value) + inline void FullMatrix::atijplusNumber(size_t i, size_t j, T value) { auto rowi = this->at(i); rowi->at(j) += value; } template - inline void FullMatrix::atijminusNumber(int i, int j, T value) + inline void FullMatrix::atijminusNumber(size_t i, size_t j, T value) { auto rowi = this->at(i); rowi->at(j) -= value; @@ -486,7 +489,7 @@ namespace MbD { inline double FullMatrix::sumOfSquares() { double sum = 0.0; - for (int i = 0; i < (int)this->size(); i++) + for (size_t i = 0; i < this->size(); i++) { sum += this->at(i)->sumOfSquares(); } @@ -506,9 +509,9 @@ namespace MbD { template inline FMatsptr FullMatrix::copy() { - auto m = (int)this->size(); + auto m = this->size(); auto answer = std::make_shared>(m); - for (int i = 0; i < m; i++) + for (size_t i = 0; i < m; i++) { answer->at(i) = this->at(i)->copy(); } @@ -517,9 +520,9 @@ namespace MbD { template inline FullMatrix FullMatrix::operator+(const FullMatrix fullMat) { - int n = (int)this->size(); + auto n = this->size(); auto answer = FullMatrix(n); - for (int i = 0; i < n; i++) { + for (size_t i = 0; i < n; i++) { answer.at(i) = this->at(i)->plusFullRow(fullMat.at(i)); } return answer; @@ -533,7 +536,7 @@ namespace MbD { template inline void FullMatrix::magnifySelf(T factor) { - for (int i = 0; i < (int)this->size(); i++) { + for (size_t i = 0; i < this->size(); i++) { this->at(i)->magnifySelf(factor); } } @@ -541,7 +544,7 @@ namespace MbD { inline std::ostream& FullMatrix::printOn(std::ostream& s) const { s << "FullMat[" << std::endl; - for (int i = 0; i < (int)this->size(); i++) + for (size_t i = 0; i < this->size(); i++) { s << *(this->at(i)) << std::endl; } @@ -560,7 +563,7 @@ namespace MbD { auto qE = std::make_shared>(4); qE->initialize(); auto OneMinusTraceDivFour = (1.0 - traceA) / 4.0; - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { dumSq = this->at(i)->at(i) / 2.0 + OneMinusTraceDivFour; dum = (dumSq > 0.0) ? std::sqrt(dumSq) : 0.0; @@ -570,8 +573,8 @@ namespace MbD { dum = (dumSq > 0.0) ? std::sqrt(dumSq) : 0.0; qE->atiput(3, dum); T max = 0.0; - int maxE = -1; - for (int i = 0; i < 4; i++) + size_t maxE = SIZE_MAX; + for (size_t i = 0; i < 4; i++) { auto num = qE->at(i); if (max < num) { @@ -612,7 +615,7 @@ namespace MbD { inline T FullMatrix::trace() { T trace = 0.0; - for (int i = 0; i < (int)this->size(); i++) + for (size_t i = 0; i < this->size(); i++) { trace += this->at(i)->at(i); } @@ -622,7 +625,7 @@ namespace MbD { inline double FullMatrix::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)->maxMagnitude(); if (max < element) max = element; @@ -667,15 +670,51 @@ namespace MbD { return answer; } template + inline std::shared_ptr> FullMatrix::eulerAngleszxz() + { + auto answer = std::make_shared>(); + T cthe1x, the0z, the1x, the2z, cthe2z, sthe2z; + cthe1x = this->at(2)->at(2); + if (Numeric::equaltol(std::abs(cthe1x), 1.0, 1.0e-6)) { + the0z = std::atan2(this->at(1)->at(0), this->at(0)->at(0)); + if (cthe1x > 0.0) { + the1x = 0.0; + the2z = 0.0; + } + else { + the1x = OS_M_PI; + the2z = 0.0; + } + } + else { + the2z = std::atan2(this->at(2)->at(0), this->at(2)->at(1)); + cthe2z = std::cos(the2z); + sthe2z = std::sin(the2z); + if (std::abs(cthe2z) > std::abs(sthe2z)) { + the1x = std::atan2(this->at(2)->at(1), cthe2z * this->at(2)->at(2)); + } + else { + the1x = std::atan2(this->at(2)->at(0), sthe2z * this->at(2)->at(2)); + } + the0z = std::atan2(this->at(0)->at(2), this->at(1)->at(2)); + auto aaaa = std::atan2(this->at(0)->at(2), -this->at(1)->at(2)); //Check missing minus is needed above. Smalltalk has missing minus too. + assert(Numeric::equaltol(the0z, aaaa, 1.0e-9)); + } + answer->atiput(0, the0z); + answer->atiput(1, the1x); + answer->atiput(2, the2z); + return answer; + } + template inline bool FullMatrix::isDiagonal() { auto m = this->nrow(); auto n = this->ncol(); if (m != n) return false; - for (int i = 0; i < m; i++) + for (size_t i = 0; i < m; i++) { auto rowi = this->at(i); - for (int j = 0; j < n; j++) + for (size_t j = 0; j < n; j++) { if (i != j && rowi->at(j) != 0) return false; } @@ -689,9 +728,9 @@ namespace MbD { auto tol = ratio * maxMag; auto nrow = this->nrow(); if (nrow == this->ncol()) { - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { - for (int j = i + 1; j < 3; j++) + for (size_t j = i + 1; j < 3; j++) { if (std::abs(this->at(i)->at(j)) > tol) return false; if (std::abs(this->at(j)->at(i)) > tol) return false; @@ -722,9 +761,9 @@ namespace MbD { template inline std::shared_ptr> FullMatrix::asDiagonalMatrix() { - int nrow = this->nrow(); + size_t nrow = this->nrow(); auto diagMat = std::make_shared>(nrow); - for (int i = 0; i < nrow; i++) + for (size_t i = 0; i < nrow; i++) { diagMat->atiput(i, this->at(i)->at(i)); } @@ -748,7 +787,7 @@ namespace MbD { //"a*b = a(i,j)b(j) sum j." auto nrow = this->nrow(); auto answer = std::make_shared>(nrow); - for (int i = 0; i < nrow; i++) + for (size_t i = 0; i < nrow; i++) { answer->at(i) = this->at(i)->timesFullColumn(fullCol); } diff --git a/OndselSolver/FullRow.h b/OndselSolver/FullRow.h index fac8d57..cf049af 100644 --- a/OndselSolver/FullRow.h +++ b/OndselSolver/FullRow.h @@ -49,7 +49,7 @@ namespace MbD { void equalFullRow(FRowsptr fullRow); FColsptr transpose(); FRowsptr copy(); - void atiplusFullRow(int j, FRowsptr fullRow); + void atiplusFullRow(size_t j, FRowsptr fullRow); FMatsptr transposeTimesFullRow(FRowsptr fullRow); double dot(std::shared_ptr> vec); std::shared_ptr> dot(std::shared_ptr>>> vecvec); @@ -61,9 +61,9 @@ namespace MbD { template<> inline FRowDsptr FullRow::times(double a) { - int n = (int)this->size(); + auto n = this->size(); auto answer = std::make_shared>(n); - for (int i = 0; i < n; i++) { + for (size_t i = 0; i < n; i++) { answer->at(i) = this->at(i) * a; } return answer; @@ -81,9 +81,9 @@ namespace MbD { template inline FRowsptr FullRow::plusFullRow(FRowsptr fullRow) { - int n = (int) this->size(); + auto n = this->size(); auto answer = std::make_shared>(n); - for (int i = 0; i < n; i++) { + for (size_t i = 0; i < n; i++) { answer->at(i) = this->at(i) + fullRow->at(i); } return answer; @@ -91,9 +91,9 @@ namespace MbD { template inline FRowsptr FullRow::minusFullRow(FRowsptr fullRow) { - int n = (int) this->size(); + auto n = this->size(); auto answer = std::make_shared>(n); - for (int i = 0; i < n; i++) { + for (size_t i = 0; i < n; i++) { answer->at(i) = this->at(i) - fullRow->at(i); } return answer; @@ -107,7 +107,7 @@ namespace MbD { inline T FullRow::timesFullColumn(FullColumn* fullCol) { auto answer = this->at(0) * fullCol->at(0); - for (int i = 1; i < (int)this->size(); i++) + for (size_t i = 1; i < this->size(); i++) { answer += this->at(i) * fullCol->at(i); } @@ -117,9 +117,9 @@ namespace MbD { inline FRowsptr FullRow::timesTransposeFullMatrix(FMatsptr fullMat) { //"a*bT = a(1,j)b(k,j)" - int ncol = fullMat->nrow(); + size_t ncol = fullMat->nrow(); auto answer = std::make_shared>(ncol); - for (int k = 0; k < ncol; k++) { + for (size_t k = 0; k < ncol; k++) { answer->at(k) = this->dot(fullMat->at(k)); } return answer; @@ -142,18 +142,18 @@ namespace MbD { template<> inline FRowDsptr FullRow::copy() { - auto n = (int)this->size(); + auto n = this->size(); auto answer = std::make_shared>(n); - for (int i = 0; i < n; i++) + for (size_t i = 0; i < n; i++) { answer->at(i) = this->at(i); } return answer; } template - inline void FullRow::atiplusFullRow(int j1, FRowsptr fullRow) + inline void FullRow::atiplusFullRow(size_t 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); @@ -163,9 +163,9 @@ namespace MbD { inline FMatsptr FullRow::transposeTimesFullRow(FRowsptr fullRow) { //"a*b = a(i)b(j)" - auto nrow = (int)this->size(); + auto nrow = this->size(); auto answer = std::make_shared>(nrow); - for (int i = 0; i < nrow; i++) + for (size_t i = 0; i < nrow; i++) { answer->atiput(i, fullRow->times(this->at(i))); } @@ -174,9 +174,9 @@ namespace MbD { template inline double FullRow::dot(std::shared_ptr> vec) { - int n = (int)this->size(); + auto n = this->size(); double answer = 0.0; - for (int i = 0; i < n; i++) { + for (size_t i = 0; i < n; i++) { answer += this->at(i) * vec->at(i); } return answer; @@ -184,12 +184,12 @@ namespace MbD { template inline std::shared_ptr> FullRow::dot(std::shared_ptr>>> vecvec) { - auto ncol = (int)this->size(); + auto ncol = this->size(); auto nelem = vecvec->at(0)->size(); auto answer = std::make_shared>(nelem); - for (int k = 0; k < (int)nelem; k++) { + for (size_t k = 0; k < nelem; k++) { auto sum = 0.0; - for (int i = 0; i < ncol; i++) + for (size_t i = 0; i < ncol; i++) { sum += this->at(i) * vecvec->at(i)->at(k); } @@ -202,7 +202,7 @@ namespace MbD { { s << "FullRow{"; 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); } @@ -213,7 +213,7 @@ namespace MbD { inline FRowsptr FullRow::timesFullMatrix(FMatsptr 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/FullVector.h b/OndselSolver/FullVector.h index 5e44d96..409470f 100644 --- a/OndselSolver/FullVector.h +++ b/OndselSolver/FullVector.h @@ -9,7 +9,6 @@ #pragma once #include -#include #include "Array.h" @@ -25,13 +24,13 @@ namespace MbD { FullVector(typename std::vector::iterator begin, typename std::vector::iterator end) : Array(begin, end) {} FullVector(std::initializer_list list) : Array{ list } {} double dot(std::shared_ptr> vec); - void atiplusNumber(int i, T value); - void atiminusNumber(int i, T value); + void atiplusNumber(size_t i, T value); + void atiminusNumber(size_t i, T value); double sumOfSquares() override; - int numberOfElements() override; + size_t numberOfElements() override; void zeroSelf() override; - void atiplusFullVector(int i, std::shared_ptr> fullVec); - void atiplusFullVectortimes(int i, std::shared_ptr> fullVec, T factor); + void atiplusFullVector(size_t i, std::shared_ptr> fullVec); + void atiplusFullVectortimes(size_t i, std::shared_ptr> fullVec, T factor); void equalSelfPlusFullVectortimes(std::shared_ptr> fullVec, T factor); double maxMagnitude() override; void normalizeSelf(); @@ -50,20 +49,20 @@ namespace MbD { template inline double FullVector::dot(std::shared_ptr> vec) { - int n = (int)this->size(); + auto n = this->size(); double answer = 0.0; - for (int i = 0; i < n; i++) { + for (size_t i = 0; i < n; i++) { answer += this->at(i) * vec->at(i); } return answer; } template - inline void FullVector::atiplusNumber(int i, T value) + inline void FullVector::atiplusNumber(size_t i, T value) { this->at(i) += value; } template - inline void FullVector::atiminusNumber(int i, T value) + inline void FullVector::atiminusNumber(size_t i, T value) { this->at(i) -= value; } @@ -71,7 +70,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; @@ -85,14 +84,14 @@ namespace MbD { return 0.0; } template - inline int FullVector::numberOfElements() + inline size_t FullVector::numberOfElements() { - return (int)this->size(); + return this->size(); } 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; } } @@ -102,18 +101,18 @@ namespace MbD { assert(false); } template - inline void FullVector::atiplusFullVector(int i1, std::shared_ptr> fullVec) + inline void FullVector::atiplusFullVector(size_t i1, std::shared_ptr> fullVec) { - for (int ii = 0; ii < (int)fullVec->size(); ii++) + for (size_t ii = 0; ii < fullVec->size(); ii++) { auto i = i1 + ii; this->at(i) += fullVec->at(ii); } } template - inline void FullVector::atiplusFullVectortimes(int i1, std::shared_ptr> fullVec, T factor) + inline void FullVector::atiplusFullVectortimes(size_t i1, std::shared_ptr> fullVec, T factor) { - for (int ii = 0; ii < (int)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 +121,7 @@ namespace MbD { template inline void FullVector::equalSelfPlusFullVectortimes(std::shared_ptr> fullVec, T factor) { - for (int i = 0; i < (int)this->size(); i++) + for (size_t i = 0; i < this->size(); i++) { this->atiplusNumber(i, fullVec->at(i) * factor); } @@ -131,7 +130,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 +155,7 @@ namespace MbD { inline double FullVector::length() { double ssq = 0.0; - for (int i = 0; i < (int)this->size(); i++) + for (size_t i = 0; i < this->size(); i++) { double elem = this->at(i); ssq += elem * elem; @@ -173,7 +172,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 +204,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 < (int)this->size(); i++) + for (size_t i = 1; i < this->size(); i++) { auto previous = next; next = this->at(i); @@ -219,7 +218,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 < (int)this->size(); i++) + for (size_t i = 1; i < this->size(); i++) { auto previous = next; next = this->at(i); @@ -232,7 +231,7 @@ namespace MbD { { s << "FullVec{"; 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/FunctionWithManyArgs.cpp b/OndselSolver/FunctionWithManyArgs.cpp index bd4b2e5..d89c56b 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 < (int)_terms->size(); i++) + for (size_t i = 0; i < _terms->size(); i++) terms->push_back(_terms->at(i)); } diff --git a/OndselSolver/GEFullMat.cpp b/OndselSolver/GEFullMat.cpp index a89f65e..b551049 100644 --- a/OndselSolver/GEFullMat.cpp +++ b/OndselSolver/GEFullMat.cpp @@ -12,7 +12,7 @@ using namespace MbD; -void GEFullMat::forwardEliminateWithPivot(int) +void GEFullMat::forwardEliminateWithPivot(size_t) { assert(false); } @@ -21,11 +21,11 @@ void GEFullMat::backSubstituteIntoDU() { answerX = std::make_shared>(n); answerX->at(n - 1) = rightHandSideB->at(m - 1) / matrixA->at(m - 1)->at(n - 1); - for (int i = n - 2; i >= 0; i--) + for (int i = n - 2; i >= 0; i--) //Use int because of decrement { auto rowi = matrixA->at(i); double sum = answerX->at(n) * rowi->at(n); - for (int j = i + 1; j < n - 1; j++) + for (size_t j = i + 1; j < n - 1; j++) { sum += answerX->at(j) * rowi->at(j); } @@ -48,7 +48,7 @@ void GEFullMat::preSolvewithsaveOriginal(SpMatDsptr, FColDsptr, bool) assert(false); } -double GEFullMat::getmatrixArowimaxMagnitude(int i) +double GEFullMat::getmatrixArowimaxMagnitude(size_t i) { return matrixA->at(i)->maxMagnitude(); } @@ -56,7 +56,7 @@ double GEFullMat::getmatrixArowimaxMagnitude(int i) FColDsptr GEFullMat::basicSolvewithsaveOriginal(FMatDsptr fullMat, FColDsptr fullCol, bool saveOriginal) { this->preSolvewithsaveOriginal(fullMat, fullCol, saveOriginal); - for (int p = 0; p < m; p++) + for (size_t p = 0; p < m; p++) { this->doPivoting(p); this->forwardEliminateWithPivot(p); diff --git a/OndselSolver/GEFullMat.h b/OndselSolver/GEFullMat.h index 806c947..3c8e47c 100644 --- a/OndselSolver/GEFullMat.h +++ b/OndselSolver/GEFullMat.h @@ -15,14 +15,14 @@ namespace MbD { { // public: - void forwardEliminateWithPivot(int p) override; + void forwardEliminateWithPivot(size_t p) override; void backSubstituteIntoDU() override; void postSolve() override; FColDsptr basicSolvewithsaveOriginal(FMatDsptr fullMat, FColDsptr fullCol, bool saveOriginal) override; FColDsptr basicSolvewithsaveOriginal(SpMatDsptr spMat, FColDsptr fullCol, bool saveOriginal) override; void preSolvewithsaveOriginal(FMatDsptr fullMat, FColDsptr fullCol, bool saveOriginal) override; void preSolvewithsaveOriginal(SpMatDsptr spMat, FColDsptr fullCol, bool saveOriginal) override; - double getmatrixArowimaxMagnitude(int i) override; + double getmatrixArowimaxMagnitude(size_t i) override; FMatDsptr matrixA; }; diff --git a/OndselSolver/GEFullMatFullPv.cpp b/OndselSolver/GEFullMatFullPv.cpp index d8a0085..7722934 100644 --- a/OndselSolver/GEFullMatFullPv.cpp +++ b/OndselSolver/GEFullMatFullPv.cpp @@ -13,18 +13,18 @@ using namespace MbD; -void GEFullMatFullPv::doPivoting(int p) +void GEFullMatFullPv::doPivoting(size_t p) { //"Do full pivoting." //| max pivotRow pivotCol rowi aij mag | double max = 0.0; - int pivotRow = p; - int pivotCol = p; - for (int i = p; i < m; i++) + size_t pivotRow = p; + size_t pivotCol = p; + for (size_t i = p; i < m; i++) { auto rowi = matrixA->at(i); - for (int j = p; j < n; j++) + for (size_t j = p; j < n; j++) { auto aij = rowi->at(j); if (aij != 0.0) { diff --git a/OndselSolver/GEFullMatFullPv.h b/OndselSolver/GEFullMatFullPv.h index e0d1594..01e7aff 100644 --- a/OndselSolver/GEFullMatFullPv.h +++ b/OndselSolver/GEFullMatFullPv.h @@ -15,7 +15,7 @@ namespace MbD { { // public: - void doPivoting(int p) override; + void doPivoting(size_t p) override; void postSolve() override; }; } diff --git a/OndselSolver/GEFullMatParPv.cpp b/OndselSolver/GEFullMatParPv.cpp index cd7ddfe..4ee5d01 100644 --- a/OndselSolver/GEFullMatParPv.cpp +++ b/OndselSolver/GEFullMatParPv.cpp @@ -13,7 +13,7 @@ using namespace MbD; -void GEFullMatParPv::doPivoting(int p) +void GEFullMatParPv::doPivoting(size_t p) { //"Use scalings. Do row pivoting." @@ -22,7 +22,7 @@ void GEFullMatParPv::doPivoting(int p) double max = app * rowScalings->at(p); if (max < 0.0) max = -max; auto rowPivot = p; - for (int i = p + 1; i < m; i++) + for (size_t i = p + 1; i < m; i++) { auto aip = matrixA->at(i)->at(p); if (aip != 0.0) { diff --git a/OndselSolver/GEFullMatParPv.h b/OndselSolver/GEFullMatParPv.h index d849369..4d3cf9e 100644 --- a/OndselSolver/GEFullMatParPv.h +++ b/OndselSolver/GEFullMatParPv.h @@ -15,7 +15,7 @@ namespace MbD { { // public: - void doPivoting(int p) override; + void doPivoting(size_t p) override; void postSolve() override; void preSolvewithsaveOriginal(FMatDsptr fullMat, FColDsptr fullCol, bool saveOriginal) override; }; diff --git a/OndselSolver/GESpMat.cpp b/OndselSolver/GESpMat.cpp index 4beccd3..83ab84f 100644 --- a/OndselSolver/GESpMat.cpp +++ b/OndselSolver/GESpMat.cpp @@ -21,7 +21,7 @@ FColDsptr GESpMat::solvewithsaveOriginal(SpMatDsptr spMat, FColDsptr fullCol, bo FColDsptr GESpMat::basicSolvewithsaveOriginal(SpMatDsptr spMat, FColDsptr fullCol, bool saveOriginal) { this->preSolvewithsaveOriginal(spMat, fullCol, saveOriginal); - for (int p = 0; p < m; p++) + for (size_t p = 0; p < m; p++) { this->doPivoting(p); this->forwardEliminateWithPivot(p); @@ -47,7 +47,7 @@ void GESpMat::preSolvewithsaveOriginal(SpMatDsptr, FColDsptr, bool) assert(false); } -double GESpMat::getmatrixArowimaxMagnitude(int i) +double GESpMat::getmatrixArowimaxMagnitude(size_t i) { return matrixA->at(i)->maxMagnitude(); } diff --git a/OndselSolver/GESpMat.h b/OndselSolver/GESpMat.h index f7002dd..1508044 100644 --- a/OndselSolver/GESpMat.h +++ b/OndselSolver/GESpMat.h @@ -21,11 +21,11 @@ namespace MbD { FColDsptr basicSolvewithsaveOriginal(FMatDsptr fullMat, FColDsptr fullCol, bool saveOriginal) override; void preSolvewithsaveOriginal(FMatDsptr fullMat, FColDsptr fullCol, bool saveOriginal) override; void preSolvewithsaveOriginal(SpMatDsptr spMat, FColDsptr fullCol, bool saveOriginal) override; - double getmatrixArowimaxMagnitude(int i) override; + double getmatrixArowimaxMagnitude(size_t i) override; SpMatDsptr matrixA; - int markowitzPivotRowCount = -1, markowitzPivotColCount = -1; - std::shared_ptr> rowPositionsOfNonZerosInPivotColumn; + size_t markowitzPivotRowCount = SIZE_MAX, markowitzPivotColCount = SIZE_MAX; + std::shared_ptr> rowPositionsOfNonZerosInPivotColumn; }; } diff --git a/OndselSolver/GESpMatFullPv.cpp b/OndselSolver/GESpMatFullPv.cpp index 38407d4..3eab30b 100644 --- a/OndselSolver/GESpMatFullPv.cpp +++ b/OndselSolver/GESpMatFullPv.cpp @@ -13,7 +13,7 @@ using namespace MbD; -void GESpMatFullPv::doPivoting(int p) +void GESpMatFullPv::doPivoting(size_t p) { //"Used by Gauss Elimination only." //"Do full pivoting." @@ -23,11 +23,11 @@ void GESpMatFullPv::doPivoting(int p) double max = 0.0; auto pivotRow = p; auto pivotCol = p; - for (int j = p; j < n; j++) + for (size_t j = p; j < n; j++) { rowPositionsOfNonZerosInColumns->at(colOrder->at(j))->clear(); } - for (int i = p; i < m; i++) + for (size_t i = p; i < m; i++) { auto& rowi = matrixA->at(i); for (auto const& kv : *rowi) { @@ -59,9 +59,9 @@ void GESpMatFullPv::doPivoting(int p) if (rowPositionsOfNonZerosInPivotColumn->front() == p) { rowPositionsOfNonZerosInPivotColumn->erase(rowPositionsOfNonZerosInPivotColumn->begin()); } - markowitzPivotColCount = (int)rowPositionsOfNonZerosInPivotColumn->size(); + markowitzPivotColCount = rowPositionsOfNonZerosInPivotColumn->size(); } -void GESpMatFullPv::forwardEliminateWithPivot(int p) +void GESpMatFullPv::forwardEliminateWithPivot(size_t p) { //app is pivot. //i > p, j > p @@ -73,8 +73,8 @@ void GESpMatFullPv::forwardEliminateWithPivot(int p) auto jp = colOrder->at(p); auto& rowp = matrixA->at(p); auto app = rowp->at(jp); - auto elementsInPivotRow = std::make_shared*>>(rowp->size() - 1); - int index = 0; + auto elementsInPivotRow = std::make_shared*>>(rowp->size() - 1); + size_t index = 0; for (auto const& keyValue : *rowp) { if (keyValue.first != jp) { elementsInPivotRow->at(index) = (&keyValue); @@ -82,7 +82,7 @@ void GESpMatFullPv::forwardEliminateWithPivot(int p) } } auto bp = rightHandSideB->at(p); - for (int ii = 0; ii < markowitzPivotColCount; ii++) + for (size_t ii = 0; ii < markowitzPivotColCount; ii++) { auto i = rowPositionsOfNonZerosInPivotColumn->at(ii); auto& spRowi = matrixA->at(i); @@ -118,9 +118,9 @@ void GESpMatFullPv::backSubstituteIntoDU() auto jn = colOrder->at(n); answerX->at(jn) = rightHandSideB->at(m) / matrixA->at(m)->at(jn); //auto rhsZeroElement = this->rhsZeroElement(); - for (int i = n - 2; i >= 0; i--) + for (int i = n - 2; i >= 0; i--) //Use int because of decrement { - auto& rowi = matrixA->at((int)i); + auto& rowi = matrixA->at(i); sum = 0.0; // rhsZeroElement copy. for (auto const& keyValue : *rowi) { auto jj = keyValue.first; @@ -151,13 +151,13 @@ void GESpMatFullPv::preSolvewithsaveOriginal(SpMatDsptr spMat, FColDsptr fullCol n = spMat->ncol(); matrixA = std::make_shared>(m); pivotValues = std::make_shared>(m); - rowOrder = std::make_shared>(m); - colOrder = std::make_shared>(n); - positionsOfOriginalCols = std::make_shared>(m); - rowPositionsOfNonZerosInColumns = std::make_shared>>>(n); - for (int j = 0; j < n; j++) + rowOrder = std::make_shared>(m); + colOrder = std::make_shared>(n); + positionsOfOriginalCols = std::make_shared>(m); + rowPositionsOfNonZerosInColumns = std::make_shared>>>(n); + for (size_t j = 0; j < n; j++) { - rowPositionsOfNonZerosInColumns->at(j) = std::make_shared>(); + rowPositionsOfNonZerosInColumns->at(j) = std::make_shared>(); } } if (saveOriginal) { @@ -166,7 +166,7 @@ void GESpMatFullPv::preSolvewithsaveOriginal(SpMatDsptr spMat, FColDsptr fullCol else { rightHandSideB = fullCol; } - for (int i = 0; i < m; i++) + for (size_t i = 0; i < m; i++) { auto& spRowi = spMat->at(i); double maxRowMagnitude = spRowi->maxMagnitude(); diff --git a/OndselSolver/GESpMatFullPv.h b/OndselSolver/GESpMatFullPv.h index a0e351f..9e8c60f 100644 --- a/OndselSolver/GESpMatFullPv.h +++ b/OndselSolver/GESpMatFullPv.h @@ -15,14 +15,14 @@ namespace MbD { { //positionsOfOriginalCols rowPositionsOfNonZerosInColumns public: - void doPivoting(int p) override; - void forwardEliminateWithPivot(int p) override; + void doPivoting(size_t p) override; + void forwardEliminateWithPivot(size_t p) override; void backSubstituteIntoDU() override; void postSolve() override; void preSolvewithsaveOriginal(SpMatDsptr spMat, FColDsptr fullCol, bool saveOriginal) override; - std::shared_ptr> positionsOfOriginalCols; - std::shared_ptr>>> rowPositionsOfNonZerosInColumns; + std::shared_ptr> positionsOfOriginalCols; + std::shared_ptr>>> rowPositionsOfNonZerosInColumns; }; } diff --git a/OndselSolver/GESpMatFullPvPosIC.cpp b/OndselSolver/GESpMatFullPvPosIC.cpp index d4ae23b..458e1da 100644 --- a/OndselSolver/GESpMatFullPvPosIC.cpp +++ b/OndselSolver/GESpMatFullPvPosIC.cpp @@ -19,15 +19,15 @@ void GESpMatFullPvPosIC::preSolvewithsaveOriginal(SpMatDsptr spMat, FColDsptr fu { GESpMatFullPv::preSolvewithsaveOriginal(spMat, fullCol, saveOriginal); if (system == nullptr) { - pivotRowLimits = std::make_shared>(); + pivotRowLimits = std::make_shared>(); } else { pivotRowLimits = system->pivotRowLimits; } - pivotRowLimit = -1; + pivotRowLimit = SIZE_MAX; } -void GESpMatFullPvPosIC::doPivoting(int p) +void GESpMatFullPvPosIC::doPivoting(size_t p) { //"Used by Gauss Elimination only." //"Swap rows but keep columns in place." @@ -36,16 +36,16 @@ void GESpMatFullPvPosIC::doPivoting(int p) double max = 0.0; auto pivotRow = p; auto pivotCol = p; - for (int j = p; j < n; j++) + for (size_t j = p; j < n; j++) { rowPositionsOfNonZerosInColumns->at(colOrder->at(j))->clear(); } - if (p >= pivotRowLimit) { + if (pivotRowLimit == SIZE_MAX || p >= pivotRowLimit) { pivotRowLimit = *std::find_if( pivotRowLimits->begin(), pivotRowLimits->end(), - [&](int limit) { return limit > p; }); + [&](size_t limit) { return limit > p; }); } - for (int i = p; i < pivotRowLimit; i++) + for (size_t i = p; i < pivotRowLimit; i++) { auto& rowi = matrixA->at(i); for (auto const& kv : *rowi) { @@ -74,11 +74,11 @@ void GESpMatFullPvPosIC::doPivoting(int p) if (max < singularPivotTolerance) { auto itr = std::find_if( pivotRowLimits->begin(), pivotRowLimits->end(), - [&](int limit) { return limit > pivotRowLimit; }); + [&](size_t limit) { return limit > pivotRowLimit; }); if (itr == pivotRowLimits->end()) { auto begin = rowOrder->begin() + p; auto end = rowOrder->begin() + pivotRowLimit; - auto redundantEqnNos = std::make_shared>(begin, end); + auto redundantEqnNos = std::make_shared>(begin, end); throwSingularMatrixError("", redundantEqnNos); } else { @@ -88,7 +88,7 @@ void GESpMatFullPvPosIC::doPivoting(int p) } auto jp = colOrder->at(p); rowPositionsOfNonZerosInPivotColumn = rowPositionsOfNonZerosInColumns->at(jp); - for (int i = pivotRowLimit; i < m; i++) + for (size_t i = pivotRowLimit; i < m; i++) { auto& spRowi = matrixA->at(i); if (spRowi->find(jp) != spRowi->end()) { @@ -98,5 +98,5 @@ void GESpMatFullPvPosIC::doPivoting(int p) if (rowPositionsOfNonZerosInPivotColumn->front() == p) { rowPositionsOfNonZerosInPivotColumn->erase(rowPositionsOfNonZerosInPivotColumn->begin()); } - markowitzPivotColCount = (int)rowPositionsOfNonZerosInPivotColumn->size(); + markowitzPivotColCount = rowPositionsOfNonZerosInPivotColumn->size(); } \ No newline at end of file diff --git a/OndselSolver/GESpMatFullPvPosIC.h b/OndselSolver/GESpMatFullPvPosIC.h index de6fc6e..203660d 100644 --- a/OndselSolver/GESpMatFullPvPosIC.h +++ b/OndselSolver/GESpMatFullPvPosIC.h @@ -18,11 +18,11 @@ namespace MbD { //system pivotRowLimits pivotRowLimit public: void preSolvewithsaveOriginal(SpMatDsptr spMat, FColDsptr fullCol, bool saveOriginal) override; - void doPivoting(int p) override; + void doPivoting(size_t p) override; PosICNewtonRaphson* system; //Use raw pointer when pointing backwards. - std::shared_ptr> pivotRowLimits; - int pivotRowLimit; + std::shared_ptr> pivotRowLimits; + size_t pivotRowLimit; }; } diff --git a/OndselSolver/GESpMatParPv.cpp b/OndselSolver/GESpMatParPv.cpp index 4f0d476..62c2cb7 100644 --- a/OndselSolver/GESpMatParPv.cpp +++ b/OndselSolver/GESpMatParPv.cpp @@ -12,14 +12,14 @@ using namespace MbD; -void GESpMatParPv::forwardEliminateWithPivot(int p) +void GESpMatParPv::forwardEliminateWithPivot(size_t p) { //"rightHandSideB may be multidimensional." auto& rowp = matrixA->at(p); auto app = rowp->at(p); - auto elementsInPivotRow = std::make_shared*>>(rowp->size() - 1); - int index = 0; + auto elementsInPivotRow = std::make_shared*>>(rowp->size() - 1); + size_t index = 0; for (auto const& keyValue : *rowp) { if (keyValue.first != p) { elementsInPivotRow->at(index) = (&keyValue); @@ -27,7 +27,7 @@ void GESpMatParPv::forwardEliminateWithPivot(int p) } } auto bp = rightHandSideB->at(p); - for (int ii = 0; ii < markowitzPivotColCount; ii++) + for (size_t ii = 0; ii < markowitzPivotColCount; ii++) { auto i = rowPositionsOfNonZerosInPivotColumn->at(ii); auto& rowi = matrixA->at(i); @@ -54,7 +54,7 @@ void GESpMatParPv::backSubstituteIntoDU() answerX = std::make_shared>(m); answerX->at(n - 1) = rightHandSideB->at(m - 1) / matrixA->at(m - 1)->at(n - 1); //auto rhsZeroElement = this->rhsZeroElement(); - for (int i = n - 2; i >= 0; i--) + for (int i = n - 2; i >= 0; i--) //Use int because of decrement { auto rowi = matrixA->at(i); sum = 0.0; // rhsZeroElement copy. diff --git a/OndselSolver/GESpMatParPv.h b/OndselSolver/GESpMatParPv.h index cfb8f8c..06a7ffa 100644 --- a/OndselSolver/GESpMatParPv.h +++ b/OndselSolver/GESpMatParPv.h @@ -15,7 +15,7 @@ namespace MbD { { // public: - void forwardEliminateWithPivot(int p) override; + void forwardEliminateWithPivot(size_t p) override; void backSubstituteIntoDU() override; void postSolve() override; diff --git a/OndselSolver/GESpMatParPvMarko.cpp b/OndselSolver/GESpMatParPvMarko.cpp index 8de4227..8d075af 100644 --- a/OndselSolver/GESpMatParPvMarko.cpp +++ b/OndselSolver/GESpMatParPvMarko.cpp @@ -13,14 +13,15 @@ using namespace MbD; -void GESpMatParPvMarko::doPivoting(int p) +void GESpMatParPvMarko::doPivoting(size_t p) { //"Search from bottom to top." //"Check for singular pivot." //"Do scaling. Do partial pivoting." //"criterion := mag / (2.0d raisedTo: rowiCount)." //| lookForFirstNonZeroInPivotCol i rowi aip criterionMax rowPivoti criterion max | - int i, rowPivoti; + int i; //Use int because of decrement + size_t rowPivoti; double aip, mag, max, criterion, criterionMax; SpRowDsptr spRowi; rowPositionsOfNonZerosInPivotColumn->clear(); @@ -29,7 +30,7 @@ void GESpMatParPvMarko::doPivoting(int p) while (lookForFirstNonZeroInPivotCol) { spRowi = matrixA->at(i); if (spRowi->find(p) == spRowi->end()) { - if (i <= p) throwSingularMatrixError(""); + if (i <= (int)p) throwSingularMatrixError(""); //Use int because i can be negative } else { markowitzPivotColCount = 0; @@ -38,12 +39,12 @@ void GESpMatParPvMarko::doPivoting(int p) if (mag < 0) mag = -mag; max = mag; criterionMax = mag / std::pow(2.0, spRowi->size()); - rowPivoti = i; + rowPivoti = (size_t)i; lookForFirstNonZeroInPivotCol = false; } i--; } - while (i >= p) { + while (i >= (int)p) { //Use int because i can be negative spRowi = matrixA->at(i); if (spRowi->find(p) == spRowi->end()) { aip = std::numeric_limits::min(); @@ -58,7 +59,7 @@ void GESpMatParPvMarko::doPivoting(int p) max = mag; criterionMax = criterion; rowPositionsOfNonZerosInPivotColumn->push_back(rowPivoti); - rowPivoti = i; + rowPivoti = (size_t)i; } else { rowPositionsOfNonZerosInPivotColumn->push_back(i); @@ -70,7 +71,7 @@ void GESpMatParPvMarko::doPivoting(int p) matrixA->swapElems(p, rowPivoti); rightHandSideB->swapElems(p, rowPivoti); rowScalings->swapElems(p, rowPivoti); - if (aip != std::numeric_limits::min()) rowPositionsOfNonZerosInPivotColumn->at((int)markowitzPivotColCount - 1) = rowPivoti; + if (aip != std::numeric_limits::min()) rowPositionsOfNonZerosInPivotColumn->at(markowitzPivotColCount - 1) = rowPivoti; } if (max < singularPivotTolerance) throwSingularMatrixError(""); } @@ -83,7 +84,7 @@ void GESpMatParPvMarko::preSolvewithsaveOriginal(SpMatDsptr spMat, FColDsptr ful n = spMat->ncol(); matrixA = std::make_shared>(m); rowScalings = std::make_shared>(m); - rowPositionsOfNonZerosInPivotColumn = std::make_shared>(); + rowPositionsOfNonZerosInPivotColumn = std::make_shared>(); } if (saveOriginal) { rightHandSideB = fullCol->copy(); @@ -91,7 +92,7 @@ void GESpMatParPvMarko::preSolvewithsaveOriginal(SpMatDsptr spMat, FColDsptr ful else { rightHandSideB = fullCol; } - for (int i = 0; i < m; i++) + for (size_t i = 0; i < m; i++) { auto& spRowi = spMat->at(i); double maxRowMagnitude = spRowi->maxMagnitude(); diff --git a/OndselSolver/GESpMatParPvMarko.h b/OndselSolver/GESpMatParPvMarko.h index f85d081..2c9636c 100644 --- a/OndselSolver/GESpMatParPvMarko.h +++ b/OndselSolver/GESpMatParPvMarko.h @@ -15,7 +15,7 @@ namespace MbD { { // public: - void doPivoting(int p) override; + void doPivoting(size_t p) override; void preSolvewithsaveOriginal(SpMatDsptr spMat, FColDsptr fullCol, bool saveOriginal) override; }; diff --git a/OndselSolver/GESpMatParPvMarkoFast.cpp b/OndselSolver/GESpMatParPvMarkoFast.cpp index 7a23812..d8fd26d 100644 --- a/OndselSolver/GESpMatParPvMarkoFast.cpp +++ b/OndselSolver/GESpMatParPvMarkoFast.cpp @@ -22,7 +22,7 @@ void GESpMatParPvMarkoFast::preSolvewithsaveOriginal(SpMatDsptr spMat, FColDsptr m = spMat->nrow(); n = spMat->ncol(); matrixA = std::make_shared>(m); - rowPositionsOfNonZerosInPivotColumn = std::make_shared>(); + rowPositionsOfNonZerosInPivotColumn = std::make_shared>(); } if (saveOriginal) { rightHandSideB = fullCol->copy(); @@ -30,7 +30,7 @@ void GESpMatParPvMarkoFast::preSolvewithsaveOriginal(SpMatDsptr spMat, FColDsptr else { rightHandSideB = fullCol; } - for (int i = 0; i < m; i++) + for (size_t i = 0; i < m; i++) { auto& spRowi = spMat->at(i); double maxRowMagnitude = spRowi->maxMagnitude(); @@ -41,7 +41,7 @@ void GESpMatParPvMarkoFast::preSolvewithsaveOriginal(SpMatDsptr spMat, FColDsptr } } -void GESpMatParPvMarkoFast::doPivoting(int p) +void GESpMatParPvMarkoFast::doPivoting(size_t p) { //"Search from bottom to top." //"Optimized for speed. No check for singular pivot." @@ -51,7 +51,8 @@ void GESpMatParPvMarkoFast::doPivoting(int p) //"Pivot size are nieither checked nor stored." //| lookForFirstNonZeroInPivotCol i rowi aip criterionMax rowPivoti criterion max | - int i, rowPivoti; + int i; //Use int because of decrement + size_t rowPivoti; double aip, max, criterion, criterionMax; SpRowDsptr spRowi; rowPositionsOfNonZerosInPivotColumn->clear(); @@ -60,7 +61,7 @@ void GESpMatParPvMarkoFast::doPivoting(int p) while (lookForFirstNonZeroInPivotCol) { spRowi = matrixA->at(i); if (spRowi->find(p) == spRowi->end()) { - if (i <= p) throwSingularMatrixError(""); + if (i <= (int)p) throwSingularMatrixError(""); //Use int because i can be negative } else { markowitzPivotColCount = 0; @@ -68,12 +69,12 @@ void GESpMatParPvMarkoFast::doPivoting(int p) if (aip < 0) aip = -aip; max = aip; criterionMax = aip / std::pow(2.0, spRowi->size()); - rowPivoti = i; + rowPivoti = (size_t)i; lookForFirstNonZeroInPivotCol = false; } i--; } - while (i >= p) { + while (i >= (int)p) { //Use int because i can be negative spRowi = matrixA->at(i); if (spRowi->find(p) == spRowi->end()) { aip = std::numeric_limits::min(); @@ -87,7 +88,7 @@ void GESpMatParPvMarkoFast::doPivoting(int p) max = aip; criterionMax = criterion; rowPositionsOfNonZerosInPivotColumn->push_back(rowPivoti); - rowPivoti = i; + rowPivoti = (size_t)i; } else { rowPositionsOfNonZerosInPivotColumn->push_back(i); diff --git a/OndselSolver/GESpMatParPvMarkoFast.h b/OndselSolver/GESpMatParPvMarkoFast.h index e9a84d5..8640d77 100644 --- a/OndselSolver/GESpMatParPvMarkoFast.h +++ b/OndselSolver/GESpMatParPvMarkoFast.h @@ -16,7 +16,7 @@ namespace MbD { // public: void preSolvewithsaveOriginal(SpMatDsptr spMat, FColDsptr fullCol, bool saveOriginal) override; - void doPivoting(int p) override; + void doPivoting(size_t p) override; }; } diff --git a/OndselSolver/GESpMatParPvPrecise.cpp b/OndselSolver/GESpMatParPvPrecise.cpp index fca7e26..bad1894 100644 --- a/OndselSolver/GESpMatParPvPrecise.cpp +++ b/OndselSolver/GESpMatParPvPrecise.cpp @@ -13,14 +13,15 @@ using namespace MbD; -void GESpMatParPvPrecise::doPivoting(int p) +void GESpMatParPvPrecise::doPivoting(size_t p) { //"Search from bottom to top." //"Use scaling vector and partial pivoting with actual swapping of rows." //"Check for singular pivot." //"Do scaling. Do partial pivoting." //| max rowPivot aip mag lookForFirstNonZeroInPivotCol i | - int i, rowPivoti; + int i; //Use int because of decrement + size_t rowPivoti; double aip, mag, max; SpRowDsptr spRowi; rowPositionsOfNonZerosInPivotColumn->clear(); @@ -29,7 +30,7 @@ void GESpMatParPvPrecise::doPivoting(int p) while (lookForFirstNonZeroInPivotCol) { spRowi = matrixA->at(i); if (spRowi->find(p) == spRowi->end()) { - if (i <= p) throwSingularMatrixError("doPivoting"); + if (i <= (int)p) throwSingularMatrixError("doPivoting"); //Use int because i can be negative } else { markowitzPivotColCount = 0; @@ -37,12 +38,12 @@ void GESpMatParPvPrecise::doPivoting(int p) mag = aip * rowScalings->at(i); if (mag < 0) mag = -mag; max = mag; - rowPivoti = i; + rowPivoti = (size_t)i; lookForFirstNonZeroInPivotCol = false; } i--; } - while (i >= p) { + while (i >= (int)p) { //Use int because i can be negative spRowi = matrixA->at(i); if (spRowi->find(p) == spRowi->end()) { aip = std::numeric_limits::min(); @@ -55,7 +56,7 @@ void GESpMatParPvPrecise::doPivoting(int p) if (mag > max) { max = mag; rowPositionsOfNonZerosInPivotColumn->push_back(rowPivoti); - rowPivoti = i; + rowPivoti = (size_t)i; } else { rowPositionsOfNonZerosInPivotColumn->push_back(i); @@ -84,8 +85,8 @@ void GESpMatParPvPrecise::preSolvewithsaveOriginal(SpMatDsptr spMat, FColDsptr f matrixA = std::make_shared>(m); rowScalings = std::make_shared>(m); pivotValues = std::make_shared>(m); - rowOrder = std::make_shared>(m); - rowPositionsOfNonZerosInPivotColumn = std::make_shared>(); + rowOrder = std::make_shared>(m); + rowPositionsOfNonZerosInPivotColumn = std::make_shared>(); } if (saveOriginal) { rightHandSideB = fullCol->copy(); @@ -93,7 +94,7 @@ void GESpMatParPvPrecise::preSolvewithsaveOriginal(SpMatDsptr spMat, FColDsptr f else { rightHandSideB = fullCol; } - for (int i = 0; i < m; i++) + for (size_t i = 0; i < m; i++) { auto& spRowi = spMat->at(i); double maxRowMagnitude = spRowi->maxMagnitude(); diff --git a/OndselSolver/GESpMatParPvPrecise.h b/OndselSolver/GESpMatParPvPrecise.h index 0bdda68..17db611 100644 --- a/OndselSolver/GESpMatParPvPrecise.h +++ b/OndselSolver/GESpMatParPvPrecise.h @@ -15,7 +15,7 @@ namespace MbD { { // public: - void doPivoting(int p) override; + void doPivoting(size_t p) override; void preSolvewithsaveOriginal(SpMatDsptr spMat, FColDsptr fullCol, bool saveOriginal) override; }; diff --git a/OndselSolver/GearConstraintIqcJc.cpp b/OndselSolver/GearConstraintIqcJc.cpp index 974c507..b5c4b24 100644 --- a/OndselSolver/GearConstraintIqcJc.cpp +++ b/OndselSolver/GearConstraintIqcJc.cpp @@ -30,7 +30,7 @@ void MbD::GearConstraintIqcJc::addToJointTorqueI(FColDsptr jointTorque) auto pAOIppEI = frmIeqc->pAOppE(); auto aBOIp = frmIeqc->aBOp(); auto fpAOIppEIrIpIeIp = std::make_shared>(4, 0.0); - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto dum = cForceT->timesFullColumn(pAOIppEI->at(i)->timesFullColumn(rIpIeIp)); fpAOIppEIrIpIeIp->atiput(i, dum); diff --git a/OndselSolver/GearConstraintIqcJc.h b/OndselSolver/GearConstraintIqcJc.h index 5c7d34f..99f64fa 100644 --- a/OndselSolver/GearConstraintIqcJc.h +++ b/OndselSolver/GearConstraintIqcJc.h @@ -35,7 +35,7 @@ namespace MbD { FRowDsptr pGpXI, pGpEI; FMatDsptr ppGpXIpXI, ppGpXIpEI, ppGpEIpEI; - int iqXI, iqEI; + size_t iqXI, iqEI; }; } diff --git a/OndselSolver/GearConstraintIqcJqc.h b/OndselSolver/GearConstraintIqcJqc.h index af0f972..20b1557 100644 --- a/OndselSolver/GearConstraintIqcJqc.h +++ b/OndselSolver/GearConstraintIqcJqc.h @@ -37,7 +37,7 @@ namespace MbD { FRowDsptr pGpXJ, pGpEJ; FMatDsptr ppGpXIpXJ, ppGpXIpEJ, ppGpEIpXJ, ppGpEIpEJ, ppGpXJpXJ, ppGpXJpEJ, ppGpEJpEJ; - int iqXJ, iqEJ; + size_t iqXJ, iqEJ; }; } diff --git a/OndselSolver/GeneralSpline.cpp b/OndselSolver/GeneralSpline.cpp index 0c98d39..0579eb0 100644 --- a/OndselSolver/GeneralSpline.cpp +++ b/OndselSolver/GeneralSpline.cpp @@ -36,20 +36,20 @@ void MbD::GeneralSpline::arguments(Symsptr args) { auto array = args->getTerms(); auto& arg = array->at(0); - int order = (int)array->at(1)->getValue(); - int n = ((int)array->size() - 2) / 2; + size_t order = array->at(1)->getValue(); + size_t n = (array->size() - 2) / 2; auto xarray = std::make_shared>(n); auto yarray = std::make_shared>(n); - for (int i = 0; i < n; i++) + for (size_t i = 0; i < n; i++) { - int ii = 2 * ((int)i + 1); + size_t ii = 2 * (i + 1); xarray->at(i) = array->at(ii)->getValue(); yarray->at(i) = array->at(ii + 1)->getValue(); } initxdegreexsys(arg, order, xarray, yarray); } -void MbD::GeneralSpline::initxdegreexsys(Symsptr arg, int order, std::shared_ptr> xarr, std::shared_ptr> yarr) +void MbD::GeneralSpline::initxdegreexsys(Symsptr arg, size_t order, std::shared_ptr> xarr, std::shared_ptr> yarr) { xx = arg; degree = order; @@ -63,41 +63,41 @@ void MbD::GeneralSpline::computeDerivatives() { //"See derivation in MbDTheory 9spline.fodt." if (degree == 0) throw std::runtime_error("ToDo: Use ZeroDegreeSpline"); - auto n = (int)xs->size(); + auto n = xs->size(); auto p = degree; auto np = n * p; auto matrix = std::make_shared>(np, np); auto bvector = std::make_shared>(np, 0.0); auto hs = std::make_shared>(n - 1); double hmax = 0.0; - for (int i = 0; i < n - 1; i++) + for (size_t i = 0; i < n - 1; i++) { - double h = xs->at((int)i + 1) - xs->at(i); + double h = xs->at(i + 1) - xs->at(i); hmax = std::max(hmax, std::abs(h)); hs->atiput(i, h); } - for (int i = 0; i < n - 1; i++) + for (size_t i = 0; i < n - 1; i++) { auto offset = i * p; double hbar = hs->at(i) / hmax; - for (int j = 1; j < p; j++) + for (size_t j = 1; j < p; j++) { matrix->atijput(offset + j, offset + j - 1, 1.0); matrix->atijput(offset + j, offset + j - 1 + p, -1.0); } double dum = 1.0; - for (int j = 0; j < p; j++) + for (size_t j = 0; j < p; j++) { dum = dum * hbar / (j + 1); - for (int k = j; k < p; k++) + for (size_t k = j; k < p; k++) { matrix->atijput(offset + k - j, offset + k, dum); } } - bvector->atiput(offset, ys->at((int)i + 1) - ys->at(i)); + bvector->atiput(offset, ys->at(i + 1) - ys->at(i)); } if (isCyclic()) { - for (int j = 1; j < p + 1; j++) + for (size_t j = 1; j < p + 1; j++) { matrix->atijput(np - j, np - j, 1.0); matrix->atijput(np - j, p - j, -1.0); @@ -121,15 +121,15 @@ void MbD::GeneralSpline::computeDerivatives() auto derivsVector = solver->solvewithsaveOriginal(matrix, bvector, false); derivs = std::make_shared>(n, p); auto hmaxpowers = std::make_shared>(p); - for (int j = 0; j < p; j++) + for (size_t j = 0; j < p; j++) { hmaxpowers->atiput(j, std::pow(hmax, j + 1)); } - for (int i = 0; i < n; i++) + for (size_t i = 0; i < n; i++) { auto& derivsi = derivs->at(i); derivsi->equalArrayAt(derivsVector, (i - 1) * p + 1); - for (int j = 0; j < p; j++) + for (size_t j = 0; j < p; j++) { derivsi->atiput(j, derivsi->at(j) / hmaxpowers->at(j)); } @@ -141,7 +141,7 @@ bool MbD::GeneralSpline::isCyclic() return (ys->size() > 3) && (ys->front() == ys->back()); } -double MbD::GeneralSpline::derivativeAt(int n, double xxx) +double MbD::GeneralSpline::derivativeAt(size_t n, double xxx) { //"dydx(x) := dydxi + d2ydx2i*hi + d3ydx3i*hi^2/2! +" //"d2ydx2(x) := d2ydx2i + d3ydx3i*hi + d4ydx4i*hi^2/2! +" @@ -149,11 +149,11 @@ double MbD::GeneralSpline::derivativeAt(int n, double xxx) calcIndexAndDeltaFor(xxx); auto& derivsi = derivs->at(index); double sum = 0.0; - for (int j = degree; j >= n + 1; j--) + for (int j = degree; j >= n + 1; j--) //Use int because of decrement { - sum = (sum + derivsi->at((int)j - 1)) * delta / (j - n); + sum = (sum + derivsi->at(j - 1)) * delta / (j - n); } - return derivsi->at((int)n - 1) + sum; + return derivsi->at(n - 1) + sum; } void MbD::GeneralSpline::calcIndexAndDeltaFor(double xxx) @@ -185,7 +185,7 @@ void MbD::GeneralSpline::calcNonCyclicIndexAndDelta() } else { if (xvalue >= xLast) { - index = (int)xs->size() - 1; + index = xs->size() - 1; delta = xvalue - xLast; } else { @@ -196,20 +196,20 @@ void MbD::GeneralSpline::calcNonCyclicIndexAndDelta() void MbD::GeneralSpline::calcIndexAndDelta() { - if (!(index < (int)xs->size() - 1) || !(xs->at(index) <= xvalue) || !(xvalue < xs->at((int)index + 1))) { - searchIndexFromto(0, (int)xs->size()); //Using range. + if (!(index < xs->size() - 1) || !(xs->at(index) <= xvalue) || !(xvalue < xs->at(index + 1))) { + searchIndexFromto(0, xs->size()); //Using range. } delta = xvalue - xs->at(index); } -void MbD::GeneralSpline::searchIndexFromto(int first, int last) +void MbD::GeneralSpline::searchIndexFromto(size_t first, size_t last) { //"Assume xs(first) <= xvalue < xs(last)." if (first + 1 == last) { index = first; } else { - auto middle = (int)std::floor((first + last) / 2); + auto middle = std::floor((first + last) / 2); if (xvalue < xs->at(middle)) { searchIndexFromto(first, middle); } @@ -231,9 +231,9 @@ double MbD::GeneralSpline::y(double xxx) calcIndexAndDeltaFor(xxx); auto& derivsi = derivs->at(index); double sum = 0.0; - for (int j = degree; j >= 1; j--) + for (int j = degree; j >= 1; j--) //Use int because of decrement { - sum = (sum + derivsi->at((int)j - 1)) * delta / j; + sum = (sum + derivsi->at(j - 1)) * delta / j; } return ys->at(index) + sum; } @@ -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 < (int)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 < (int)ys->size(); i++) + for (size_t i = 1; i < ys->size(); i++) { s << ", " << ys->at(i); } diff --git a/OndselSolver/GeneralSpline.h b/OndselSolver/GeneralSpline.h index f8ee03f..c1b0d37 100644 --- a/OndselSolver/GeneralSpline.h +++ b/OndselSolver/GeneralSpline.h @@ -20,22 +20,22 @@ namespace MbD { double getValue() override; Symsptr differentiateWRTx() override; void arguments(Symsptr args) override; - void initxdegreexsys(Symsptr arg, int order, std::shared_ptr> xarr, std::shared_ptr> yarr); + void initxdegreexsys(Symsptr arg, size_t order, std::shared_ptr> xarr, std::shared_ptr> yarr); void computeDerivatives(); bool isCyclic(); - double derivativeAt(int derivativeOrder, double arg); + double derivativeAt(size_t derivativeOrder, double arg); void calcIndexAndDeltaFor(double xxx); void calcCyclicIndexAndDelta(); void calcNonCyclicIndexAndDelta(); void calcIndexAndDelta(); - void searchIndexFromto(int start, int end); + void searchIndexFromto(size_t start, size_t end); Symsptr clonesptr() override; double y(double xxx); std::ostream& printOn(std::ostream& s) const override; FMatDsptr derivs; - int degree = -1, index = -1; + size_t degree = SIZE_MAX, index = SIZE_MAX; double delta = std::numeric_limits::min(); }; } diff --git a/OndselSolver/ICKineIntegrator.cpp b/OndselSolver/ICKineIntegrator.cpp index 47b2002..037b025 100644 --- a/OndselSolver/ICKineIntegrator.cpp +++ b/OndselSolver/ICKineIntegrator.cpp @@ -18,7 +18,7 @@ void ICKineIntegrator::runInitialConditionTypeSolution() system->runAccICKine(); } -void ICKineIntegrator::iStep(int) +void ICKineIntegrator::iStep(size_t) { assert(false); } diff --git a/OndselSolver/ICKineIntegrator.h b/OndselSolver/ICKineIntegrator.h index 8d6a8b5..8502977 100644 --- a/OndselSolver/ICKineIntegrator.h +++ b/OndselSolver/ICKineIntegrator.h @@ -20,7 +20,7 @@ namespace MbD { void subsequentSteps() override; void nextStep() override; void runInitialConditionTypeSolution() override; - void iStep(int i) override; + void iStep(size_t i) override; void selectOrder() override; }; diff --git a/OndselSolver/Integrator.h b/OndselSolver/Integrator.h index 8543618..4ebdc1d 100644 --- a/OndselSolver/Integrator.h +++ b/OndselSolver/Integrator.h @@ -27,7 +27,7 @@ namespace MbD { virtual void preStep() = 0; virtual void postStep() = 0; virtual void runInitialConditionTypeSolution() = 0; - virtual void iStep(int i) = 0; + virtual void iStep(size_t i) = 0; virtual void selectOrder() = 0; double direction = 1; diff --git a/OndselSolver/IntegratorInterface.cpp b/OndselSolver/IntegratorInterface.cpp index 3cb293a..c7727e8 100644 --- a/OndselSolver/IntegratorInterface.cpp +++ b/OndselSolver/IntegratorInterface.cpp @@ -48,7 +48,7 @@ void IntegratorInterface::run() this->postRun(); } -int IntegratorInterface::orderMax() +size_t IntegratorInterface::orderMax() { return system->orderMax; } diff --git a/OndselSolver/IntegratorInterface.h b/OndselSolver/IntegratorInterface.h index 1206b14..a7f33c7 100644 --- a/OndselSolver/IntegratorInterface.h +++ b/OndselSolver/IntegratorInterface.h @@ -26,7 +26,7 @@ namespace MbD { void setSystem(Solver* sys) override; void logString(std::string& str) override; void run() override; - int orderMax(); + size_t orderMax(); virtual void incrementTime(double tnew); void postFirstStep() override; diff --git a/OndselSolver/Item.cpp b/OndselSolver/Item.cpp index 52b7c4b..8f01dc0 100644 --- a/OndselSolver/Item.cpp +++ b/OndselSolver/Item.cpp @@ -97,7 +97,7 @@ void MbD::Item::checkForCollisionDiscontinuityBetweenand(double, double) assert(false); } -void Item::removeRedundantConstraints(std::shared_ptr>) +void Item::removeRedundantConstraints(std::shared_ptr>) { } diff --git a/OndselSolver/Item.h b/OndselSolver/Item.h index 7fff0c0..fc13868 100644 --- a/OndselSolver/Item.h +++ b/OndselSolver/Item.h @@ -128,7 +128,7 @@ namespace MbD { virtual void preVelIC(); virtual void reactivateRedundantConstraints(); virtual void registerName(); - virtual void removeRedundantConstraints(std::shared_ptr> redundantEqnNos); + virtual void removeRedundantConstraints(std::shared_ptr> redundantEqnNos); virtual void setpqsumu(FColDsptr col); virtual void setpqsumuddot(FColDsptr col); virtual void setpqsumudot(FColDsptr col); diff --git a/OndselSolver/Joint.cpp b/OndselSolver/Joint.cpp index 334d207..735a8d5 100644 --- a/OndselSolver/Joint.cpp +++ b/OndselSolver/Joint.cpp @@ -168,9 +168,9 @@ void Joint::fillPosICJacob(SpMatDsptr mat) constraintsDo([&](std::shared_ptr con) { con->fillPosICJacob(mat); }); } -void Joint::removeRedundantConstraints(std::shared_ptr> redundantEqnNos) +void Joint::removeRedundantConstraints(std::shared_ptr> redundantEqnNos) { - for (int i = 0; i < (int)constraints->size(); i++) + for (size_t i = 0; i < constraints->size(); i++) { auto& constraint = constraints->at(i); if (std::find(redundantEqnNos->begin(), redundantEqnNos->end(), constraint->iG) != redundantEqnNos->end()) { @@ -183,7 +183,7 @@ void Joint::removeRedundantConstraints(std::shared_ptr> redunda void Joint::reactivateRedundantConstraints() { - for (int i = 0; i < (int)constraints->size(); i++) + for (size_t i = 0; i < constraints->size(); i++) { auto& con = constraints->at(i); if (con->isRedundant()) { diff --git a/OndselSolver/Joint.h b/OndselSolver/Joint.h index e6281f7..75ea760 100644 --- a/OndselSolver/Joint.h +++ b/OndselSolver/Joint.h @@ -68,7 +68,7 @@ namespace MbD { void prePosKine() override; void preVelIC() override; void reactivateRedundantConstraints() override; - void removeRedundantConstraints(std::shared_ptr> redundantEqnNos) override; + void removeRedundantConstraints(std::shared_ptr> redundantEqnNos) override; void setqsuddotlam(FColDsptr col) override; void setqsudotlam(FColDsptr col) override; void setqsulam(FColDsptr col) override; diff --git a/OndselSolver/KineIntegrator.cpp b/OndselSolver/KineIntegrator.cpp index 98d62a1..072cac1 100644 --- a/OndselSolver/KineIntegrator.cpp +++ b/OndselSolver/KineIntegrator.cpp @@ -42,7 +42,7 @@ void KineIntegrator::runInitialConditionTypeSolution() system->runAccKine(); } -void KineIntegrator::iStep(int) +void KineIntegrator::iStep(size_t) { assert(false); } diff --git a/OndselSolver/KineIntegrator.h b/OndselSolver/KineIntegrator.h index f16d920..fe134dc 100644 --- a/OndselSolver/KineIntegrator.h +++ b/OndselSolver/KineIntegrator.h @@ -20,7 +20,7 @@ namespace MbD { void subsequentSteps() override; void nextStep() override; void runInitialConditionTypeSolution() override; - void iStep(int i) override; + void iStep(size_t i) override; void selectOrder() override; }; } diff --git a/OndselSolver/LDUFullMat.cpp b/OndselSolver/LDUFullMat.cpp index 6789150..b29f5b6 100644 --- a/OndselSolver/LDUFullMat.cpp +++ b/OndselSolver/LDUFullMat.cpp @@ -33,21 +33,21 @@ void LDUFullMat::preSolvewithsaveOriginal(SpMatDsptr, FColDsptr, bool) assert(false); } -void LDUFullMat::forwardEliminateWithPivot(int p) +void LDUFullMat::forwardEliminateWithPivot(size_t p) { //"Save factors in lower triangle for LU decomposition." //| rowp app rowi aip factor | auto& rowp = matrixA->at(p); auto app = rowp->at(p); - for (int i = p + 1; i < m; i++) + for (size_t i = p + 1; i < m; i++) { auto& rowi = matrixA->at(i); auto aip = rowi->at(p); auto factor = aip / app; rowi->at(p) = factor; if (factor != 0) { - for (int j = p + 1; j < n; j++) + for (size_t j = p + 1; j < n; j++) { rowi->atiminusNumber(j, factor * rowp->at(j)); } @@ -72,22 +72,22 @@ void LDUFullMat::preSolvesaveOriginal(FMatDsptr fullMat, bool saveOriginal) m = matrixA->nrow(); n = matrixA->ncol(); pivotValues = std::make_shared>(m); - rowOrder = std::make_shared>(m); - colOrder = std::make_shared>(n); + rowOrder = std::make_shared>(m); + colOrder = std::make_shared>(n); } if (m == n) { - for (int i = 0; i < m; i++) + for (size_t i = 0; i < m; i++) { rowOrder->at(i) = i; colOrder->at(i) = i; } } else { - for (int i = 0; i < m; i++) + for (size_t i = 0; i < m; i++) { rowOrder->at(i) = i; } - for (int j = 0; j < n; j++) + for (size_t j = 0; j < n; j++) { colOrder->at(j) = j; } @@ -98,7 +98,7 @@ void LDUFullMat::preSolvesaveOriginal(FMatDsptr fullMat, bool saveOriginal) void LDUFullMat::decomposesaveOriginal(FMatDsptr fullMat, bool saveOriginal) { this->preSolvesaveOriginal(fullMat, saveOriginal); - for (int p = 0; p < m; p++) + for (size_t p = 0; p < m; p++) { this->doPivoting(p); this->forwardEliminateWithPivot(p); @@ -117,7 +117,7 @@ FMatDsptr LDUFullMat::inversesaveOriginal(FMatDsptr fullMat, bool saveOriginal) this->decomposesaveOriginal(fullMat, saveOriginal); rightHandSideB = std::make_shared>(m); auto matrixAinverse = std::make_shared >(m, n); - for (int j = 0; j < n; j++) + for (size_t j = 0; j < n; j++) { rightHandSideB->zeroSelf(); rightHandSideB->at(j) = 1.0; @@ -127,7 +127,7 @@ FMatDsptr LDUFullMat::inversesaveOriginal(FMatDsptr fullMat, bool saveOriginal) return matrixAinverse; } -double LDUFullMat::getmatrixArowimaxMagnitude(int i) +double LDUFullMat::getmatrixArowimaxMagnitude(size_t i) { return matrixA->at(i)->maxMagnitude(); } @@ -136,11 +136,11 @@ void LDUFullMat::forwardSubstituteIntoL() { //"L is lower triangular with nonzero and ones in diagonal." auto vectorc = std::make_shared>(n); - for (int i = 0; i < n; i++) + for (size_t i = 0; i < n; i++) { auto& rowi = matrixA->at(i); double sum = 0.0; - for (int j = 0; j < i; j++) + for (size_t j = 0; j < i; j++) { sum += rowi->at(j) * vectorc->at(j); } @@ -155,12 +155,12 @@ void LDUFullMat::backSubstituteIntoDU() //| rowi sum | answerX = std::make_shared>(n); - answerX->at((int)n - 1) = rightHandSideB->at((int)m - 1) / matrixA->at((int)m - 1)->at((int)n - 1); - for (int i = n - 2; i >= 0; i--) + answerX->at(n - 1) = rightHandSideB->at(m - 1) / matrixA->at(m - 1)->at(n - 1); + for (int i = n - 2; i >= 0; i--) //Use int because of decrement { auto& rowi = matrixA->at(i); - double sum = answerX->at((int)n - 1) * rowi->at((int)n - 1); - for (int j = i + 1; j < n - 1; j++) + double sum = answerX->at((size_t)n - 1) * rowi->at((size_t)n - 1); + for (size_t j = i + 1; j < n - 1; j++) { sum += answerX->at(j) * rowi->at(j); } diff --git a/OndselSolver/LDUFullMat.h b/OndselSolver/LDUFullMat.h index 5a75d9e..cbeb581 100644 --- a/OndselSolver/LDUFullMat.h +++ b/OndselSolver/LDUFullMat.h @@ -19,14 +19,14 @@ namespace MbD { FColDsptr basicSolvewithsaveOriginal(SpMatDsptr spMat, FColDsptr fullCol, bool saveOriginal) override; void preSolvewithsaveOriginal(FMatDsptr fullMat, FColDsptr fullCol, bool saveOriginal) override; void preSolvewithsaveOriginal(SpMatDsptr spMat, FColDsptr fullCol, bool saveOriginal) override; - void forwardEliminateWithPivot(int p) override; + void forwardEliminateWithPivot(size_t p) override; void postSolve() override; void preSolvesaveOriginal(FMatDsptr fullMat, bool saveOriginal) override; void decomposesaveOriginal(SpMatDsptr spMat, bool saveOriginal); void decomposesaveOriginal(FMatDsptr fullMat, bool saveOriginal); FMatDsptr inversesaveOriginal(FMatDsptr fullMat, bool saveOriginal); - double getmatrixArowimaxMagnitude(int i) override; + double getmatrixArowimaxMagnitude(size_t i) override; void forwardSubstituteIntoL() override; void backSubstituteIntoDU() override; diff --git a/OndselSolver/LDUFullMatParPv.cpp b/OndselSolver/LDUFullMatParPv.cpp index d0ef28c..b61bf4b 100644 --- a/OndselSolver/LDUFullMatParPv.cpp +++ b/OndselSolver/LDUFullMatParPv.cpp @@ -12,7 +12,7 @@ using namespace MbD; -void LDUFullMatParPv::doPivoting(int p) +void LDUFullMatParPv::doPivoting(size_t p) { //"Use scalings. Do row pivoting." @@ -21,7 +21,7 @@ void LDUFullMatParPv::doPivoting(int p) double max = app * rowScalings->at(p); if (max < 0.0) max = -max; auto rowPivot = p; - for (int i = p + 1; i < m; i++) + for (size_t i = p + 1; i < m; i++) { auto aip = matrixA->at(i)->at(p); if (aip != 0.0) { diff --git a/OndselSolver/LDUFullMatParPv.h b/OndselSolver/LDUFullMatParPv.h index 9e11b8b..c1e7486 100644 --- a/OndselSolver/LDUFullMatParPv.h +++ b/OndselSolver/LDUFullMatParPv.h @@ -15,7 +15,7 @@ namespace MbD { { // public: - void doPivoting(int p) override; + void doPivoting(size_t p) override; }; } diff --git a/OndselSolver/LDUSpMat.cpp b/OndselSolver/LDUSpMat.cpp index e88a845..4cb2407 100644 --- a/OndselSolver/LDUSpMat.cpp +++ b/OndselSolver/LDUSpMat.cpp @@ -34,7 +34,7 @@ FColDsptr LDUSpMat::forAndBackSubsaveOriginal(FColDsptr, bool) return FColDsptr(); } -double LDUSpMat::getmatrixArowimaxMagnitude(int i) +double LDUSpMat::getmatrixArowimaxMagnitude(size_t i) { return matrixA->at(i)->maxMagnitude(); } @@ -44,12 +44,12 @@ void LDUSpMat::forwardSubstituteIntoL() //"L is lower triangular with nonzero and ones in diagonal." auto vectorc = std::make_shared>(n); vectorc->at(0) = rightHandSideB->at(0); - for (int i = 1; i < n; i++) + for (size_t i = 1; i < n; i++) { auto rowi = matrixA->at(i); double sum = 0.0; for (auto const& keyValue : *rowi) { - int j = keyValue.first; + size_t j = keyValue.first; double duij = keyValue.second; sum += duij * vectorc->at(j); } @@ -63,13 +63,13 @@ void LDUSpMat::backSubstituteIntoDU() //"DU is upper triangular with nonzero diagonals." double sum, duij; - for (int i = 0; i < m; i++) + for (size_t i = 0; i < m; i++) { rightHandSideB->at(i) = rightHandSideB->at(i) / matrixD->at(i); } answerX = std::make_shared>(m); answerX->at(n - 1) = rightHandSideB->at(m - 1); - for (int i = n - 2; i >= 0; i--) + for (int i = n - 2; i >= 0; i--) //Use int because of decrement { auto rowi = matrixU->at(i); sum = 0.0; diff --git a/OndselSolver/LDUSpMat.h b/OndselSolver/LDUSpMat.h index 5965a24..3507bb1 100644 --- a/OndselSolver/LDUSpMat.h +++ b/OndselSolver/LDUSpMat.h @@ -20,14 +20,14 @@ namespace MbD { void decomposesaveOriginal(FMatDsptr fullMat, bool saveOriginal); void decomposesaveOriginal(SpMatDsptr spMat, bool saveOriginal); FColDsptr forAndBackSubsaveOriginal(FColDsptr fullCol, bool saveOriginal) override; - double getmatrixArowimaxMagnitude(int i) override; + double getmatrixArowimaxMagnitude(size_t i) override; void forwardSubstituteIntoL() override; void backSubstituteIntoDU() override; SpMatDsptr matrixA, matrixL, matrixU; DiagMatDsptr matrixD; - int markowitzPivotRowCount, markowitzPivotColCount; - std::shared_ptr> rowPositionsOfNonZerosInPivotColumn; + size_t markowitzPivotRowCount, markowitzPivotColCount; + std::shared_ptr> rowPositionsOfNonZerosInPivotColumn; }; } diff --git a/OndselSolver/LDUSpMatParPvMarko.cpp b/OndselSolver/LDUSpMatParPvMarko.cpp index 43bf432..bc5692c 100644 --- a/OndselSolver/LDUSpMatParPvMarko.cpp +++ b/OndselSolver/LDUSpMatParPvMarko.cpp @@ -11,14 +11,15 @@ using namespace MbD; -void LDUSpMatParPvMarko::doPivoting(int p) +void LDUSpMatParPvMarko::doPivoting(size_t p) { //"Search from bottom to top." //"Check for singular pivot." //"Do scaling. Do partial pivoting." //"criterion := mag / (2.0d raisedTo: rowiCount)." //| lookForFirstNonZeroInPivotCol i rowi aip criterionMax rowPivoti criterion max | - int i, rowPivoti; + int i; //Use int because of decrement + size_t rowPivoti; double aip, mag, max, criterion, criterionMax; SpRowDsptr spRowi; rowPositionsOfNonZerosInPivotColumn->clear(); @@ -27,7 +28,7 @@ void LDUSpMatParPvMarko::doPivoting(int p) while (lookForFirstNonZeroInPivotCol) { spRowi = matrixA->at(i); if (spRowi->find(p) == spRowi->end()) { - if (i <= p) throwSingularMatrixError(""); + if (i <= (int)p) throwSingularMatrixError(""); //Use int because i can be negative } else { markowitzPivotColCount = 0; @@ -36,12 +37,12 @@ void LDUSpMatParPvMarko::doPivoting(int p) if (mag < 0) mag = -mag; max = mag; criterionMax = mag / std::pow(2.0, spRowi->size()); - rowPivoti = i; + rowPivoti = (size_t)i; lookForFirstNonZeroInPivotCol = false; } i--; } - while (i >= p) { + while (i >= (int)p) { //Use int because i can be negative spRowi = matrixA->at(i); if (spRowi->find(p) == spRowi->end()) { aip = std::numeric_limits::min(); @@ -56,7 +57,7 @@ void LDUSpMatParPvMarko::doPivoting(int p) max = mag; criterionMax = criterion; rowPositionsOfNonZerosInPivotColumn->push_back(rowPivoti); - rowPivoti = i; + rowPivoti = (size_t)i; } else { rowPositionsOfNonZerosInPivotColumn->push_back(i); diff --git a/OndselSolver/LDUSpMatParPvMarko.h b/OndselSolver/LDUSpMatParPvMarko.h index 2505f3a..ef66373 100644 --- a/OndselSolver/LDUSpMatParPvMarko.h +++ b/OndselSolver/LDUSpMatParPvMarko.h @@ -15,7 +15,7 @@ namespace MbD { { // public: - void doPivoting(int p) override; + void doPivoting(size_t p) override; }; } diff --git a/OndselSolver/LDUSpMatParPvPrecise.cpp b/OndselSolver/LDUSpMatParPvPrecise.cpp index 7cc4ae4..c3ae451 100644 --- a/OndselSolver/LDUSpMatParPvPrecise.cpp +++ b/OndselSolver/LDUSpMatParPvPrecise.cpp @@ -11,14 +11,15 @@ using namespace MbD; -void LDUSpMatParPvPrecise::doPivoting(int p) +void LDUSpMatParPvPrecise::doPivoting(size_t p) { //"Search from bottom to top." //"Use scaling vector and partial pivoting with actual swapping of rows." //"Check for singular pivot." //"Do scaling. Do partial pivoting." //| max rowPivot aip mag lookForFirstNonZeroInPivotCol i | - int i, rowPivoti; + int i; //Use int because of decrement + size_t rowPivoti; double aip, mag, max; SpRowDsptr spRowi; rowPositionsOfNonZerosInPivotColumn->clear(); @@ -27,7 +28,7 @@ void LDUSpMatParPvPrecise::doPivoting(int p) while (lookForFirstNonZeroInPivotCol) { spRowi = matrixA->at(i); if (spRowi->find(p) == spRowi->end()) { - if (i <= p) throwSingularMatrixError(""); + if (i <= (int)p) throwSingularMatrixError(""); //Use int because i can be negative } else { markowitzPivotColCount = 0; @@ -35,12 +36,12 @@ void LDUSpMatParPvPrecise::doPivoting(int p) mag = aip * rowScalings->at(i); if (mag < 0) mag = -mag; max = mag; - rowPivoti = i; + rowPivoti = (size_t)i; lookForFirstNonZeroInPivotCol = false; } i--; } - while (i >= p) { + while (i >= (int)p) { //Use int because i can be negative spRowi = matrixA->at(i); if (spRowi->find(p) == spRowi->end()) { aip = std::numeric_limits::min(); @@ -53,7 +54,7 @@ void LDUSpMatParPvPrecise::doPivoting(int p) if (mag > max) { max = mag; rowPositionsOfNonZerosInPivotColumn->push_back(rowPivoti); - rowPivoti = i; + rowPivoti = (size_t)i; } else { rowPositionsOfNonZerosInPivotColumn->push_back(i); @@ -66,7 +67,7 @@ void LDUSpMatParPvPrecise::doPivoting(int p) rowScalings->swapElems(p, rowPivoti); rowOrder->swapElems(p, rowPivoti); matrixL->swapElems(p, rowPivoti); - if (aip != std::numeric_limits::min()) rowPositionsOfNonZerosInPivotColumn->at((int)markowitzPivotColCount - 1) = rowPivoti; + if (aip != std::numeric_limits::min()) rowPositionsOfNonZerosInPivotColumn->at(markowitzPivotColCount - 1) = rowPivoti; } pivotValues->at(p) = max; if (max < singularPivotTolerance) throwSingularMatrixError(""); diff --git a/OndselSolver/LDUSpMatParPvPrecise.h b/OndselSolver/LDUSpMatParPvPrecise.h index 51811d6..0213a83 100644 --- a/OndselSolver/LDUSpMatParPvPrecise.h +++ b/OndselSolver/LDUSpMatParPvPrecise.h @@ -15,7 +15,7 @@ namespace MbD { { // public: - void doPivoting(int p) override; + void doPivoting(size_t p) override; }; } diff --git a/OndselSolver/LinearMultiStepMethod.cpp b/OndselSolver/LinearMultiStepMethod.cpp index d1e8691..44b0efd 100644 --- a/OndselSolver/LinearMultiStepMethod.cpp +++ b/OndselSolver/LinearMultiStepMethod.cpp @@ -11,7 +11,7 @@ using namespace MbD; -FColDsptr MbD::LinearMultiStepMethod::derivativeatpresentpast(int n, double t, FColDsptr y, std::shared_ptr> ypast) +FColDsptr MbD::LinearMultiStepMethod::derivativeatpresentpast(size_t n, double t, FColDsptr y, std::shared_ptr> ypast) { //"Interpolate or extrapolate." //"dfdt(t) = df0dt + d2f0dt2*(t - t0) + d3f0dt3*(t - t0)^2 / 2! + ..." @@ -20,17 +20,17 @@ FColDsptr MbD::LinearMultiStepMethod::derivativeatpresentpast(int n, double t, F if (t != time) { auto dt = t - time; auto dtpower = 1.0; - for (int i = n + 1; i <= order; i++) + for (size_t i = n + 1; i <= order; i++) { auto diydti = this->derivativepresentpast(i, y, ypast); dtpower = dtpower * dt; - answer->equalSelfPlusFullColumntimes(diydti, dtpower * (OneOverFactorials->at((int)i - n))); + answer->equalSelfPlusFullColumntimes(diydti, dtpower * (OneOverFactorials->at(i - n))); } } return answer; } -FColDsptr MbD::LinearMultiStepMethod::derivativepresentpast(int, FColDsptr, std::shared_ptr>) +FColDsptr MbD::LinearMultiStepMethod::derivativepresentpast(size_t, FColDsptr, std::shared_ptr>) { assert(false); return FColDsptr(); @@ -47,7 +47,7 @@ double MbD::LinearMultiStepMethod::firstPastTimeNode() return timeNodes->at(0); } -FColDsptr MbD::LinearMultiStepMethod::derivativepresentpastpresentDerivativepastDerivative(int, +FColDsptr MbD::LinearMultiStepMethod::derivativepresentpastpresentDerivativepastDerivative(size_t, FColDsptr, std::shared_ptr>, FColDsptr, std::shared_ptr>) { diff --git a/OndselSolver/LinearMultiStepMethod.h b/OndselSolver/LinearMultiStepMethod.h index f34ed83..3286142 100644 --- a/OndselSolver/LinearMultiStepMethod.h +++ b/OndselSolver/LinearMultiStepMethod.h @@ -15,11 +15,11 @@ namespace MbD { { // public: - FColDsptr derivativeatpresentpast(int n, double t, FColDsptr y, std::shared_ptr> ypast); - virtual FColDsptr derivativepresentpast(int order, FColDsptr y, std::shared_ptr> ypast); + FColDsptr derivativeatpresentpast(size_t n, double t, FColDsptr y, std::shared_ptr> ypast); + virtual FColDsptr derivativepresentpast(size_t order, FColDsptr y, std::shared_ptr> ypast); virtual double pvdotpv(); double firstPastTimeNode(); - virtual FColDsptr derivativepresentpastpresentDerivativepastDerivative(int n, + virtual FColDsptr derivativepresentpastpresentDerivativepastDerivative(size_t n, FColDsptr y, std::shared_ptr> ypast, FColDsptr ydot, std::shared_ptr> ydotpast); diff --git a/OndselSolver/MBDynBody.cpp b/OndselSolver/MBDynBody.cpp index cfbf8f5..76182ed 100644 --- a/OndselSolver/MBDynBody.cpp +++ b/OndselSolver/MBDynBody.cpp @@ -48,7 +48,7 @@ void MbD::MBDynBody::readInertiaMatrix(std::vector& args) auto str = args.at(0); //Must copy string if (str.find("diag") != std::string::npos) { args.erase(args.begin()); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto userFunc = std::make_shared(popOffTop(args), 1.0); parser->parseUserFunction(userFunc); diff --git a/OndselSolver/MBDynControlData.h b/OndselSolver/MBDynControlData.h index 493c375..8209b52 100644 --- a/OndselSolver/MBDynControlData.h +++ b/OndselSolver/MBDynControlData.h @@ -25,11 +25,11 @@ namespace MbD { void readJoints(std::vector& lines); void readGravity(std::vector& lines); - int maxIterations = 1000; + size_t maxIterations = 1000; std::string defaultOrientation = "euler321"; std::string omegaRotates = "no"; std::string print = "none"; std::string initialStiffness = "1.0, 1.0"; - int structuralNodes = -1, rigidBodies = -1, joints = -1; + size_t structuralNodes = SIZE_MAX, rigidBodies = SIZE_MAX, joints = SIZE_MAX; }; } diff --git a/OndselSolver/MBDynInitialValue.h b/OndselSolver/MBDynInitialValue.h index 8c1a4c4..cb88665 100644 --- a/OndselSolver/MBDynInitialValue.h +++ b/OndselSolver/MBDynInitialValue.h @@ -26,9 +26,9 @@ namespace MbD { void createASMT() override; double initialTime = 0.0, finalTime = 5.0, timeStep = 1.0e-2, tolerance = 1.0e-6; - int maxIterations = 10; + size_t maxIterations = 10; double derivativesTolerance = 1.0e-4; - int derivativesMaxIterations = 100; + size_t derivativesMaxIterations = 100; std::string derivativesCoefficient = "auto"; }; } diff --git a/OndselSolver/MBDynItem.cpp b/OndselSolver/MBDynItem.cpp index 1f3964b..939c651 100644 --- a/OndselSolver/MBDynItem.cpp +++ b/OndselSolver/MBDynItem.cpp @@ -194,7 +194,7 @@ FColDsptr MbD::MBDynItem::readVector3(std::vector& args) args.erase(args.begin()); } else { - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto userFunc = std::make_shared(popOffTop(args), 1.0); parser->parseUserFunction(userFunc); @@ -286,8 +286,8 @@ FMatDsptr MbD::MBDynItem::readBasicOrientation(std::vector& args) if (str.find("euler") != std::string::npos) { args.erase(args.begin()); auto euler = std::make_shared>(); - euler->rotOrder = std::make_shared>(std::initializer_list{ 1, 2, 3 }); - for (int i = 0; i < 3; i++) + euler->rotOrder = std::make_shared>(std::initializer_list{ 1, 2, 3 }); + for (size_t i = 0; i < 3; i++) { auto userFunc = std::make_shared(popOffTop(args), 1.0); parser->parseUserFunction(userFunc); @@ -317,8 +317,8 @@ FMatDsptr MbD::MBDynItem::readBasicOrientation(std::vector& args) args.erase(args.begin()); double min = std::numeric_limits::max(); double max = -1.0; - int imin, imax; - for (int i = 0; i < 3; i++) + size_t imin, imax; + for (size_t i = 0; i < 3; i++) { auto mag = std::abs(vecX->at(i)); if (mag > max) { @@ -366,8 +366,8 @@ FMatDsptr MbD::MBDynItem::readBasicOrientation(std::vector& args) args.erase(args.begin()); double min = std::numeric_limits::max(); double max = -1.0; - int imin, imax; - for (int i = 0; i < 3; i++) + size_t imin, imax; + for (size_t i = 0; i < 3; i++) { auto mag = std::abs(vecZ->at(i)); if (mag > max) { @@ -405,10 +405,10 @@ FMatDsptr MbD::MBDynItem::readBasicOrientation(std::vector& args) return aAFf; } auto aAFf = FullMatrix::identitysptr(3); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto& rowi = aAFf->at(i); - for (int j = 0; j < 3; j++) + for (size_t j = 0; j < 3; j++) { auto userFunc = std::make_shared(popOffTop(args), 1.0); parser->parseUserFunction(userFunc); diff --git a/OndselSolver/MBDynNode.cpp b/OndselSolver/MBDynNode.cpp index f75302d..2fc2a71 100644 --- a/OndselSolver/MBDynNode.cpp +++ b/OndselSolver/MBDynNode.cpp @@ -13,7 +13,7 @@ void MbD::MBDynNode::parseMBDyn(std::vector&) assert(false); } -void MbD::MBDynNode::outputLine(int i, std::ostream& os) +void MbD::MBDynNode::outputLine(size_t i, std::ostream& os) { auto id = nodeidAt(name); auto asmtPart = std::static_pointer_cast(asmtItem); diff --git a/OndselSolver/MBDynNode.h b/OndselSolver/MBDynNode.h index 7842820..65c4b63 100644 --- a/OndselSolver/MBDynNode.h +++ b/OndselSolver/MBDynNode.h @@ -15,7 +15,7 @@ namespace MbD { public: void initialize() override; void parseMBDyn(std::vector& lines) override; - void outputLine(int i, std::ostream& os); + void outputLine(size_t i, std::ostream& os); }; } diff --git a/OndselSolver/MBDynReference.cpp b/OndselSolver/MBDynReference.cpp index 0162a5d..419b12f 100644 --- a/OndselSolver/MBDynReference.cpp +++ b/OndselSolver/MBDynReference.cpp @@ -34,7 +34,7 @@ void MbD::MBDynReference::readVelocity(std::vector& args) return; } else { - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto userFunc = std::make_shared(popOffTop(args), 1.0); parser->parseUserFunction(userFunc); @@ -55,7 +55,7 @@ void MbD::MBDynReference::readOmega(std::vector& args) return; } else { - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto userFunc = std::make_shared(popOffTop(args), 1.0); parser->parseUserFunction(userFunc); diff --git a/OndselSolver/MBDynStructural.cpp b/OndselSolver/MBDynStructural.cpp index c1c8a94..64a0564 100644 --- a/OndselSolver/MBDynStructural.cpp +++ b/OndselSolver/MBDynStructural.cpp @@ -45,7 +45,7 @@ void MbD::MBDynStructural::readVelocity(std::vector& args) return; } else { - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto userFunc = std::make_shared(popOffTop(args), 1.0); parser->parseUserFunction(userFunc); @@ -66,7 +66,7 @@ void MbD::MBDynStructural::readOmega(std::vector& args) return; } else { - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto userFunc = std::make_shared(popOffTop(args), 1.0); parser->parseUserFunction(userFunc); diff --git a/OndselSolver/MBDynSystem.cpp b/OndselSolver/MBDynSystem.cpp index ec20d9c..b4de09d 100644 --- a/OndselSolver/MBDynSystem.cpp +++ b/OndselSolver/MBDynSystem.cpp @@ -154,7 +154,7 @@ void MbD::MBDynSystem::outputFiles() //auto& asmtMotions = asmtAsm->motions; std::ofstream os(movFile); os << std::setprecision(static_cast(std::numeric_limits::digits10) + 1); - for (int i = 1; i < (int)asmtTimes->size(); i++) + for (size_t i = 1; i < asmtTimes->size(); i++) { for (auto& node : *nodes) { node->outputLine(i, os); @@ -248,7 +248,7 @@ void MbD::MBDynSystem::readElementsBlock(std::vector& lines) void MbD::MBDynSystem::eraseComments(std::vector& lines) { - for (int i = 0; i < (int)lines.size(); i++) + for (size_t i = 0; i < lines.size(); i++) { auto& line = lines[i]; auto it = line.find('#'); @@ -256,7 +256,8 @@ void MbD::MBDynSystem::eraseComments(std::vector& lines) lines[i] = line.substr(0, it); } } - for (int i = (int)lines.size() - 1; i >= 0; i--) { + for (int i = (int)lines.size() - 1; i >= 0; i--) //Use int because of decrement + { auto& line = lines[i]; auto it = std::find_if(line.begin(), line.end(), [](unsigned char ch) { return !std::isspace(ch); }); if (it == line.end()) lines.erase(lines.begin() + i); diff --git a/OndselSolver/MBDynTotalJoint.cpp b/OndselSolver/MBDynTotalJoint.cpp index 2b8884f..534f05f 100644 --- a/OndselSolver/MBDynTotalJoint.cpp +++ b/OndselSolver/MBDynTotalJoint.cpp @@ -115,7 +115,7 @@ void MbD::MBDynTotalJoint::createASMT() asmtMotion->setMarkerI(mkr1->asmtItem->fullName("")); asmtMotion->setMarkerJ(mkr2->asmtItem->fullName("")); asmtAsm->addMotion(asmtMotion); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { asmtMotion->rIJI->atiput(i, asmtFormula(positionFormulas.at(i))); asmtMotion->angIJJ->atiput(i, asmtFormula(orientationFormulas.at(i))); diff --git a/OndselSolver/MarkerFrame.cpp b/OndselSolver/MarkerFrame.cpp index ac20528..ad39e72 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 < (int)endFrames->size(); i++) + for (size_t i = 0; i < endFrames->size(); i++) { auto eFrmqc = std::dynamic_pointer_cast(endFrames->at(i)); if (eFrmqc) { @@ -72,7 +72,7 @@ void MarkerFrame::calcPostDynCorrectorIteration() rOmO = rOpO->plusFullColumn(aAOp->timesFullColumn(rpmp)); aAOm = aAOp->timesFullMatrix(aApm); auto pAOppE = partFrame->pAOppE(); - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto& pAOppEi = pAOppE->at(i); prOmOpE->atijputFullColumn(0, i, pAOppEi->timesFullColumn(rpmp)); @@ -86,12 +86,12 @@ void MarkerFrame::prePosIC() endFramesDo([](EndFrmsptr endFrame) { endFrame->prePosIC(); }); } -int MarkerFrame::iqX() +size_t MarkerFrame::iqX() { return partFrame->iqX; } -int MarkerFrame::iqE() +size_t MarkerFrame::iqE() { return partFrame->iqE; } diff --git a/OndselSolver/MarkerFrame.h b/OndselSolver/MarkerFrame.h index 5ee8cea..9b253a6 100644 --- a/OndselSolver/MarkerFrame.h +++ b/OndselSolver/MarkerFrame.h @@ -39,8 +39,8 @@ namespace MbD { void initializeLocally() override; void initializeGlobally() override; void calcPostDynCorrectorIteration() override; - int iqX(); - int iqE(); + size_t iqX(); + size_t iqE(); void endFramesDo(const std::function & f); void fillqsu(FColDsptr col) override; void fillqsuWeights(DiagMatDsptr diagMat) override; diff --git a/OndselSolver/MatrixDecomposition.cpp b/OndselSolver/MatrixDecomposition.cpp index 6695794..2c8ca5c 100644 --- a/OndselSolver/MatrixDecomposition.cpp +++ b/OndselSolver/MatrixDecomposition.cpp @@ -19,7 +19,7 @@ FColDsptr MbD::MatrixDecomposition::forAndBackSubsaveOriginal(FColDsptr, bool) void MatrixDecomposition::applyRowOrderOnRightHandSideB() { FColDsptr answer = std::make_shared>(m); - for (int i = 0; i < m; i++) + for (size_t i = 0; i < m; i++) { answer->at(i) = rightHandSideB->at(rowOrder->at(i)); } diff --git a/OndselSolver/MatrixGaussElimination.h b/OndselSolver/MatrixGaussElimination.h index 1e15d37..d0dc743 100644 --- a/OndselSolver/MatrixGaussElimination.h +++ b/OndselSolver/MatrixGaussElimination.h @@ -16,7 +16,7 @@ namespace MbD { { // public: - virtual void forwardEliminateWithPivot(int p) = 0; + virtual void forwardEliminateWithPivot(size_t p) = 0; }; } diff --git a/OndselSolver/MatrixSolver.cpp b/OndselSolver/MatrixSolver.cpp index f7ceccc..f21b560 100644 --- a/OndselSolver/MatrixSolver.cpp +++ b/OndselSolver/MatrixSolver.cpp @@ -58,11 +58,11 @@ FColDsptr MatrixSolver::timedSolvewithsaveOriginal(FMatDsptr, FColDsptr, bool) return FColDsptr(); } -void MatrixSolver::findScalingsForRowRange(int begin, int end) +void MatrixSolver::findScalingsForRowRange(size_t begin, size_t end) { //"Row element * scaling <= 1.0." rowScalings = std::make_shared>(m); - for (int i = begin; i < end; i++) + for (size_t i = begin; i < end; i++) { double maxRowMagnitude = this->getmatrixArowimaxMagnitude(i); if (maxRowMagnitude == 0.0) throwSingularMatrixError(""); @@ -75,7 +75,7 @@ void MatrixSolver::throwSingularMatrixError(const char* chars) throw SingularMatrixError(chars); } -void MatrixSolver::throwSingularMatrixError(const char* chars, std::shared_ptr> redunEqnNos) +void MatrixSolver::throwSingularMatrixError(const char* chars, std::shared_ptr> redunEqnNos) { throw SingularMatrixError(chars, redunEqnNos); } diff --git a/OndselSolver/MatrixSolver.h b/OndselSolver/MatrixSolver.h index a1486b9..0bb99fa 100644 --- a/OndselSolver/MatrixSolver.h +++ b/OndselSolver/MatrixSolver.h @@ -31,20 +31,20 @@ namespace MbD { 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(int p) = 0; - virtual void forwardEliminateWithPivot(int p) = 0; + virtual void doPivoting(size_t p) = 0; + virtual void forwardEliminateWithPivot(size_t p) = 0; virtual void backSubstituteIntoDU() = 0; virtual void postSolve() = 0; - virtual void findScalingsForRowRange(int begin, int end); - virtual double getmatrixArowimaxMagnitude(int i) = 0; + virtual void findScalingsForRowRange(size_t begin, size_t end); + virtual double getmatrixArowimaxMagnitude(size_t i) = 0; void throwSingularMatrixError(const char* chars); - void throwSingularMatrixError(const char* chars, std::shared_ptr> redunEqnNos); + void throwSingularMatrixError(const char* chars, std::shared_ptr> redunEqnNos); - int m = 0, n = 0; + size_t m = 0, n = 0; FColDsptr answerX, rightHandSideB, rowScalings, pivotValues; - std::shared_ptr> rowOrder; - std::shared_ptr> colOrder; + std::shared_ptr> rowOrder; + std::shared_ptr> colOrder; double singularPivotTolerance = 0, millisecondsToRun = 0; }; } diff --git a/OndselSolver/MomentOfInertiaSolver.cpp b/OndselSolver/MomentOfInertiaSolver.cpp index ad92789..b887616 100644 --- a/OndselSolver/MomentOfInertiaSolver.cpp +++ b/OndselSolver/MomentOfInertiaSolver.cpp @@ -41,15 +41,15 @@ void MbD::MomentOfInertiaSolver::example1() std::cout << *solver->getAPp() << std::endl; } -void MbD::MomentOfInertiaSolver::doFullPivoting(int p) +void MbD::MomentOfInertiaSolver::doFullPivoting(size_t p) { double max = 0.0; auto pivotRow = p; auto pivotCol = p; - for (int i = p; i < 3; i++) + for (size_t i = p; i < 3; i++) { auto rowi = aJcmPcopy->at(i); - for (int j = p; j < 3; j++) + for (size_t j = p; j < 3; j++) { auto aij = rowi->at(j); if (aij != 0.0) { @@ -72,18 +72,18 @@ void MbD::MomentOfInertiaSolver::doFullPivoting(int p) } } -void MbD::MomentOfInertiaSolver::forwardEliminateWithPivot(int p) +void MbD::MomentOfInertiaSolver::forwardEliminateWithPivot(size_t p) { auto rowp = aJcmPcopy->at(p); auto app = rowp->at(p); - for (int i = p + 1; i < 3; i++) + for (size_t i = p + 1; i < 3; i++) { auto rowi = aJcmPcopy->at(i); auto aip = rowi->at(p); if (aip != 0) { rowi->atiput(p, 0.0); auto factor = aip / app; - for (int j = p + 1; j < 3; j++) + for (size_t j = p + 1; j < 3; j++) { rowi->atiminusNumber(j, factor * rowp->at(j)); } @@ -117,12 +117,12 @@ void MbD::MomentOfInertiaSolver::preSolvewithsaveOriginal(SpMatDsptr, FColDsptr, { } -double MbD::MomentOfInertiaSolver::getmatrixArowimaxMagnitude(int) +double MbD::MomentOfInertiaSolver::getmatrixArowimaxMagnitude(size_t) { return 0.0; } -void MbD::MomentOfInertiaSolver::doPivoting(int) +void MbD::MomentOfInertiaSolver::doPivoting(size_t) { } @@ -250,14 +250,14 @@ FColDsptr MbD::MomentOfInertiaSolver::eigenvectorFor(double lam) double e0, e1, e2; aJcmPcopy = aJcmP->copy(); - colOrder = std::make_shared>(3); + colOrder = std::make_shared>(3); auto eigenvector = std::make_shared>(3); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { colOrder->atiput(i, i); aJcmPcopy->atijminusNumber(i, i, lam); } - for (int p = 0; p < 3; p++) + for (size_t p = 0; p < 3; p++) { doFullPivoting(p); forwardEliminateWithPivot(p); @@ -283,7 +283,7 @@ FColDsptr MbD::MomentOfInertiaSolver::eigenvectorFor(double lam) auto dum = std::make_shared>(ListD{ e0, e1, e2 }); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { eigenvector->atiput(colOrder->at(i), dum->at(i)); } diff --git a/OndselSolver/MomentOfInertiaSolver.h b/OndselSolver/MomentOfInertiaSolver.h index daa0925..755b6ff 100644 --- a/OndselSolver/MomentOfInertiaSolver.h +++ b/OndselSolver/MomentOfInertiaSolver.h @@ -18,16 +18,16 @@ namespace MbD { //aJoo == aJpp when rPoP == rPcmP and aAPo == aAPp public: static void example1(); - void doFullPivoting(int p); - void forwardEliminateWithPivot(int p) override; + void doFullPivoting(size_t p); + void forwardEliminateWithPivot(size_t p) override; void backSubstituteIntoDU() override; void postSolve() override; FColDsptr basicSolvewithsaveOriginal(FMatDsptr fullMat, FColDsptr fullCol, bool saveOriginal) override; FColDsptr basicSolvewithsaveOriginal(SpMatDsptr spMat, FColDsptr fullCol, bool saveOriginal) override; void preSolvewithsaveOriginal(FMatDsptr fullMat, FColDsptr fullCol, bool saveOriginal) override; void preSolvewithsaveOriginal(SpMatDsptr spMat, FColDsptr fullCol, bool saveOriginal) override; - double getmatrixArowimaxMagnitude(int i) override; - void doPivoting(int p) override; + double getmatrixArowimaxMagnitude(size_t i) override; + void doPivoting(size_t p) override; void setm(double mass); void setJPP(FMatDsptr mat); @@ -51,7 +51,7 @@ namespace MbD { FMatDsptr aJPP, aJoo, aAPo, aJcmP, aJcmPcopy, aAPp; FColDsptr rPoP, rPcmP; DiagMatDsptr aJpp; - std::shared_ptr> colOrder; + std::shared_ptr> colOrder; }; } diff --git a/OndselSolver/NewtonRaphson.cpp b/OndselSolver/NewtonRaphson.cpp index 8be628a..3175c8b 100644 --- a/OndselSolver/NewtonRaphson.cpp +++ b/OndselSolver/NewtonRaphson.cpp @@ -28,9 +28,9 @@ void NewtonRaphson::initialize() void NewtonRaphson::initializeLocally() { - iterNo = -1; - nDivergence = -1; - nBackTracking = -1; + iterNo = SIZE_MAX; + nDivergence = SIZE_MAX; + nBackTracking = SIZE_MAX; dxNorms->clear(); yNorms->clear(); yNormOld = std::numeric_limits::max(); @@ -64,7 +64,7 @@ void NewtonRaphson::iterate() // zero. // " - iterNo = -1; + iterNo = SIZE_MAX; this->fillY(); this->calcyNorm(); yNorms->push_back(yNorm); @@ -84,7 +84,7 @@ void NewtonRaphson::iterate() void NewtonRaphson::incrementIterNo() { iterNo++; - if (iterNo >= iterMax) { + if (iterNo > iterMax) { this->reportStats(); throw MaximumIterationError(""); } diff --git a/OndselSolver/NewtonRaphson.h b/OndselSolver/NewtonRaphson.h index cdbc545..9d9fb19 100644 --- a/OndselSolver/NewtonRaphson.h +++ b/OndselSolver/NewtonRaphson.h @@ -48,7 +48,7 @@ namespace MbD { SystemSolver* system = nullptr; //Use raw pointer when pointing backwards. std::shared_ptr> dxNorms, yNorms; double dxNorm = 0.0, yNorm = 0.0, yNormOld = 0.0, yNormTol = 0.0, dxTol = 0.0, twoAlp = 0.0, lam = 0.0; - int iterNo = -1, iterMax = -1, nDivergence = -1, nBackTracking = -1; + size_t iterNo = SIZE_MAX, iterMax = SIZE_MAX, nDivergence = SIZE_MAX, nBackTracking = SIZE_MAX; }; } diff --git a/OndselSolver/Numeric.h b/OndselSolver/Numeric.h index 6068d09..f1d6382 100644 --- a/OndselSolver/Numeric.h +++ b/OndselSolver/Numeric.h @@ -8,6 +8,7 @@ #pragma once #include +#include #include "MbDMath.h" @@ -27,7 +28,7 @@ namespace MbD { { T previous, next; next = vec->at(0); - for (int i = 1; i < (int)vec->size(); i++) + for (size_t i = 1; i < vec->size(); i++) { previous = next; next = vec->at(i); diff --git a/OndselSolver/OndselSolver.vcxproj b/OndselSolver/OndselSolver.vcxproj index fc475b7..de7b322 100644 --- a/OndselSolver/OndselSolver.vcxproj +++ b/OndselSolver/OndselSolver.vcxproj @@ -141,6 +141,8 @@ + + @@ -152,6 +154,7 @@ + @@ -466,6 +469,8 @@ + + @@ -477,6 +482,7 @@ + diff --git a/OndselSolver/OndselSolver.vcxproj.filters b/OndselSolver/OndselSolver.vcxproj.filters index 8f63dfa..2582775 100644 --- a/OndselSolver/OndselSolver.vcxproj.filters +++ b/OndselSolver/OndselSolver.vcxproj.filters @@ -984,6 +984,15 @@ Source Files + + Source Files + + + Source Files + + + Source Files + @@ -1961,6 +1970,15 @@ Header Files + + Header Files + + + Header Files + + + Header Files + diff --git a/OndselSolver/OrbitAngleZIeqcJec.cpp b/OndselSolver/OrbitAngleZIeqcJec.cpp index 1dd5298..f33cca4 100644 --- a/OndselSolver/OrbitAngleZIeqcJec.cpp +++ b/OndselSolver/OrbitAngleZIeqcJec.cpp @@ -26,14 +26,14 @@ void MbD::OrbitAngleZIeqcJec::calc_ppthezpEIpEI() auto pypEI = yIeJeIe->pvaluepEI(); auto ppxpEIpEI = xIeJeIe->ppvaluepEIpEI(); auto ppypEIpEI = yIeJeIe->ppvaluepEIpEI(); - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto ppthezpEIpEIi = ppthezpEIpEI->at(i); auto ppxpEIpEIi = ppxpEIpEI->at(i); auto ppypEIpEIi = ppypEIpEI->at(i); auto pxpEIi = pxpEI->at(i); auto pypEIi = pypEI->at(i); - for (int j = i; j < 4; j++) + for (size_t j = i; j < 4; j++) { auto pxpEIj = pxpEI->at(j); auto pypEIj = pypEI->at(j); @@ -55,14 +55,14 @@ void MbD::OrbitAngleZIeqcJec::calc_ppthezpXIpEI() auto pypEI = yIeJeIe->pvaluepEI(); auto ppxpXIpEI = xIeJeIe->ppvaluepXIpEI(); auto ppypXIpEI = yIeJeIe->ppvaluepXIpEI(); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto ppthezpXIpEIi = ppthezpXIpEI->at(i); auto ppxpXIpEIi = ppxpXIpEI->at(i); auto ppypXIpEIi = ppypXIpEI->at(i); auto pxpXIi = pxpXI->at(i); auto pypXIi = pypXI->at(i); - for (int j = 0; j < 4; j++) + for (size_t j = 0; j < 4; j++) { auto pxpEIj = pxpEI->at(j); auto pypEIj = pypEI->at(j); @@ -81,12 +81,12 @@ void MbD::OrbitAngleZIeqcJec::calc_ppthezpXIpXI() auto pxpXI = xIeJeIe->pvaluepXI(); auto pypXI = yIeJeIe->pvaluepXI(); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto ppthezpXIpXIi = ppthezpXIpXI->at(i); auto pxpXIi = pxpXI->at(i); auto pypXIi = pypXI->at(i); - for (int j = 0; j < 3; j++) + for (size_t j = 0; j < 3; j++) { auto pxpXIj = pxpXI->at(j); auto pypXIj = pypXI->at(j); @@ -101,7 +101,7 @@ void MbD::OrbitAngleZIeqcJec::calc_pthezpEI() { auto pxpEI = xIeJeIe->pvaluepEI(); auto pypEI = yIeJeIe->pvaluepEI(); - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { pthezpEI->atiput(i, pypEI->at(i) * cosOverSSq - (pxpEI->at(i) * sinOverSSq)); } @@ -111,7 +111,7 @@ void MbD::OrbitAngleZIeqcJec::calc_pthezpXI() { auto pxpXI = xIeJeIe->pvaluepXI(); auto pypXI = yIeJeIe->pvaluepXI(); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { pthezpXI->atiput(i, pypXI->at(i) * cosOverSSq - (pxpXI->at(i) * sinOverSSq)); } diff --git a/OndselSolver/OrbitAngleZIeqcJeqc.cpp b/OndselSolver/OrbitAngleZIeqcJeqc.cpp index 79709c6..17a39a8 100644 --- a/OndselSolver/OrbitAngleZIeqcJeqc.cpp +++ b/OndselSolver/OrbitAngleZIeqcJeqc.cpp @@ -28,14 +28,14 @@ void MbD::OrbitAngleZIeqcJeqc::calc_ppthezpEIpEJ() auto pypEJ = yIeJeIe->pvaluepEJ(); auto ppxpEIpEJ = xIeJeIe->ppvaluepEIpEJ(); auto ppypEIpEJ = yIeJeIe->ppvaluepEIpEJ(); - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto ppthezpEIpEJi = ppthezpEIpEJ->at(i); auto ppxpEIpEJi = ppxpEIpEJ->at(i); auto ppypEIpEJi = ppypEIpEJ->at(i); auto pxpEIi = pxpEI->at(i); auto pypEIi = pypEI->at(i); - for (int j = 0; j < 4; j++) + for (size_t j = 0; j < 4; j++) { auto pxpEJj = pxpEJ->at(j); auto pypEJj = pypEJ->at(j); @@ -56,12 +56,12 @@ void MbD::OrbitAngleZIeqcJeqc::calc_ppthezpEIpXJ() auto pypEI = yIeJeIe->pvaluepEI(); auto pxpXJ = xIeJeIe->pvaluepXJ(); auto pypXJ = yIeJeIe->pvaluepXJ(); - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto ppthezpEIpXJi = ppthezpEIpXJ->at(i); auto pxpEIi = pxpEI->at(i); auto pypEIi = pypEI->at(i); - for (int j = 0; j < 3; j++) + for (size_t j = 0; j < 3; j++) { auto pxpXJj = pxpXJ->at(j); auto pypXJj = pypXJ->at(j); @@ -78,14 +78,14 @@ void MbD::OrbitAngleZIeqcJeqc::calc_ppthezpEJpEJ() auto pypEJ = yIeJeIe->pvaluepEJ(); auto ppxpEJpEJ = xIeJeIe->ppvaluepEJpEJ(); auto ppypEJpEJ = yIeJeIe->ppvaluepEJpEJ(); - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto ppthezpEJpEJi = ppthezpEJpEJ->at(i); auto ppxpEJpEJi = ppxpEJpEJ->at(i); auto ppypEJpEJi = ppypEJpEJ->at(i); auto pxpEJi = pxpEJ->at(i); auto pypEJi = pypEJ->at(i); - for (int j = i; j < 4; j++) + for (size_t j = i; j < 4; j++) { auto pxpEJj = pxpEJ->at(j); auto pypEJj = pypEJ->at(j); @@ -108,12 +108,12 @@ void MbD::OrbitAngleZIeqcJeqc::calc_ppthezpXIpEJ() auto pypXI = yIeJeIe->pvaluepXI(); auto pxpEJ = xIeJeIe->pvaluepEJ(); auto pypEJ = yIeJeIe->pvaluepEJ(); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto ppthezpXIpEJi = ppthezpXIpEJ->at(i); auto pxpXIi = pxpXI->at(i); auto pypXIi = pypXI->at(i); - for (int j = 0; j < 4; j++) + for (size_t j = 0; j < 4; j++) { auto pxpEJj = pxpEJ->at(j); auto pypEJj = pypEJ->at(j); @@ -133,12 +133,12 @@ void MbD::OrbitAngleZIeqcJeqc::calc_ppthezpXIpXJ() auto pypXI = yIeJeIe->pvaluepXI(); auto pxpXJ = xIeJeIe->pvaluepXJ(); auto pypXJ = yIeJeIe->pvaluepXJ(); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto ppthezpXIpXJi = ppthezpXIpXJ->at(i); auto pxpXIi = pxpXI->at(i); auto pypXIi = pypXI->at(i); - for (int j = 0; j < 3; j++) + for (size_t j = 0; j < 3; j++) { auto pxpXJj = pxpXJ->at(j); auto pypXJj = pypXJ->at(j); @@ -158,12 +158,12 @@ void MbD::OrbitAngleZIeqcJeqc::calc_ppthezpXJpEJ() auto pypXJ = yIeJeIe->pvaluepXJ(); auto pxpEJ = xIeJeIe->pvaluepEJ(); auto pypEJ = yIeJeIe->pvaluepEJ(); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto ppthezpXJpEJi = ppthezpXJpEJ->at(i); auto pxpXJi = pxpXJ->at(i); auto pypXJi = pypXJ->at(i); - for (int j = 0; j < 4; j++) + for (size_t j = 0; j < 4; j++) { auto pxpEJj = pxpEJ->at(j); auto pypEJj = pypEJ->at(j); @@ -181,12 +181,12 @@ void MbD::OrbitAngleZIeqcJeqc::calc_ppthezpXJpXJ() auto pxpXJ = xIeJeIe->pvaluepXJ(); auto pypXJ = yIeJeIe->pvaluepXJ(); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto ppthezpXJpXJi = ppthezpXJpXJ->at(i); auto pxpXJi = pxpXJ->at(i); auto pypXJi = pypXJ->at(i); - for (int j = 0; j < 3; j++) + for (size_t j = 0; j < 3; j++) { auto pxpXJj = pxpXJ->at(j); auto pypXJj = pypXJ->at(j); @@ -201,7 +201,7 @@ void MbD::OrbitAngleZIeqcJeqc::calc_pthezpEJ() { auto pxpEJ = xIeJeIe->pvaluepEJ(); auto pypEJ = yIeJeIe->pvaluepEJ(); - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { pthezpEJ->atiput(i, pypEJ->at(i) * cosOverSSq - (pxpEJ->at(i) * sinOverSSq)); } @@ -211,7 +211,7 @@ void MbD::OrbitAngleZIeqcJeqc::calc_pthezpXJ() { auto pxpXJ = xIeJeIe->pvaluepXJ(); auto pypXJ = yIeJeIe->pvaluepXJ(); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { pthezpXJ->atiput(i, pypXJ->at(i) * cosOverSSq - (pxpXJ->at(i) * sinOverSSq)); } diff --git a/OndselSolver/Part.cpp b/OndselSolver/Part.cpp index 7f24ef0..a262dc1 100644 --- a/OndselSolver/Part.cpp +++ b/OndselSolver/Part.cpp @@ -218,22 +218,22 @@ void Part::prePosKine() partFrame->prePosKine(); } -int MbD::Part::iqX() +size_t MbD::Part::iqX() { return partFrame->iqX; } -int MbD::Part::iqE() +size_t MbD::Part::iqE() { return partFrame->iqE; } -void Part::iqX(int eqnNo) +void Part::iqX(size_t eqnNo) { partFrame->iqX = eqnNo; } -void Part::iqE(int eqnNo) +void Part::iqE(size_t eqnNo) { partFrame->iqE = eqnNo; @@ -274,12 +274,12 @@ void Part::fillqsuWeights(DiagMatDsptr diagMat) auto wqX = std::make_shared>(3); auto wqE = std::make_shared>(4); if (mMax == 0) { mMax = 1.0; } - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { wqX->at(i) = (maxw * m / mMax) + minw; } if (aJiMax == 0) { aJiMax = 1.0; } - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { auto aJi = aJ->at(i); wqE->at(i) = (maxw * aJi / aJiMax) + minw; @@ -321,7 +321,7 @@ void Part::fillqsudotWeights(DiagMatDsptr diagMat) double maxw = maxInertia; auto wqXdot = std::make_shared>(3); auto wqEdot = std::make_shared>(4); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { wqXdot->at(i) = (maxw * m / maxInertia) + minw; auto aJi = aJ->at(i); @@ -373,7 +373,7 @@ void Part::fillPosICJacob(SpMatDsptr mat) partFrame->fillPosICJacob(mat); } -void Part::removeRedundantConstraints(std::shared_ptr> redundantEqnNos) +void Part::removeRedundantConstraints(std::shared_ptr> redundantEqnNos) { partFrame->removeRedundantConstraints(redundantEqnNos); } diff --git a/OndselSolver/Part.h b/OndselSolver/Part.h index a5a0442..35f57c1 100644 --- a/OndselSolver/Part.h +++ b/OndselSolver/Part.h @@ -62,10 +62,10 @@ namespace MbD { void prePosIC() override; void prePosKine() override; - int iqX(); - int iqE(); - void iqX(int eqnNo); - void iqE(int eqnNo); + size_t iqX(); + size_t iqE(); + void iqX(size_t eqnNo); + void iqE(size_t eqnNo); void fillEssenConstraints(std::shared_ptr>> essenConstraints) override; void fillRedundantConstraints(std::shared_ptr>> redunConstraints) override; void fillConstraints(std::shared_ptr>> allConstraints) override; @@ -83,7 +83,7 @@ namespace MbD { void postPosICIteration() override; void fillPosICError(FColDsptr col) override; void fillPosICJacob(SpMatDsptr mat) override; - void removeRedundantConstraints(std::shared_ptr> redundantEqnNos) override; + void removeRedundantConstraints(std::shared_ptr> redundantEqnNos) override; void reactivateRedundantConstraints() override; void constraintsReport() override; void postPosIC() override; @@ -113,8 +113,8 @@ namespace MbD { void postAccIC() override; System* system; //Use raw pointer when pointing backwards. - int ipX = -1; - int ipE = -1; + size_t ipX = SIZE_MAX; + size_t ipE = SIZE_MAX; double m = 0.0; DiagMatDsptr aJ; std::shared_ptr partFrame; diff --git a/OndselSolver/PartFrame.cpp b/OndselSolver/PartFrame.cpp index 24344cd..35e9185 100644 --- a/OndselSolver/PartFrame.cpp +++ b/OndselSolver/PartFrame.cpp @@ -143,14 +143,14 @@ void PartFrame::markerFramesDo(const std::functionbegin(), markerFrames->end(), f); } -void PartFrame::removeRedundantConstraints(std::shared_ptr> redundantEqnNos) +void PartFrame::removeRedundantConstraints(std::shared_ptr> redundantEqnNos) { if (std::find(redundantEqnNos->begin(), redundantEqnNos->end(), aGeu->iG) != redundantEqnNos->end()) { auto redunCon = CREATE::With(); redunCon->constraint = aGeu; aGeu = redunCon; } - for (int i = 0; i < (int)aGabs->size(); i++) + for (size_t i = 0; i < aGabs->size(); i++) { auto& constraint = aGabs->at(i); if (std::find(redundantEqnNos->begin(), redundantEqnNos->end(), constraint->iG) != redundantEqnNos->end()) { @@ -164,7 +164,7 @@ void PartFrame::removeRedundantConstraints(std::shared_ptr> red void PartFrame::reactivateRedundantConstraints() { if (aGeu->isRedundant()) aGeu = std::dynamic_pointer_cast(aGeu)->constraint; - for (int i = 0; i < (int)aGabs->size(); i++) + for (size_t i = 0; i < aGabs->size(); i++) { auto& con = aGabs->at(i); if (con->isRedundant()) { @@ -194,8 +194,8 @@ void PartFrame::constraintsReport() void PartFrame::prePosIC() { - iqX = -1; - iqE = -1; + iqX = SIZE_MAX; + iqE = SIZE_MAX; Item::prePosIC(); markerFramesDo([](std::shared_ptr markerFrm) { markerFrm->prePosIC(); }); aGeu->prePosIC(); @@ -204,8 +204,8 @@ void PartFrame::prePosIC() void PartFrame::prePosKine() { - iqX = -1; - iqE = -1; + iqX = SIZE_MAX; + iqE = SIZE_MAX; this->calcPostDynCorrectorIteration(); markerFramesDo([](std::shared_ptr markerFrm) { markerFrm->prePosKine(); }); aGeu->prePosKine(); @@ -511,7 +511,7 @@ void PartFrame::postDynStep() void PartFrame::asFixed() { - for (int i = 0; i < 6; i++) { + for (size_t i = 0; i < 6; i++) { auto con = CREATE::With(i); con->owner = this; aGabs->push_back(con); diff --git a/OndselSolver/PartFrame.h b/OndselSolver/PartFrame.h index 24bd58b..61c19bd 100644 --- a/OndselSolver/PartFrame.h +++ b/OndselSolver/PartFrame.h @@ -60,7 +60,7 @@ namespace MbD { EndFrmsptr endFrame(std::string name); void aGabsDo(const std::function )>& f); void markerFramesDo(const std::function )>& f); - void removeRedundantConstraints(std::shared_ptr> redundantEqnNos) override; + void removeRedundantConstraints(std::shared_ptr> redundantEqnNos) override; void reactivateRedundantConstraints() override; void constraintsReport() override; @@ -107,8 +107,8 @@ namespace MbD { void postDynStep() override; Part* part = nullptr; //Use raw pointer when pointing backwards. - int iqX = -1; - int iqE = -1; //Position index of frame variables qX and qE in system list of variables + size_t iqX = SIZE_MAX; + size_t iqE = SIZE_MAX; //Position index of frame variables qX and qE in system list of variables FColDsptr qX = std::make_shared>(3); std::shared_ptr> qE = CREATE>::With(4); FColDsptr qXdot = std::make_shared>(3); diff --git a/OndselSolver/PiecewiseFunction.cpp b/OndselSolver/PiecewiseFunction.cpp index 23d6e30..aaf6500 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 < (int)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 < (int)transitions->size(); i++) + for (size_t i = 0; i < transitions->size(); i++) { if (xval < transitions->at(i)->getValue()) { return functions->at(i)->getValue(); @@ -107,14 +107,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 < (int)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 < (int)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 2993686..258b7d3 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, std::shared_ptr> set) { auto newCoeffs = std::make_shared>(); - for (int i = 0; i < (int)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, std::shared_ptr> set) { auto newCoeffs = std::make_shared>(); - for (int i = 0; i < (int)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 < (int)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 < (int)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 < (int)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 < (int)coeffs->size(); i++) + for (size_t i = 1; i < coeffs->size(); i++) { s << ", " << *coeffs->at(i); } diff --git a/OndselSolver/PosICDragNewtonRaphson.cpp b/OndselSolver/PosICDragNewtonRaphson.cpp index e9b807b..4e186b0 100644 --- a/OndselSolver/PosICDragNewtonRaphson.cpp +++ b/OndselSolver/PosICDragNewtonRaphson.cpp @@ -25,13 +25,13 @@ void MbD::PosICDragNewtonRaphson::initializeGlobally() AnyPosICNewtonRaphson::initializeGlobally(); iterMax = system->iterMaxPosKine; dxTol = system->errorTolPosKine; - for (int i = 0; i < qsuWeights->size(); i++) + for (size_t i = 0; i < qsuWeights->size(); i++) { qsuWeights->at(i) = 1.0e3; //minimum weight } for (auto& part : *dragParts) { auto iqX = part->iqX(); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { qsuWeights->at((size_t)iqX + i) = 1.0e6; //maximum weight } @@ -44,7 +44,7 @@ void MbD::PosICDragNewtonRaphson::assignEquationNumbers() //auto contactEndFrames = system->contactEndFrames(); //auto uHolders = system->uHolders(); auto constraints = system->allConstraints(); - int eqnNo = 0; + size_t eqnNo = 0; for (auto& part : *parts) { part->iqX(eqnNo); eqnNo = eqnNo + 3; diff --git a/OndselSolver/PosICKineNewtonRaphson.cpp b/OndselSolver/PosICKineNewtonRaphson.cpp index 14f6fd9..28eebbb 100644 --- a/OndselSolver/PosICKineNewtonRaphson.cpp +++ b/OndselSolver/PosICKineNewtonRaphson.cpp @@ -26,7 +26,7 @@ void PosICKineNewtonRaphson::assignEquationNumbers() //auto contactEndFrames = system->contactEndFrames(); //auto uHolders = system->uHolders(); auto constraints = system->allConstraints(); - int eqnNo = 0; + size_t eqnNo = 0; for (auto& part : *parts) { part->iqX(eqnNo); eqnNo = eqnNo + 3; diff --git a/OndselSolver/PosICNewtonRaphson.cpp b/OndselSolver/PosICNewtonRaphson.cpp index 69ffa42..2c32760 100644 --- a/OndselSolver/PosICNewtonRaphson.cpp +++ b/OndselSolver/PosICNewtonRaphson.cpp @@ -56,7 +56,7 @@ void PosICNewtonRaphson::assignEquationNumbers() auto essentialConstraints = system->essentialConstraints(); auto displacementConstraints = system->displacementConstraints(); auto perpendicularConstraints = system->perpendicularConstraints(); - int eqnNo = 0; + size_t eqnNo = 0; for (auto& part : *parts) { part->iqX(eqnNo); eqnNo = eqnNo + 3; @@ -91,7 +91,7 @@ void PosICNewtonRaphson::assignEquationNumbers() nEqns = eqnNo; //C++ uses index 0. n = nEqns; auto rangelimits = { lastEssenConEqnNo + 1, lastDispConEqnNo + 1, lastEqnNo + 1 }; - pivotRowLimits = std::make_shared>(rangelimits); + pivotRowLimits = std::make_shared>(rangelimits); } bool PosICNewtonRaphson::isConverged() diff --git a/OndselSolver/PosICNewtonRaphson.h b/OndselSolver/PosICNewtonRaphson.h index 798bae9..9d16dcf 100644 --- a/OndselSolver/PosICNewtonRaphson.h +++ b/OndselSolver/PosICNewtonRaphson.h @@ -26,7 +26,7 @@ namespace MbD { void handleSingularMatrix() override; void lookForRedundantConstraints(); - std::shared_ptr> pivotRowLimits; + std::shared_ptr> pivotRowLimits; }; } diff --git a/OndselSolver/PosKineNewtonRaphson.cpp b/OndselSolver/PosKineNewtonRaphson.cpp index 7071609..44f75c3 100644 --- a/OndselSolver/PosKineNewtonRaphson.cpp +++ b/OndselSolver/PosKineNewtonRaphson.cpp @@ -43,7 +43,7 @@ void PosKineNewtonRaphson::assignEquationNumbers() //auto contactEndFrames = system->contactEndFrames(); //auto uHolders = system->uHolders(); auto constraints = system->allConstraints(); - int varNo = 0; + size_t varNo = 0; for (auto& part : *parts) { part->iqX(varNo); varNo = varNo + 3; diff --git a/OndselSolver/PosNewtonRaphson.cpp b/OndselSolver/PosNewtonRaphson.cpp index 3de4522..0fa0dd8 100644 --- a/OndselSolver/PosNewtonRaphson.cpp +++ b/OndselSolver/PosNewtonRaphson.cpp @@ -22,7 +22,8 @@ void PosNewtonRaphson::preRun() void PosNewtonRaphson::incrementIterNo() { - if (iterNo >= iterMax) + iterNo++; + if (iterNo > iterMax) { std::stringstream ss; ss << "MbD: No convergence after " << iterNo << " iterations."; @@ -38,9 +39,7 @@ void PosNewtonRaphson::incrementIterNo() system->logString(str); throw SimulationStoppingError(""); - } - - iterNo++; + } } void PosNewtonRaphson::askSystemToUpdate() diff --git a/OndselSolver/Product.cpp b/OndselSolver/Product.cpp index ee3b0cf..0aced6c 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 < (int)terms->size(); i++) + for (size_t i = 0; i < terms->size(); i++) { auto& derivative = derivatives->at(i); auto newTermFunctions = std::make_shared>(*terms); @@ -128,7 +128,7 @@ Symsptr Product::simplifyUntil(Symsptr, std::shared_ptrinsert(newTerms->begin(), sptrConstant(factor)); } - auto newSize = (int)newTerms->size(); + auto newSize = newTerms->size(); if (newSize == 0) { return sptrConstant(1.0); } @@ -146,7 +146,7 @@ std::ostream& Product::printOn(std::ostream& s) const { s << "("; s << *(this->terms->at(0)); - for (int i = 1; i < (int)this->terms->size(); i++) + for (size_t i = 1; i < this->terms->size(); i++) { s << "*" << *(this->terms->at(i)); } @@ -162,7 +162,7 @@ bool Product::isProduct() double Product::getValue() { double answer = 1.0; - for (int i = 0; i < (int)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/RackPinConstraintIqcJc.cpp b/OndselSolver/RackPinConstraintIqcJc.cpp index 1ce7c5c..cc04cdf 100644 --- a/OndselSolver/RackPinConstraintIqcJc.cpp +++ b/OndselSolver/RackPinConstraintIqcJc.cpp @@ -45,7 +45,7 @@ void MbD::RackPinConstraintIqcJc::addToJointTorqueI(FColDsptr jointTorque) auto pAOIppEI = frmIeqc->pAOppE(); auto aBOIp = frmIeqc->aBOp(); auto fpAOIppEIrIpIeIp = std::make_shared>(4, 0.0); - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto dum = cForceT->timesFullColumn(pAOIppEI->at(i)->timesFullColumn(rIpIeIp)); fpAOIppEIrIpIeIp->atiput(i, dum); diff --git a/OndselSolver/RackPinConstraintIqcJc.h b/OndselSolver/RackPinConstraintIqcJc.h index c118a65..f94cd29 100644 --- a/OndselSolver/RackPinConstraintIqcJc.h +++ b/OndselSolver/RackPinConstraintIqcJc.h @@ -36,7 +36,7 @@ namespace MbD { FRowDsptr pGpXI, pGpEI; FMatDsptr ppGpXIpEI, ppGpEIpEI; - int iqXI, iqEI; + size_t iqXI, iqEI; }; } diff --git a/OndselSolver/RackPinConstraintIqcJqc.h b/OndselSolver/RackPinConstraintIqcJqc.h index c579ea5..1f50f4a 100644 --- a/OndselSolver/RackPinConstraintIqcJqc.h +++ b/OndselSolver/RackPinConstraintIqcJqc.h @@ -35,7 +35,7 @@ namespace MbD { FRowDsptr pGpXJ, pGpEJ; FMatDsptr ppGpEIpXJ, ppGpEIpEJ, ppGpEJpEJ; - int iqXJ = -1, iqEJ = -1; + size_t iqXJ = SIZE_MAX, iqEJ = SIZE_MAX; }; } diff --git a/OndselSolver/RedundantConstraint.cpp b/OndselSolver/RedundantConstraint.cpp index 6ed7957..d3938c0 100644 --- a/OndselSolver/RedundantConstraint.cpp +++ b/OndselSolver/RedundantConstraint.cpp @@ -10,7 +10,7 @@ using namespace MbD; -void RedundantConstraint::removeRedundantConstraints(std::shared_ptr>) +void RedundantConstraint::removeRedundantConstraints(std::shared_ptr>) { } diff --git a/OndselSolver/RedundantConstraint.h b/OndselSolver/RedundantConstraint.h index 55a2863..aa5024d 100644 --- a/OndselSolver/RedundantConstraint.h +++ b/OndselSolver/RedundantConstraint.h @@ -15,7 +15,7 @@ namespace MbD { { // public: - void removeRedundantConstraints(std::shared_ptr> redundantEqnNos) override; + void removeRedundantConstraints(std::shared_ptr> redundantEqnNos) override; bool isRedundant() override; std::string classname() override; ConstraintType type() override; diff --git a/OndselSolver/RowTypeMatrix.h b/OndselSolver/RowTypeMatrix.h index 143bb43..1f7a145 100644 --- a/OndselSolver/RowTypeMatrix.h +++ b/OndselSolver/RowTypeMatrix.h @@ -17,16 +17,16 @@ namespace MbD { { public: RowTypeMatrix() {} - RowTypeMatrix(int m) : Array(m) {} + RowTypeMatrix(size_t m) : Array(m) {} RowTypeMatrix(std::initializer_list list) : Array{ list } {} void copyFrom(std::shared_ptr> x); virtual void zeroSelf() override = 0; //double maxMagnitude() override; - int numberOfElements() override; - int nrow() { - return (int)this->size(); + size_t numberOfElements() override; + size_t nrow() { + return this->size(); } - int ncol() { + size_t ncol() { return this->at(0)->numberOfElements(); } }; @@ -34,7 +34,7 @@ namespace MbD { template inline void RowTypeMatrix::copyFrom(std::shared_ptr> x) { - for (int i = 0; i < (int)x->size(); i++) { + for (size_t i = 0; i < x->size(); i++) { this->at(i)->copyFrom(x->at(i)); } } @@ -42,7 +42,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; @@ -50,7 +50,7 @@ namespace MbD { // return max; //} template - inline int RowTypeMatrix::numberOfElements() + inline size_t RowTypeMatrix::numberOfElements() { return this->nrow() * this->ncol(); } diff --git a/OndselSolver/ScrewConstraintIqcJc.cpp b/OndselSolver/ScrewConstraintIqcJc.cpp index e6ff72b..6e2b15e 100644 --- a/OndselSolver/ScrewConstraintIqcJc.cpp +++ b/OndselSolver/ScrewConstraintIqcJc.cpp @@ -47,7 +47,7 @@ void MbD::ScrewConstraintIqcJc::addToJointTorqueI(FColDsptr jointTorque) auto pAOIppEI = frmIeqc->pAOppE(); auto aBOIp = frmIeqc->aBOp(); auto fpAOIppEIrIpIeIp = std::make_shared>(4, 0.0); - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto dum = cForceT->timesFullColumn(pAOIppEI->at(i)->timesFullColumn(rIpIeIp)); fpAOIppEIrIpIeIp->atiput(i, dum); diff --git a/OndselSolver/ScrewConstraintIqcJc.h b/OndselSolver/ScrewConstraintIqcJc.h index fd9e352..3647d6a 100644 --- a/OndselSolver/ScrewConstraintIqcJc.h +++ b/OndselSolver/ScrewConstraintIqcJc.h @@ -36,7 +36,7 @@ namespace MbD { FRowDsptr pGpXI, pGpEI; FMatDsptr ppGpXIpEI, ppGpEIpEI; - int iqXI, iqEI; + size_t iqXI, iqEI; }; diff --git a/OndselSolver/ScrewConstraintIqcJqc.h b/OndselSolver/ScrewConstraintIqcJqc.h index ff4aaba..812d37a 100644 --- a/OndselSolver/ScrewConstraintIqcJqc.h +++ b/OndselSolver/ScrewConstraintIqcJqc.h @@ -35,7 +35,7 @@ namespace MbD { FRowDsptr pGpXJ, pGpEJ; FMatDsptr ppGpEIpXJ, ppGpEIpEJ, ppGpEJpEJ; - int iqXJ = -1, iqEJ = -1; + size_t iqXJ = SIZE_MAX, iqEJ = SIZE_MAX; }; diff --git a/OndselSolver/SingularMatrixError.h b/OndselSolver/SingularMatrixError.h index 5127943..3ce39fd 100644 --- a/OndselSolver/SingularMatrixError.h +++ b/OndselSolver/SingularMatrixError.h @@ -18,11 +18,11 @@ namespace MbD { class SingularMatrixError : virtual public std::runtime_error { protected: - std::shared_ptr> redundantEqnNos; + std::shared_ptr> redundantEqnNos; public: explicit - SingularMatrixError(const std::string& msg, std::shared_ptr> redunEqnNos) : + SingularMatrixError(const std::string& msg, std::shared_ptr> redunEqnNos) : std::runtime_error(msg), redundantEqnNos(redunEqnNos) { } @@ -32,7 +32,7 @@ namespace MbD { virtual ~SingularMatrixError() noexcept {} - virtual std::shared_ptr> getRedundantEqnNos() const noexcept { + virtual std::shared_ptr> getRedundantEqnNos() const noexcept { return redundantEqnNos; } }; diff --git a/OndselSolver/Solver.h b/OndselSolver/Solver.h index 941ce34..4f679f7 100644 --- a/OndselSolver/Solver.h +++ b/OndselSolver/Solver.h @@ -9,6 +9,7 @@ #pragma once #include +#include "Numeric.h" namespace MbD { class Solver diff --git a/OndselSolver/SparseColumn.h b/OndselSolver/SparseColumn.h index d8de56c..ca3ae76 100644 --- a/OndselSolver/SparseColumn.h +++ b/OndselSolver/SparseColumn.h @@ -16,7 +16,7 @@ namespace MbD { { public: SparseColumn() {} - SparseColumn(std::initializer_list> list) : SparseVector{ list } {} + SparseColumn(std::initializer_list> list) : SparseVector{ list } {} SparseColumn(std::initializer_list> list) : SparseVector{ list } {} }; } diff --git a/OndselSolver/SparseMatrix.h b/OndselSolver/SparseMatrix.h index 549a909..ed1b08d 100644 --- a/OndselSolver/SparseMatrix.h +++ b/OndselSolver/SparseMatrix.h @@ -26,11 +26,11 @@ namespace MbD { class SparseMatrix : public RowTypeMatrix> { public: - SparseMatrix(int m) : RowTypeMatrix>(m) + SparseMatrix(size_t m) : RowTypeMatrix>(m) { } - SparseMatrix(int m, int n) { - for (int i = 0; i < m; i++) + SparseMatrix(size_t m, size_t n) { + for (size_t i = 0; i < m; i++) { auto row = std::make_shared>(n); this->push_back(row); @@ -43,22 +43,22 @@ namespace MbD { this->push_back(row); } } - void atiput(int i, SpRowsptr spRow); - void atijplusDiagonalMatrix(int i, int j, DiagMatDsptr diagMat); - void atijminusDiagonalMatrix(int i, int j, DiagMatDsptr diagMat); + void atiput(size_t i, SpRowsptr spRow); + void atijplusDiagonalMatrix(size_t i, size_t j, DiagMatDsptr diagMat); + void atijminusDiagonalMatrix(size_t i, size_t j, DiagMatDsptr diagMat); double sumOfSquares() override; void zeroSelf() override; - void atijplusFullRow(int i, int j, FRowsptr fullRow); - void atijplusFullColumn(int i, int j, FColsptr fullCol); - void atijplusFullMatrix(int i, int j, FMatDsptr fullMat); - void atijminusFullMatrix(int i, int j, FMatDsptr fullMat); - void atijplusTransposeFullMatrix(int i, int j, FMatDsptr fullMat); - void atijplusFullMatrixtimes(int i, int j, FMatDsptr fullMat, T factor); - void atijminusFullColumn(int i, int j, FColDsptr fullCol); - void atijminusTransposeFullMatrix(int i, int j, FMatDsptr fullMat); - void atijplusNumber(int i, int j, double value); - void atijminusNumber(int i, int j, double value); - void atijput(int i, int j, T value); + void atijplusFullRow(size_t i, size_t j, FRowsptr fullRow); + void atijplusFullColumn(size_t i, size_t j, FColsptr fullCol); + void atijplusFullMatrix(size_t i, size_t j, FMatDsptr fullMat); + void atijminusFullMatrix(size_t i, size_t j, FMatDsptr fullMat); + void atijplusTransposeFullMatrix(size_t i, size_t j, FMatDsptr fullMat); + void atijplusFullMatrixtimes(size_t i, size_t j, FMatDsptr fullMat, T factor); + void atijminusFullColumn(size_t i, size_t j, FColDsptr fullCol); + void atijminusTransposeFullMatrix(size_t i, size_t j, FMatDsptr fullMat); + void atijplusNumber(size_t i, size_t j, double value); + void atijminusNumber(size_t i, size_t j, double value); + void atijput(size_t i, size_t j, T value); double maxMagnitude() override; FColsptr timesFullColumn(FColsptr fullCol); SpMatsptr plusSparseMatrix(SpMatsptr spMat); @@ -70,26 +70,26 @@ namespace MbD { }; template - inline void SparseMatrix::atiput(int i, SpRowsptr spRow) + inline void SparseMatrix::atiput(size_t i, SpRowsptr spRow) { this->at(i) = spRow; } template - inline void SparseMatrix::atijplusDiagonalMatrix(int i, int j, DiagMatDsptr diagMat) + inline void SparseMatrix::atijplusDiagonalMatrix(size_t i, size_t j, DiagMatDsptr diagMat) { auto n = diagMat->nrow(); - for (int ii = 0; ii < n; ii++) + for (size_t ii = 0; ii < n; ii++) { this->atijplusNumber(i + ii, j + ii, diagMat->at(ii)); } } template<> - inline void SparseMatrix::atijminusDiagonalMatrix(int i1, int j1, DiagMatDsptr diagMat) + inline void SparseMatrix::atijminusDiagonalMatrix(size_t i1, size_t j1, DiagMatDsptr diagMat) { auto n = diagMat->nrow(); - for (int ii = 0; ii < n; ii++) + for (size_t ii = 0; ii < n; ii++) { this->atijminusNumber(i1 + ii, j1 + ii, diagMat->at(ii)); } @@ -98,7 +98,7 @@ namespace MbD { inline double SparseMatrix::sumOfSquares() { double sum = 0.0; - for (int i = 0; i < (int)this->size(); i++) + for (size_t i = 0; i < this->size(); i++) { sum += this->at(i)->sumOfSquares(); } @@ -107,83 +107,83 @@ namespace MbD { template<> inline void SparseMatrix::zeroSelf() { - for (int i = 0; i < (int)this->size(); i++) { + for (size_t i = 0; i < this->size(); i++) { this->at(i)->zeroSelf(); } } template - inline void SparseMatrix::atijplusFullRow(int i, int j, FRowsptr fullRow) + inline void SparseMatrix::atijplusFullRow(size_t i, size_t j, FRowsptr fullRow) { this->at(i)->atiplusFullRow(j, fullRow); } template - inline void SparseMatrix::atijplusFullColumn(int i, int j, FColsptr fullCol) + inline void SparseMatrix::atijplusFullColumn(size_t i, size_t j, FColsptr fullCol) { - for (int ii = 0; ii < (int)fullCol->size(); ii++) + for (size_t ii = 0; ii < fullCol->size(); ii++) { this->atijplusNumber(i + ii, j, fullCol->at(ii)); } } template - inline void SparseMatrix::atijminusFullColumn(int i, int j, FColDsptr fullCol) + inline void SparseMatrix::atijminusFullColumn(size_t i, size_t 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)); } } template - inline void SparseMatrix::atijplusFullMatrix(int i, int j, FMatDsptr fullMat) + inline void SparseMatrix::atijplusFullMatrix(size_t i, size_t j, FMatDsptr fullMat) { - for (int ii = 0; ii < fullMat->nrow(); ii++) + for (size_t ii = 0; ii < fullMat->nrow(); ii++) { this->at(i + ii)->atiplusFullRow(j, fullMat->at(ii)); } } template - inline void SparseMatrix::atijminusFullMatrix(int i, int j, FMatDsptr fullMat) + inline void SparseMatrix::atijminusFullMatrix(size_t i, size_t j, FMatDsptr fullMat) { - for (int ii = 0; ii < fullMat->nrow(); ii++) + for (size_t ii = 0; ii < fullMat->nrow(); ii++) { this->at(i + ii)->atiminusFullRow(j, fullMat->at(ii)); } } template - inline void SparseMatrix::atijplusTransposeFullMatrix(int i, int j, FMatDsptr fullMat) + inline void SparseMatrix::atijplusTransposeFullMatrix(size_t i, size_t j, FMatDsptr fullMat) { - for (int ii = 0; ii < fullMat->nrow(); ii++) + for (size_t ii = 0; ii < fullMat->nrow(); ii++) { this->atijplusFullColumn(i, j + ii, fullMat->at(ii)->transpose()); } } template - inline void SparseMatrix::atijminusTransposeFullMatrix(int i, int j, FMatDsptr fullMat) + inline void SparseMatrix::atijminusTransposeFullMatrix(size_t i, size_t j, FMatDsptr fullMat) { - for (int ii = 0; ii < fullMat->nrow(); ii++) + for (size_t ii = 0; ii < fullMat->nrow(); ii++) { this->atijminusFullColumn(i, j + ii, fullMat->at(ii)->transpose()); } } template - inline void SparseMatrix::atijplusFullMatrixtimes(int i, int j, FMatDsptr fullMat, T factor) + inline void SparseMatrix::atijplusFullMatrixtimes(size_t i, size_t j, FMatDsptr fullMat, T factor) { - for (int ii = 0; ii < fullMat->nrow(); ii++) + for (size_t ii = 0; ii < fullMat->nrow(); ii++) { this->at(i + ii)->atiplusFullRowtimes(j, fullMat->at(ii), factor); } } template - inline void SparseMatrix::atijplusNumber(int i, int j, double value) + inline void SparseMatrix::atijplusNumber(size_t i, size_t j, double value) { this->at(i)->atiplusNumber(j, value); } template - inline void SparseMatrix::atijminusNumber(int i, int j, double value) + inline void SparseMatrix::atijminusNumber(size_t i, size_t j, double value) { this->at(i)->atiminusNumber(j, value); } template - inline void SparseMatrix::atijput(int i, int j, T value) + inline void SparseMatrix::atijput(size_t i, size_t j, T value) { this->at(i)->atiput(j, value); } @@ -191,7 +191,7 @@ namespace MbD { inline double SparseMatrix::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)->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 < (int)this->size(); i++) + for (size_t i = 0; i < this->size(); i++) { s << *(this->at(i)) << std::endl; } @@ -215,7 +215,7 @@ namespace MbD { //"a*b = a(i,j)b(j) sum j." auto nrow = this->nrow(); auto answer = std::make_shared>(nrow); - for (int i = 0; i < nrow; i++) + for (size_t i = 0; i < nrow; i++) { answer->at(i) = this->at(i)->timesFullColumn(fullCol); } @@ -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 < (int)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 1a3fa48..181f6a0 100644 --- a/OndselSolver/SparseRow.h +++ b/OndselSolver/SparseRow.h @@ -26,14 +26,14 @@ namespace MbD { { public: SparseRow() {} - SparseRow(int n) : SparseVector(n) {} - SparseRow(std::initializer_list> list) : SparseVector{ list } {} + SparseRow(size_t n) : SparseVector(n) {} + SparseRow(std::initializer_list> list) : SparseVector{ list } {} SparseRow(std::initializer_list> list) : SparseVector{ list } {} SpRowDsptr timesconditionedWithTol(double scaling, double tol); SpRowDsptr conditionedWithTol(double tol); - void atiplusFullRow(int j, FRowsptr fullRow); - void atiminusFullRow(int j, FRowsptr fullRow); - void atiplusFullRowtimes(int j, FRowsptr fullRow, double factor); + void atiplusFullRow(size_t j, FRowsptr fullRow); + void atiminusFullRow(size_t j, FRowsptr fullRow); + void atiplusFullRowtimes(size_t j, FRowsptr fullRow, double factor); T timesFullColumn(FColsptr fullCol); SpRowsptr plusSparseRow(SpRowsptr spMat); SpRowsptr clonesptr(); @@ -62,25 +62,25 @@ namespace MbD { return answer; } template - inline void SparseRow::atiplusFullRow(int j, FRowsptr fullRow) + inline void SparseRow::atiplusFullRow(size_t j, FRowsptr fullRow) { - for (int jj = 0; jj < (int)fullRow->size(); jj++) + for (size_t jj = 0; jj < fullRow->size(); jj++) { (*this)[j + jj] += fullRow->at(jj); } } template - inline void SparseRow::atiminusFullRow(int j, FRowsptr fullRow) + inline void SparseRow::atiminusFullRow(size_t j, FRowsptr fullRow) { - for (int jj = 0; jj < (int)fullRow->size(); jj++) + for (size_t jj = 0; jj < fullRow->size(); jj++) { (*this)[j + jj] -= fullRow->at(jj); } } template - inline void SparseRow::atiplusFullRowtimes(int j, FRowsptr fullRow, double factor) + inline void SparseRow::atiplusFullRowtimes(size_t j, FRowsptr fullRow, double factor) { - for (int jj = 0; jj < (int)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 484aa14..4c79431 100644 --- a/OndselSolver/SparseVector.h +++ b/OndselSolver/SparseVector.h @@ -14,33 +14,33 @@ namespace MbD { template - class SparseVector : public std::map + class SparseVector : public std::map { public: - int n; + size_t n; SparseVector() {} - SparseVector(int n) : std::map(), n(n) {} - SparseVector(std::initializer_list> list) : std::map{ list } {} + SparseVector(size_t n) : std::map(), n(n) {} + SparseVector(std::initializer_list> list) : std::map{ list } {} SparseVector(std::initializer_list> list) { for (auto& pair : list) { - int i = 0; - int index; + size_t i = 0; + size_t index; T value; for (auto& element : pair) { - if (i == 0) index = (int)std::round(element); + if (i == 0) index = std::round(element); if (i == 1) value = element; i++; } - this->insert(std::pair(index, value)); + this->insert(std::pair(index, value)); } } virtual ~SparseVector() {} double rootMeanSquare(); - int numberOfElements(); + size_t numberOfElements(); double sumOfSquares(); - void atiput(int i, T value); - void atiplusNumber(int i, double value); - void atiminusNumber(int i, double value); + void atiput(size_t i, T value); + void atiplusNumber(size_t i, double value); + void atiminusNumber(size_t i, double value); void zeroSelf(); double maxMagnitude(); void magnifySelf(T factor); @@ -57,7 +57,7 @@ namespace MbD { return std::sqrt(this->sumOfSquares() / this->numberOfElements()); } template - inline int SparseVector::numberOfElements() + inline size_t SparseVector::numberOfElements() { return n; } @@ -72,17 +72,17 @@ namespace MbD { return sum; } template - inline void SparseVector::atiput(int i, T value) + inline void SparseVector::atiput(size_t i, T value) { (*this)[i] = value; } template<> - inline void SparseVector::atiplusNumber(int i, double value) + inline void SparseVector::atiplusNumber(size_t i, double value) { (*this)[i] += value; } template - inline void SparseVector::atiminusNumber(int i, double value) + inline void SparseVector::atiminusNumber(size_t i, double value) { (*this)[i] -= value; } diff --git a/OndselSolver/StableBackwardDifference.cpp b/OndselSolver/StableBackwardDifference.cpp index 4700105..ad98b99 100644 --- a/OndselSolver/StableBackwardDifference.cpp +++ b/OndselSolver/StableBackwardDifference.cpp @@ -20,7 +20,7 @@ void StableBackwardDifference::formTaylorMatrix() //| (t3 - t) (t3 - t) ^ 2 / 2! (t3 - t) ^ 3 / 3!| |qddd(t)| |q(t3) - q(t) | this->instantiateTaylorMatrix(); - for (int i = 0; i < order; i++) + for (size_t i = 0; i < order; i++) { this->formTaylorRowwithTimeNodederivative(i, i, 0); } @@ -32,7 +32,7 @@ double MbD::StableBackwardDifference::pvdotpv() auto& coeffs = operatorMatrix->at(0); auto sum = 0.0; - for (int i = 0; i < order; i++) + for (size_t i = 0; i < order; i++) { sum -= coeffs->at(i); } @@ -40,7 +40,7 @@ double MbD::StableBackwardDifference::pvdotpv() } FColDsptr MbD::StableBackwardDifference::derivativepresentpastpresentDerivativepastDerivative( - int, FColDsptr, std::shared_ptr>, FColDsptr, + size_t, FColDsptr, std::shared_ptr>, FColDsptr, std::shared_ptr>) { assert(false); @@ -54,29 +54,29 @@ void StableBackwardDifference::instantiateTaylorMatrix() } } -void StableBackwardDifference::formTaylorRowwithTimeNodederivative(int i, int ii, int k) +void StableBackwardDifference::formTaylorRowwithTimeNodederivative(size_t i, size_t ii, size_t k) { //| rowi hi hipower aij | auto& rowi = taylorMatrix->at(i); if (k > 0) { - for (int j = 0; j < k - 2; j++) + for (size_t j = 0; j < k - 2; j++) { rowi->at(j) = 0.0; } - rowi->at((int)k - 1) = 1.0; + rowi->at(k - 1) = 1.0; } auto hi = timeNodes->at(ii) - time; auto hipower = 1.0; - for (int j = k; j < order; j++) + for (size_t j = k; j < order; j++) { hipower *= hi; - auto aij = hipower * OneOverFactorials->at((int)(j - k + 1)); + auto aij = hipower * OneOverFactorials->at(j - k + 1); rowi->at(j) = aij; } } -FColDsptr MbD::StableBackwardDifference::derivativepresentpast(int deriv, FColDsptr y, std::shared_ptr> ypast) +FColDsptr MbD::StableBackwardDifference::derivativepresentpast(size_t deriv, FColDsptr y, std::shared_ptr> ypast) { //"Answer ith derivative given present value and past values." @@ -86,16 +86,16 @@ FColDsptr MbD::StableBackwardDifference::derivativepresentpast(int deriv, FColDs else { if (deriv <= order) { auto series = std::make_shared>(order); - for (int i = 0; i < order; i++) + for (size_t i = 0; i < order; i++) { series->at(i) = ypast->at(i)->minusFullColumn(y); } - auto& coeffs = operatorMatrix->at((int)deriv - 1); + auto& coeffs = operatorMatrix->at(deriv - 1); auto answer = coeffs->dot(series); return std::static_pointer_cast>(answer); } else { - auto ySize = (int)y->size(); + auto ySize = y->size(); return std::make_shared>(ySize, 0.0); } } diff --git a/OndselSolver/StableBackwardDifference.h b/OndselSolver/StableBackwardDifference.h index ac4f5ed..6075fbd 100644 --- a/OndselSolver/StableBackwardDifference.h +++ b/OndselSolver/StableBackwardDifference.h @@ -16,15 +16,15 @@ namespace MbD { { // public: - FColDsptr derivativepresentpast(int order, FColDsptr y, std::shared_ptr> ypast) override; + FColDsptr derivativepresentpast(size_t order, FColDsptr y, std::shared_ptr> ypast) override; void instantiateTaylorMatrix() override; - void formTaylorRowwithTimeNodederivative(int i, int ii, int k) override; + void formTaylorRowwithTimeNodederivative(size_t i, size_t ii, size_t k) override; void formTaylorMatrix() override; double pvdotpv() override; - FColDsptr derivativepresentpastpresentDerivativepastDerivative(int n, + FColDsptr derivativepresentpastpresentDerivativepastDerivative(size_t n, FColDsptr y, std::shared_ptr> ypast, FColDsptr ydot, std::shared_ptr> ydotpast) override; - FColDsptr derivativewith(int deriv, std::shared_ptr> series); + FColDsptr derivativewith(size_t deriv, std::shared_ptr> series); }; } diff --git a/OndselSolver/Sum.cpp b/OndselSolver/Sum.cpp index ea0e1a5..3a33cc7 100644 --- a/OndselSolver/Sum.cpp +++ b/OndselSolver/Sum.cpp @@ -127,7 +127,7 @@ bool Sum::isSum() double Sum::getValue() { double answer = 0.0; - for (int i = 0; i < (int)terms->size(); i++) answer += terms->at(i)->getValue(); + for (size_t i = 0; i < terms->size(); i++) answer += terms->at(i)->getValue(); return answer; } @@ -173,7 +173,7 @@ std::ostream& Sum::printOn(std::ostream& s) const { s << "("; s << *(this->terms->at(0)); - for (int i = 1; i < (int)this->terms->size(); i++) + for (size_t i = 1; i < this->terms->size(); i++) { s << " + " << *(this->terms->at(i)); } diff --git a/OndselSolver/SymbolicParser.cpp b/OndselSolver/SymbolicParser.cpp index 162061a..6217022 100644 --- a/OndselSolver/SymbolicParser.cpp +++ b/OndselSolver/SymbolicParser.cpp @@ -64,7 +64,7 @@ void MbD::SymbolicParser::parseString(std::string expr) } source = std::make_shared(expr); hereChar = source->get(); - prevEnd = -1; + prevEnd = SIZE_MAX; scanToken(); expression(); if (tokenType != "end") expected("Nothing more"); @@ -191,7 +191,7 @@ bool MbD::SymbolicParser::peekForTypeNoPush(std::string c) std::string MbD::SymbolicParser::scanToken() { - prevEnd = (int)source->tellg(); + prevEnd = (int)source->tellg(); //Use int because of decrement prevEnd--; while (std::isspace(hereChar) || isNextLineTag(hereChar)) { hereChar = source->get(); @@ -393,7 +393,7 @@ bool MbD::SymbolicParser::intrinsic() if (expression()) { while (commaExpression()) {} if (stack->size() > startsize) { - combineStackTo((int)startsize); + combineStackTo(startsize); if (peekForTypeNoPush(")")) { Symsptr args = stack->top(); //args is a Sum with "terms" containing the actual arguments stack->pop(); @@ -501,10 +501,10 @@ void MbD::SymbolicParser::notifyat(std::string, int) //raiseSignal } -void MbD::SymbolicParser::combineStackTo(int pos) +void MbD::SymbolicParser::combineStackTo(size_t pos) { auto args = std::make_shared>(); - while ((int)stack->size() > pos) { + while (stack->size() > pos) { Symsptr arg = stack->top(); stack->pop(); args->push_back(arg); diff --git a/OndselSolver/SymbolicParser.h b/OndselSolver/SymbolicParser.h index 72b46a5..b0d6219 100644 --- a/OndselSolver/SymbolicParser.h +++ b/OndselSolver/SymbolicParser.h @@ -51,14 +51,14 @@ namespace MbD { bool peekForTypevalue(std::string type, std::string symbol); void notify(std::string msg); void notifyat(std::string msg, int mrk); - void combineStackTo(int pos); + void combineStackTo(size_t pos); bool isNextLineTag(char c); ASMTItem* owner = nullptr; std::shared_ptr> variables; std::shared_ptr> geoIJs; std::shared_ptr units; - int mark = -1, prevEnd = -1; + int mark = SIZE_MAX, prevEnd = SIZE_MAX; char hereChar = '\0'; std::string token, tokenType; double tokenNum = -1.0e100; diff --git a/OndselSolver/System.cpp b/OndselSolver/System.cpp index 49ec1a4..52f8951 100644 --- a/OndselSolver/System.cpp +++ b/OndselSolver/System.cpp @@ -207,10 +207,10 @@ double System::maximumMass() double System::maximumMomentOfInertia() { double max = 0.0; - for (int i = 0; i < (int)parts->size(); i++) + for (size_t i = 0; i < parts->size(); i++) { auto& part = parts->at(i); - for (int j = 0; j < 3; j++) + for (size_t j = 0; j < 3; j++) { auto& aJ = part->aJ; auto aJi = aJ->at(j); diff --git a/OndselSolver/SystemSolver.h b/OndselSolver/SystemSolver.h index d93c51b..ee14c21 100644 --- a/OndselSolver/SystemSolver.h +++ b/OndselSolver/SystemSolver.h @@ -89,8 +89,8 @@ namespace MbD { double errorTolPosKine = 1.0e-6; double errorTolAccKine = 1.0e-6; - int iterMaxPosKine = 25; - int iterMaxAccKine = 25; + size_t iterMaxPosKine = 25; + size_t iterMaxAccKine = 25; std::shared_ptr basicIntegrator; std::shared_ptr> tstartPasts; double tstart = 0.0; @@ -104,8 +104,8 @@ namespace MbD { double corRelTol = 0.0; double intAbsTol = 0.0; double intRelTol = 0.0; - int iterMaxDyn = 0; - int orderMax = 0; + size_t iterMaxDyn = 0; + size_t orderMax = 0; double translationLimit = 0.0; double rotationLimit = 0.0; }; diff --git a/OndselSolver/TranslationConstraintIJ.cpp b/OndselSolver/TranslationConstraintIJ.cpp index e9969cf..03f8740 100644 --- a/OndselSolver/TranslationConstraintIJ.cpp +++ b/OndselSolver/TranslationConstraintIJ.cpp @@ -11,7 +11,7 @@ using namespace MbD; -TranslationConstraintIJ::TranslationConstraintIJ(EndFrmsptr frmi, EndFrmsptr frmj, int axisi) : +TranslationConstraintIJ::TranslationConstraintIJ(EndFrmsptr frmi, EndFrmsptr frmj, size_t axisi) : ConstraintIJ(frmi, frmj), axisI(axisi) { } diff --git a/OndselSolver/TranslationConstraintIJ.h b/OndselSolver/TranslationConstraintIJ.h index 15a8a73..8bfd0a1 100644 --- a/OndselSolver/TranslationConstraintIJ.h +++ b/OndselSolver/TranslationConstraintIJ.h @@ -16,7 +16,7 @@ namespace MbD { { //riIeJeIe public: - TranslationConstraintIJ(EndFrmsptr frmi, EndFrmsptr frmj, int axisi); + TranslationConstraintIJ(EndFrmsptr frmi, EndFrmsptr frmj, size_t axisi); void calcPostDynCorrectorIteration() override; void initialize() override; @@ -31,7 +31,7 @@ namespace MbD { void simUpdateAll() override; ConstraintType type() override; - int axisI; + size_t axisI; std::shared_ptr riIeJeIe; //ToDo: Use DispCompIecJecIe instead of DispCompIecJecKec }; diff --git a/OndselSolver/TranslationConstraintIqcJc.cpp b/OndselSolver/TranslationConstraintIqcJc.cpp index 429655c..0f02c33 100644 --- a/OndselSolver/TranslationConstraintIqcJc.cpp +++ b/OndselSolver/TranslationConstraintIqcJc.cpp @@ -13,7 +13,7 @@ using namespace MbD; -TranslationConstraintIqcJc::TranslationConstraintIqcJc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi) : +TranslationConstraintIqcJc::TranslationConstraintIqcJc(EndFrmsptr frmi, EndFrmsptr frmj, size_t axisi) : TranslationConstraintIJ(frmi, frmj, axisi) { } @@ -102,7 +102,7 @@ void TranslationConstraintIqcJc::addToJointTorqueI(FColDsptr jointTorque) auto pAOIppEI = frmI->pAOppE(); auto aBOIp = frmI->aBOp(); auto fpAOIppEIrIpIeIp = std::make_shared>(4, 0.0); - for (int i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { auto dum = cForceT->timesFullColumn(pAOIppEI->at(i)->timesFullColumn(rIpIeIp)); fpAOIppEIrIpIeIp->atiput(i, dum); diff --git a/OndselSolver/TranslationConstraintIqcJc.h b/OndselSolver/TranslationConstraintIqcJc.h index 51b9bab..a4ad5ca 100644 --- a/OndselSolver/TranslationConstraintIqcJc.h +++ b/OndselSolver/TranslationConstraintIqcJc.h @@ -15,7 +15,7 @@ namespace MbD { { //pGpXI pGpEI ppGpXIpEI ppGpEIpEI iqXI iqEI public: - TranslationConstraintIqcJc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi); + TranslationConstraintIqcJc(EndFrmsptr frmi, EndFrmsptr frmj, size_t axisi); void addToJointForceI(FColDsptr col) override; void addToJointTorqueI(FColDsptr col) override; @@ -30,7 +30,7 @@ namespace MbD { FRowDsptr pGpXI, pGpEI; FMatDsptr ppGpXIpEI, ppGpEIpEI; - int iqXI, iqEI; + size_t iqXI, iqEI; }; } diff --git a/OndselSolver/TranslationConstraintIqcJqc.cpp b/OndselSolver/TranslationConstraintIqcJqc.cpp index 5659e02..0e18b9b 100644 --- a/OndselSolver/TranslationConstraintIqcJqc.cpp +++ b/OndselSolver/TranslationConstraintIqcJqc.cpp @@ -13,7 +13,7 @@ using namespace MbD; -TranslationConstraintIqcJqc::TranslationConstraintIqcJqc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi) : +TranslationConstraintIqcJqc::TranslationConstraintIqcJqc(EndFrmsptr frmi, EndFrmsptr frmj, size_t axisi) : TranslationConstraintIqcJc(frmi, frmj, axisi) { } diff --git a/OndselSolver/TranslationConstraintIqcJqc.h b/OndselSolver/TranslationConstraintIqcJqc.h index 1ad9a64..ed0eb9a 100644 --- a/OndselSolver/TranslationConstraintIqcJqc.h +++ b/OndselSolver/TranslationConstraintIqcJqc.h @@ -15,7 +15,7 @@ namespace MbD { { //pGpXJ pGpEJ ppGpEIpXJ ppGpEIpEJ ppGpEJpEJ iqXJ iqEJ public: - TranslationConstraintIqcJqc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi); + TranslationConstraintIqcJqc(EndFrmsptr frmi, EndFrmsptr frmj, size_t axisi); void calcPostDynCorrectorIteration() override; void initriIeJeIe() override; @@ -28,7 +28,7 @@ namespace MbD { FRowDsptr pGpXJ, pGpEJ; FMatDsptr ppGpEIpXJ, ppGpEIpEJ, ppGpEJpEJ; - int iqXJ = -1, iqEJ = -1; + size_t iqXJ = SIZE_MAX, iqEJ = SIZE_MAX; }; } diff --git a/OndselSolver/TranslationConstraintIqctJqc.cpp b/OndselSolver/TranslationConstraintIqctJqc.cpp index 9da745a..e225c82 100644 --- a/OndselSolver/TranslationConstraintIqctJqc.cpp +++ b/OndselSolver/TranslationConstraintIqctJqc.cpp @@ -12,7 +12,7 @@ using namespace MbD; -TranslationConstraintIqctJqc::TranslationConstraintIqctJqc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi) : +TranslationConstraintIqctJqc::TranslationConstraintIqctJqc(EndFrmsptr frmi, EndFrmsptr frmj, size_t axisi) : TranslationConstraintIqcJqc(frmi, frmj, axisi) { } diff --git a/OndselSolver/TranslationConstraintIqctJqc.h b/OndselSolver/TranslationConstraintIqctJqc.h index 2f8830b..997aa7a 100644 --- a/OndselSolver/TranslationConstraintIqctJqc.h +++ b/OndselSolver/TranslationConstraintIqctJqc.h @@ -15,7 +15,7 @@ namespace MbD { { //pGpt ppGpXIpt ppGpEIpt ppGpXJpt ppGpEJpt ppGptpt public: - TranslationConstraintIqctJqc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi); + TranslationConstraintIqctJqc(EndFrmsptr frmi, EndFrmsptr frmj, size_t axisi); void fillAccICIterError(FColDsptr col) override; void fillVelICError(FColDsptr col) override; diff --git a/OndselSolver/VectorNewtonRaphson.h b/OndselSolver/VectorNewtonRaphson.h index 251f777..d3eb6ce 100644 --- a/OndselSolver/VectorNewtonRaphson.h +++ b/OndselSolver/VectorNewtonRaphson.h @@ -8,6 +8,8 @@ #pragma once +#include + #include "NewtonRaphson.h" #include "MatrixSolver.h" @@ -30,7 +32,7 @@ namespace MbD { virtual void handleSingularMatrix() override; std::shared_ptr matrixSolver; - int n = -1; + size_t n = SIZE_MAX; FColDsptr xold, x, dx, y; //std::shared_ptr> pypx; }; diff --git a/OndselSolver/VelICSolver.cpp b/OndselSolver/VelICSolver.cpp index a611ae0..7f0a62b 100644 --- a/OndselSolver/VelICSolver.cpp +++ b/OndselSolver/VelICSolver.cpp @@ -19,7 +19,7 @@ void VelICSolver::assignEquationNumbers() //auto contactEndFrames = system->contactEndFrames(); //auto uHolders = system->uHolders(); auto constraints = system->allConstraints(); - int eqnNo = 0; + size_t eqnNo = 0; for (auto& part : *parts) { part->iqX(eqnNo); eqnNo = eqnNo + 3; diff --git a/OndselSolver/VelICSolver.h b/OndselSolver/VelICSolver.h index 0c722dd..15bef39 100644 --- a/OndselSolver/VelICSolver.h +++ b/OndselSolver/VelICSolver.h @@ -20,7 +20,7 @@ namespace MbD { void run() override; void runBasic(); - int nqsu = -1; + size_t nqsu = SIZE_MAX; }; } diff --git a/OndselSolver/VelKineSolver.cpp b/OndselSolver/VelKineSolver.cpp index 98d8ed6..4ba6be5 100644 --- a/OndselSolver/VelKineSolver.cpp +++ b/OndselSolver/VelKineSolver.cpp @@ -21,7 +21,7 @@ void VelKineSolver::assignEquationNumbers() //auto contactEndFrames = system->contactEndFrames(); //auto uHolders = system->uHolders(); auto constraints = system->allConstraints(); - int varNo = 0; + size_t varNo = 0; for (auto& part : *parts) { part->iqX(varNo); varNo = varNo + 3; diff --git a/OndselSolver/VelSolver.h b/OndselSolver/VelSolver.h index 718636e..4824801 100644 --- a/OndselSolver/VelSolver.h +++ b/OndselSolver/VelSolver.h @@ -30,7 +30,7 @@ namespace MbD { void setSystem(Solver* sys) override; SystemSolver* system = nullptr; - int n = -1; + size_t n = SIZE_MAX; FColDsptr x, errorVector; SpMatDsptr jacobian; std::shared_ptr matrixSolver; diff --git a/testapp/OndselSolver.cpp b/testapp/OndselSolver.cpp index 38861be..e919723 100644 --- a/testapp/OndselSolver.cpp +++ b/testapp/OndselSolver.cpp @@ -26,6 +26,7 @@ void sharedptrTest(); int main() { + ASMTAssembly::runFile("../testapp/pistonAllowZRotation.asmt"); ASMTAssembly::runDraggingTest(); ASMTAssembly::runFile("../testapp/Schmidt_Coupling_Ass_1-1.asmt"); ASMTAssembly::runFile("../testapp/RevRevJt.asmt"); diff --git a/testapp/pistonAllowZRotation.asmt b/testapp/pistonAllowZRotation.asmt new file mode 100644 index 0000000..bc2f89e --- /dev/null +++ b/testapp/pistonAllowZRotation.asmt @@ -0,0 +1,389 @@ +freeCAD: 3D CAD with Motion Simulation by askoh.com +Assembly + Notes + (Text string: 'CAD: Copyright (C) 2000-2004, Aik-Siong Koh, All Rights Reserved.The piston crank is the most common mechanism to convert rotary motion to reciprocating motion or vice versa. A crank connects to the ground with a revolute joint. Its other end is connected to the connecting rod. And the connecting rod is connected to the piston which slides along an axis on the ground. The crank is given rotary motion causing the piston to slides back and forth is a straight line. Units are SI units. Angles are in radians.If the instructions below are too brief, refer to the Notes in projectile.asm and circular.asm.To load the example for a quick look:Click File/Open/Assembly/ to get a dialog. Enter *.asm for a list of assemblies. Select piston.asm. To create the assembly from scratch:To create crank, connection rod and piston:Create an empty assembly and populate it with two rods (Assembly1Part1, Assembly1Part2) and one cylinder (Assembly1Part3). The rods have dimensions (1.0d, 0.2d, 0.1d) and (1.5d, 0.2d, 0.1d). The cylinder has radius (0.5d) and height (1.0d). Arrange them from bottom up away from the origin. To mark joint attachment points:On the ground, create a marker (Assembly1Marker1) at (0.0d, 0.0d, 0.0d) and another (Assembly1Marker2) at (3.0d, 0.0d, 0.0d). On the first rod, create a marker (Assembly1Part1Marker1) at (0.1d, 0.1d, 0.0d) and another (Assembly1Part1Marker2) at (0.9d, 0.1d, 0.0d) relative to the z-face. On the second rod, create a marker (Assembly1Part2Marker1) at (0.1d, 0.1d, -0.1d) and another (Assembly1Part2Marker2) at (1.4d, 0.1d, -0.1d) relative to the z-face. On the cylinder, create a marker (Assembly1Part3Marker1) at (0.0d, 0.0d, 0.0d) and another (Assembly1Part3Marker2) at (0.0d, 0.0d, -1.0d) relative to the z-face. Tilt the cylinder a little to get a good view of (Assembly1Part3Marker2). RightClick/Rotate/ over it to rotate the marker (90.0d) degrees about the x-axis.Tilt the cylinder upright to help the solver assemble the system later.To create the joints:Connect (Assembly1Marker1) to (Assembly1Part1Marker1) with revolute joint (Assembly1Joint1).Connect (Assembly1Part1Marker2) to (Assembly1Part2Marker1) with revolute joint (Assembly1Joint2).Connect (Assembly1Part2Marker2) to (Assembly1Part3Marker2) with revolute joint (Assembly1Joint3).Connect (Assembly1Marker2) to (Assembly1Part3Marker1) with translational joint (Assembly1Joint3).The translational joint keeps the marker z-axes parallel and colinear. Only relative translation along the z-axis is permitted.To apply motion to the crank:Apply rotation motion (Assembly1Motion1) to (Assembly1Joint1). Enter 2.0d*pi*time.The assembly is now ready for simulation, animation and plotting.' runs: (Core.RunArray runs: #(514 63 14 5 12 1 2 37 89 10 4 36 1 43 295 32 848 21 517 29 151) values: #(nil #underline #(#underline #bold) #underline #(#underline #bold) #underline nil #(#bold #large) nil #bold nil #(#bold #large) nil #bold nil #bold nil #bold nil #bold nil))) + Name + Assembly1 + Position3D + 0.0 0.0 0.0 + RotationMatrix + 1.0 0.0 0.0 + 0.0 1.0 0.0 + 0.0 0.0 1.0 + Velocity3D + 0.0 0.0 0.0 + Omega3D + 0.0 0.0 0.0 + RefPoints + RefPoint + Position3D + 0.0 0.0 0.0 + RotationMatrix + 1.0 0.0 0.0 + 0.0 1.0 0.0 + 0.0 0.0 1.0 + Markers + Marker + Name + Marker1 + Position3D + 0.0 3.0 0.0 + RotationMatrix + 1.0 0.0 0.0 + 0.0 0.0 1.0 + 0.0 -1.0 0.0 + RefPoint + Position3D + 0.0 0.0 0.0 + RotationMatrix + 1.0 0.0 0.0 + 0.0 1.0 0.0 + 0.0 0.0 1.0 + Markers + Marker + Name + Marker2 + Position3D + 0.0 0.0 0.0 + RotationMatrix + 1.0 0.0 0.0 + 0.0 1.0 0.0 + 0.0 0.0 1.0 + RefCurves + RefSurfaces + Parts + Part + Name + Part1 + Position3D + -0.1 -0.1 -0.1 + RotationMatrix + 1.0 0.0 0.0 + 0.0 1.0 0.0 + 0.0 0.0 1.0 + Velocity3D + 0.0 0.0 0.0 + Omega3D + 0.0 0.0 0.0 + FeatureOrder + Extrusion + zStart + 0.0 + zEnd + 0.1 + Sketch + Name + Sketch1 + Position3D + 0.0 0.0 0.0 + RotationMatrix + 1.0 0.0 0.0 + 0.0 1.0 0.0 + 0.0 0.0 1.0 + Graphics + Rectangle + Position2D + 0.0 0.0 + Angle + 0.0 + xLength + 1.0 + yLength + 0.2 + PrincipalMassMarker + Name + MassMarker + Position3D + 0.5 0.1 0.05 + RotationMatrix + 1.0 0.0 0.0 + 0.0 1.0 0.0 + 0.0 0.0 1.0 + Mass + 0.2 + MomentOfInertias + 8.3333333333333e-4 0.016833333333333 0.017333333333333 + Density + 10.0 + RefPoints + RefPoint + Position3D + 0.0 0.0 0.1 + RotationMatrix + 1.0 0.0 0.0 + 0.0 1.0 0.0 + 0.0 0.0 1.0 + Markers + Marker + Name + Marker1 + Position3D + 0.1 0.1 0.0 + RotationMatrix + 1.0 0.0 0.0 + 0.0 1.0 0.0 + 0.0 0.0 1.0 + RefPoint + Position3D + 0.0 0.0 0.1 + RotationMatrix + 1.0 0.0 0.0 + 0.0 1.0 0.0 + 0.0 0.0 1.0 + Markers + Marker + Name + Marker2 + Position3D + 0.9 0.1 0.0 + RotationMatrix + 1.0 0.0 0.0 + 0.0 1.0 0.0 + 0.0 0.0 1.0 + RefCurves + RefSurfaces + Part + Name + Part2 + Position3D + 0.94036115973815 -0.017284236661228 6.9388939039072e-18 + RotationMatrix + -0.61538461538462 -0.78822698199689 -2.4430659816416e-17 + 0.78822698199689 -0.61538461538462 3.1292471039841e-17 + -3.9699822201676e-17 -4.8559383484174e-33 1.0 + Velocity3D + 0.0 0.0 0.0 + Omega3D + 0.0 0.0 0.0 + FeatureOrder + Extrusion + zStart + 0.0 + zEnd + 0.1 + Sketch + Name + Sketch1 + Position3D + 0.0 0.0 0.0 + RotationMatrix + 1.0 0.0 0.0 + 0.0 1.0 0.0 + 0.0 0.0 1.0 + Graphics + Rectangle + Position2D + 0.0 0.0 + Angle + 0.0 + xLength + 1.5 + yLength + 0.2 + PrincipalMassMarker + Name + MassMarker + Position3D + 0.75 0.1 0.05 + RotationMatrix + 1.0 -2.7755575615629e-16 0.0 + 2.7755575615629e-16 1.0 0.0 + 0.0 0.0 1.0 + Mass + 0.3 + MomentOfInertias + 0.00125 0.0565 0.05725 + Density + 10.0 + RefPoints + RefPoint + Position3D + 0.0 0.0 0.1 + RotationMatrix + 1.0 0.0 0.0 + 0.0 1.0 0.0 + 0.0 0.0 1.0 + Markers + Marker + Name + Marker1 + Position3D + 0.1 0.1 -0.1 + RotationMatrix + 1.0 1.6433823482157e-50 6.1629758220392e-33 + 1.9277988905447e-49 1.0 1.055150120668e-32 + 6.1629758220392e-33 8.8305116654985e-33 1.0 + RefPoint + Position3D + -7.0256300777061e-17 -1.0408340855861e-17 0.1 + RotationMatrix + 1.0 1.7347234759768e-18 -6.9388939039072e-18 + 1.7347234759768e-18 1.0 0.0 + -6.9388939039072e-18 0.0 1.0 + Markers + Marker + Name + Marker2 + Position3D + 1.4 0.1 -0.1 + RotationMatrix + 1.0 1.9417266172265e-33 1.873501354055e-16 + 1.4257315131995e-48 1.0 4.1633363423443e-17 + -2.5673907444456e-16 -4.1633363423443e-17 1.0 + RefCurves + RefSurfaces + Part + Name + Part3 + Position3D + 1.8563657024101e-16 1.024695076596 -6.9385028492422e-17 + RotationMatrix + 1.0 1.7680967979307e-16 -2.2204460492503e-16 + 2.2204460492503e-16 6.3228810015037e-17 1.0 + 1.7680967979307e-16 -1.0 6.3228810015037e-17 + Velocity3D + 0.0 0.0 0.0 + Omega3D + 0.0 0.0 0.0 + FeatureOrder + Extrusion + zStart + 0.0 + zEnd + 1.0 + Sketch + Name + Sketch1 + Position3D + 0.0 0.0 0.0 + RotationMatrix + 1.0 0.0 0.0 + 0.0 1.0 0.0 + 0.0 0.0 1.0 + Graphics + Circle + Position2D + 0.0 0.0 + Angle + 0.0 + Radius + 0.5 + PrincipalMassMarker + Name + MassMarker + Position3D + -7.9328390680452e-18 2.9323172983667e-17 0.5 + RotationMatrix + 9.2444637330587e-33 1.0 -1.0785207688569e-32 + 9.9703461330478e-65 1.0785207688569e-32 1.0 + 1.0 -9.2444637330587e-33 0.0 + Mass + 7.6536686473018 + MomentOfInertias + 0.93243354610288 1.1040224936599 1.1040224936599 + Density + 10.0 + RefPoints + RefPoint + Position3D + 0.0 0.0 0.0 + RotationMatrix + 1.0 0.0 0.0 + 0.0 -1.0 0.0 + 0.0 0.0 -1.0 + Markers + Marker + Name + Marker1 + Position3D + 0.0 0.0 0.0 + RotationMatrix + 1.0 2.1223636732195e-32 -2.4651903288157e-32 + -2.4651903288157e-32 -2.2204460492503e-16 1.0 + -1.1179465652456e-32 -1.0 -2.2204460492503e-16 + RefPoint + Position3D + 1.0408340855861e-17 5.5511151231258e-17 1.0 + RotationMatrix + 1.0 -6.9388939039072e-18 6.9388939039072e-18 + -6.9388939039072e-18 1.0 0.0 + 6.9388939039072e-18 0.0 1.0 + Markers + Marker + Name + Marker2 + Position3D + 0.0 0.0 0.0 + RotationMatrix + 1.0 -4.1633363423442e-17 4.1633363423442e-17 + -4.1633363423442e-17 1.0 -4.9303806576313e-32 + 4.1633363423442e-17 -3.6977854932235e-32 1.0 + RefCurves + RefSurfaces + KinematicIJs + ConstraintSets + Joints + RevoluteJoint + Name + Joint1 + MarkerI + /Assembly1/Marker2 + MarkerJ + /Assembly1/Part1/Marker1 + RevoluteJoint + Name + Joint2 + MarkerI + /Assembly1/Part1/Marker2 + MarkerJ + /Assembly1/Part2/Marker1 + RevoluteJoint + Name + Joint3 + MarkerI + /Assembly1/Part2/Marker2 + MarkerJ + /Assembly1/Part3/Marker1 + CylindricalJoint + Name + Joint4 + MarkerI + /Assembly1/Part3/Marker2 + MarkerJ + /Assembly1/Marker1 + Motions + AllowRotation + Name + Motion1 + MotionJoint + /Assembly1/Joint1 + GeneralConstraintSets + ForceTorques + ConstantGravity + 0.0 -9.81 0.0 + SimulationParameters + tstart + 0.0 + tend + 1.0 + hmin + 1.0e-9 + hmax + 1.0 + hout + 0.04 + errorTol + 1.0e-6 + AnimationParameters + nframe + 26 + icurrent + 1 + istart + 1 + iend + 26 + isForward + true + framesPerSecond + 30