size_t and const
This commit is contained in:
committed by
PaddleStroke
parent
85557e1fa4
commit
3a9e7cecab
@@ -18,19 +18,19 @@ void MbD::ASMTAnimationParameters::parseASMT(std::vector<std::string>& lines)
|
||||
auto leadingTabs = lines[0].substr(0, pos);
|
||||
assert(lines[0] == (leadingTabs + "nframe"));
|
||||
lines.erase(lines.begin());
|
||||
nframe = readInt(lines[0]);
|
||||
nframe = readSize_t(lines[0]);
|
||||
lines.erase(lines.begin());
|
||||
assert(lines[0] == (leadingTabs + "icurrent"));
|
||||
lines.erase(lines.begin());
|
||||
icurrent = readInt(lines[0]);
|
||||
icurrent = readSize_t(lines[0]);
|
||||
lines.erase(lines.begin());
|
||||
assert(lines[0] == (leadingTabs + "istart"));
|
||||
lines.erase(lines.begin());
|
||||
istart = readInt(lines[0]);
|
||||
istart = readSize_t(lines[0]);
|
||||
lines.erase(lines.begin());
|
||||
assert(lines[0] == (leadingTabs + "iend"));
|
||||
lines.erase(lines.begin());
|
||||
iend = readInt(lines[0]);
|
||||
iend = readSize_t(lines[0]);
|
||||
lines.erase(lines.begin());
|
||||
assert(lines[0] == (leadingTabs + "isForward"));
|
||||
lines.erase(lines.begin());
|
||||
@@ -38,7 +38,7 @@ void MbD::ASMTAnimationParameters::parseASMT(std::vector<std::string>& lines)
|
||||
lines.erase(lines.begin());
|
||||
assert(lines[0] == (leadingTabs + "framesPerSecond"));
|
||||
lines.erase(lines.begin());
|
||||
framesPerSecond = readInt(lines[0]);
|
||||
framesPerSecond = readSize_t(lines[0]);
|
||||
lines.erase(lines.begin());
|
||||
|
||||
}
|
||||
@@ -47,15 +47,15 @@ void MbD::ASMTAnimationParameters::storeOnLevel(std::ofstream& os, size_t level)
|
||||
{
|
||||
storeOnLevelString(os, level, "AnimationParameters");
|
||||
storeOnLevelString(os, level + 1, "nframe");
|
||||
storeOnLevelInt(os, level + 2, nframe);
|
||||
storeOnLevelSize_t(os, level + 2, nframe);
|
||||
storeOnLevelString(os, level + 1, "icurrent");
|
||||
storeOnLevelInt(os, level + 2, icurrent);
|
||||
storeOnLevelSize_t(os, level + 2, icurrent);
|
||||
storeOnLevelString(os, level + 1, "istart");
|
||||
storeOnLevelInt(os, level + 2, istart);
|
||||
storeOnLevelSize_t(os, level + 2, istart);
|
||||
storeOnLevelString(os, level + 1, "iend");
|
||||
storeOnLevelInt(os, level + 2, iend);
|
||||
storeOnLevelSize_t(os, level + 2, iend);
|
||||
storeOnLevelString(os, level + 1, "isForward");
|
||||
storeOnLevelBool(os, level + 2, isForward);
|
||||
storeOnLevelString(os, level + 1, "framesPerSecond");
|
||||
storeOnLevelInt(os, level + 2, framesPerSecond);
|
||||
storeOnLevelSize_t(os, level + 2, framesPerSecond);
|
||||
}
|
||||
|
||||
@@ -440,7 +440,7 @@ void MbD::ASMTAssembly::runFile(const char* fileName)
|
||||
void MbD::ASMTAssembly::runDraggingTest()
|
||||
{
|
||||
auto assembly = ASMTAssembly::assemblyFromFile("../testapp/dragCrankSlider.asmt");
|
||||
auto dragPart = assembly->parts->at(0);
|
||||
auto& dragPart = assembly->parts->at(0);
|
||||
auto dragParts = std::make_shared<std::vector<std::shared_ptr<ASMTPart>>>();
|
||||
dragParts->push_back(dragPart);
|
||||
assembly->runPreDrag(); //Do this before first drag
|
||||
@@ -709,7 +709,7 @@ void MbD::ASMTAssembly::readMotions(std::vector<std::string>& lines)
|
||||
|
||||
}
|
||||
|
||||
void MbD::ASMTAssembly::readGeneralConstraintSets(std::vector<std::string>& lines)
|
||||
void MbD::ASMTAssembly::readGeneralConstraintSets(std::vector<std::string>& lines) const
|
||||
{
|
||||
assert(lines[0] == "\t\tGeneralConstraintSets");
|
||||
lines.erase(lines.begin());
|
||||
@@ -938,12 +938,12 @@ void MbD::ASMTAssembly::calcCharacteristicDimensions()
|
||||
this->mbdUnits = std::make_shared<Units>(1.0, 1.0, 1.0, 1.0); //for debug
|
||||
}
|
||||
|
||||
double MbD::ASMTAssembly::calcCharacteristicTime()
|
||||
double MbD::ASMTAssembly::calcCharacteristicTime() const
|
||||
{
|
||||
return std::abs(simulationParameters->hout);
|
||||
}
|
||||
|
||||
double MbD::ASMTAssembly::calcCharacteristicMass()
|
||||
double MbD::ASMTAssembly::calcCharacteristicMass() const
|
||||
{
|
||||
auto n = parts->size();
|
||||
double sumOfSquares = 0.0;
|
||||
@@ -957,7 +957,7 @@ double MbD::ASMTAssembly::calcCharacteristicMass()
|
||||
return unitMass;
|
||||
}
|
||||
|
||||
double MbD::ASMTAssembly::calcCharacteristicLength()
|
||||
double MbD::ASMTAssembly::calcCharacteristicLength() const
|
||||
{
|
||||
auto markerMap = this->markerMap();
|
||||
auto lengths = std::make_shared<std::vector<double>>();
|
||||
@@ -975,7 +975,7 @@ double MbD::ASMTAssembly::calcCharacteristicLength()
|
||||
return unitLength;
|
||||
}
|
||||
|
||||
std::shared_ptr<std::vector<std::shared_ptr<ASMTItemIJ>>> MbD::ASMTAssembly::connectorList()
|
||||
std::shared_ptr<std::vector<std::shared_ptr<ASMTItemIJ>>> MbD::ASMTAssembly::connectorList() const
|
||||
{
|
||||
auto list = std::make_shared<std::vector<std::shared_ptr<ASMTItemIJ>>>();
|
||||
list->insert(list->end(), joints->begin(), joints->end());
|
||||
@@ -985,7 +985,7 @@ std::shared_ptr<std::vector<std::shared_ptr<ASMTItemIJ>>> MbD::ASMTAssembly::con
|
||||
return list;
|
||||
}
|
||||
|
||||
std::shared_ptr<std::map<std::string, std::shared_ptr<ASMTMarker>>> MbD::ASMTAssembly::markerMap()
|
||||
std::shared_ptr<std::map<std::string, std::shared_ptr<ASMTMarker>>> MbD::ASMTAssembly::markerMap() const
|
||||
{
|
||||
auto answer = std::make_shared<std::map<std::string, std::shared_ptr<ASMTMarker>>>();
|
||||
for (auto& refPoint : *refPoints) {
|
||||
@@ -1109,7 +1109,7 @@ void MbD::ASMTAssembly::runPreDrag()
|
||||
}
|
||||
}
|
||||
|
||||
void MbD::ASMTAssembly::runDragStep(std::shared_ptr<std::vector<std::shared_ptr<ASMTPart>>> dragParts)
|
||||
void MbD::ASMTAssembly::runDragStep(std::shared_ptr<std::vector<std::shared_ptr<ASMTPart>>> dragParts) const
|
||||
{
|
||||
auto dragMbDParts = std::make_shared<std::vector<std::shared_ptr<Part>>>();
|
||||
for (auto& dragPart : *dragParts) {
|
||||
@@ -1146,7 +1146,7 @@ void MbD::ASMTAssembly::initprincipalMassMarker()
|
||||
//principalMassMarker->rotationMatrix = FullMatrix<double>>::identitysptr(3);
|
||||
}
|
||||
|
||||
std::shared_ptr<ASMTSpatialContainer> MbD::ASMTAssembly::spatialContainerAt(std::shared_ptr<ASMTAssembly> self, std::string& longname)
|
||||
std::shared_ptr<ASMTSpatialContainer> MbD::ASMTAssembly::spatialContainerAt(std::shared_ptr<ASMTAssembly> self, std::string& longname) const
|
||||
{
|
||||
if ((self->fullName("")) == longname) return self;
|
||||
auto it = std::find_if(parts->begin(), parts->end(), [&](const std::shared_ptr<ASMTPart>& prt) {
|
||||
@@ -1156,7 +1156,7 @@ std::shared_ptr<ASMTSpatialContainer> MbD::ASMTAssembly::spatialContainerAt(std:
|
||||
return part;
|
||||
}
|
||||
|
||||
std::shared_ptr<ASMTMarker> MbD::ASMTAssembly::markerAt(std::string& longname)
|
||||
std::shared_ptr<ASMTMarker> MbD::ASMTAssembly::markerAt(std::string& longname) const
|
||||
{
|
||||
for (auto& refPoint : *refPoints) {
|
||||
for (auto& marker : *refPoint->markers) {
|
||||
@@ -1173,7 +1173,7 @@ std::shared_ptr<ASMTMarker> MbD::ASMTAssembly::markerAt(std::string& longname)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<ASMTJoint> MbD::ASMTAssembly::jointAt(std::string& longname)
|
||||
std::shared_ptr<ASMTJoint> MbD::ASMTAssembly::jointAt(std::string& longname) const
|
||||
{
|
||||
auto it = std::find_if(joints->begin(), joints->end(), [&](const std::shared_ptr<ASMTJoint>& jt) {
|
||||
return jt->fullName("") == longname;
|
||||
@@ -1182,7 +1182,7 @@ std::shared_ptr<ASMTJoint> MbD::ASMTAssembly::jointAt(std::string& longname)
|
||||
return joint;
|
||||
}
|
||||
|
||||
std::shared_ptr<ASMTMotion> MbD::ASMTAssembly::motionAt(std::string& longname)
|
||||
std::shared_ptr<ASMTMotion> MbD::ASMTAssembly::motionAt(std::string& longname) const
|
||||
{
|
||||
auto it = std::find_if(motions->begin(), motions->end(), [&](const std::shared_ptr<ASMTMotion>& mt) {
|
||||
return mt->fullName("") == longname;
|
||||
@@ -1191,7 +1191,7 @@ std::shared_ptr<ASMTMotion> MbD::ASMTAssembly::motionAt(std::string& longname)
|
||||
return motion;
|
||||
}
|
||||
|
||||
std::shared_ptr<ASMTForceTorque> MbD::ASMTAssembly::forceTorqueAt(std::string& longname)
|
||||
std::shared_ptr<ASMTForceTorque> MbD::ASMTAssembly::forceTorqueAt(std::string& longname) const
|
||||
{
|
||||
auto it = std::find_if(forcesTorques->begin(), forcesTorques->end(), [&](const std::shared_ptr<ASMTForceTorque>& mt) {
|
||||
return mt->fullName("") == longname;
|
||||
@@ -1210,7 +1210,7 @@ FColDsptr MbD::ASMTAssembly::omeOpO()
|
||||
return std::make_shared<FullColumn<double>>(3, 0.0);
|
||||
}
|
||||
|
||||
std::shared_ptr<ASMTTime> MbD::ASMTAssembly::geoTime()
|
||||
std::shared_ptr<ASMTTime> MbD::ASMTAssembly::geoTime() const
|
||||
{
|
||||
return asmtTime;
|
||||
}
|
||||
@@ -1276,7 +1276,7 @@ void MbD::ASMTAssembly::setSimulationParameters(std::shared_ptr<ASMTSimulationPa
|
||||
parameters->owner = this;
|
||||
}
|
||||
|
||||
std::shared_ptr<ASMTPart> MbD::ASMTAssembly::partNamed(std::string partName)
|
||||
std::shared_ptr<ASMTPart> MbD::ASMTAssembly::partNamed(std::string partName) const
|
||||
{
|
||||
auto it = std::find_if(parts->begin(), parts->end(), [&](const std::shared_ptr<ASMTPart>& prt) {
|
||||
return prt->fullName("") == partName;
|
||||
@@ -1285,7 +1285,7 @@ std::shared_ptr<ASMTPart> MbD::ASMTAssembly::partNamed(std::string partName)
|
||||
return part;
|
||||
}
|
||||
|
||||
std::shared_ptr<ASMTPart> MbD::ASMTAssembly::partPartialNamed(std::string partialName)
|
||||
std::shared_ptr<ASMTPart> MbD::ASMTAssembly::partPartialNamed(std::string partialName) const
|
||||
{
|
||||
auto it = std::find_if(parts->begin(), parts->end(), [&](const std::shared_ptr<ASMTPart>& prt) {
|
||||
auto fullName = prt->fullName("");
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace MbD {
|
||||
void readConstraintSets(std::vector<std::string>& lines);
|
||||
void readJoints(std::vector<std::string>& lines);
|
||||
void readMotions(std::vector<std::string>& lines);
|
||||
void readGeneralConstraintSets(std::vector<std::string>& lines);
|
||||
void readGeneralConstraintSets(std::vector<std::string>& lines) const;
|
||||
void readForcesTorques(std::vector<std::string>& lines);
|
||||
void readConstantGravity(std::vector<std::string>& lines);
|
||||
void readSimulationParameters(std::vector<std::string>& lines);
|
||||
@@ -73,11 +73,11 @@ namespace MbD {
|
||||
void preMbDrun(std::shared_ptr<System> mbdSys);
|
||||
void postMbDrun();
|
||||
void calcCharacteristicDimensions();
|
||||
double calcCharacteristicTime();
|
||||
double calcCharacteristicMass();
|
||||
double calcCharacteristicLength();
|
||||
std::shared_ptr<std::vector<std::shared_ptr<ASMTItemIJ>>> connectorList();
|
||||
std::shared_ptr<std::map<std::string, std::shared_ptr<ASMTMarker>>>markerMap();
|
||||
double calcCharacteristicTime() const;
|
||||
double calcCharacteristicMass() const;
|
||||
double calcCharacteristicLength() const;
|
||||
std::shared_ptr<std::vector<std::shared_ptr<ASMTItemIJ>>> connectorList() const;
|
||||
std::shared_ptr<std::map<std::string, std::shared_ptr<ASMTMarker>>>markerMap() const;
|
||||
void deleteMbD() override;
|
||||
void createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits) override;
|
||||
void outputFile(std::string filename);
|
||||
@@ -87,18 +87,18 @@ namespace MbD {
|
||||
void solve();
|
||||
|
||||
void runPreDrag();
|
||||
void runDragStep(std::shared_ptr<std::vector<std::shared_ptr<ASMTPart>>> dragParts);
|
||||
void runDragStep(std::shared_ptr<std::vector<std::shared_ptr<ASMTPart>>> dragParts) const;
|
||||
void runPostDrag();
|
||||
void runKINEMATIC();
|
||||
void initprincipalMassMarker();
|
||||
std::shared_ptr<ASMTSpatialContainer> spatialContainerAt(std::shared_ptr<ASMTAssembly> self, std::string& longname);
|
||||
std::shared_ptr<ASMTMarker> markerAt(std::string& longname);
|
||||
std::shared_ptr<ASMTJoint> jointAt(std::string& longname);
|
||||
std::shared_ptr<ASMTMotion> motionAt(std::string& longname);
|
||||
std::shared_ptr<ASMTForceTorque> forceTorqueAt(std::string& longname);
|
||||
std::shared_ptr<ASMTSpatialContainer> spatialContainerAt(std::shared_ptr<ASMTAssembly> self, std::string& longname) const;
|
||||
std::shared_ptr<ASMTMarker> markerAt(std::string& longname) const;
|
||||
std::shared_ptr<ASMTJoint> jointAt(std::string& longname) const;
|
||||
std::shared_ptr<ASMTMotion> motionAt(std::string& longname) const;
|
||||
std::shared_ptr<ASMTForceTorque> forceTorqueAt(std::string& longname) const;
|
||||
FColDsptr vOcmO() override;
|
||||
FColDsptr omeOpO() override;
|
||||
std::shared_ptr<ASMTTime> geoTime();
|
||||
std::shared_ptr<ASMTTime> geoTime() const;
|
||||
void updateFromMbD() override;
|
||||
void compareResults(AnalysisType type) override;
|
||||
void outputResults(AnalysisType type) override;
|
||||
@@ -107,8 +107,8 @@ namespace MbD {
|
||||
void addMotion(std::shared_ptr<ASMTMotion> motion);
|
||||
void setConstantGravity(std::shared_ptr<ASMTConstantGravity> constantGravity);
|
||||
void setSimulationParameters(std::shared_ptr<ASMTSimulationParameters> simulationParameters);
|
||||
std::shared_ptr<ASMTPart> partNamed(std::string partName);
|
||||
std::shared_ptr<ASMTPart> partPartialNamed(std::string partialName);
|
||||
std::shared_ptr<ASMTPart> partNamed(std::string partName) const;
|
||||
std::shared_ptr<ASMTPart> partPartialNamed(std::string partialName) const;
|
||||
void storeOnLevelNotes(std::ofstream& os, size_t level);
|
||||
void storeOnLevelParts(std::ofstream& os, size_t level);
|
||||
void storeOnLevelKinematicIJs(std::ofstream& os, size_t level);
|
||||
|
||||
@@ -110,6 +110,14 @@ int MbD::ASMTItem::readInt(std::string& line)
|
||||
return i;
|
||||
}
|
||||
|
||||
size_t MbD::ASMTItem::readSize_t(std::string& line)
|
||||
{
|
||||
std::istringstream iss(line);
|
||||
size_t i;
|
||||
iss >> i;
|
||||
return i;
|
||||
}
|
||||
|
||||
bool MbD::ASMTItem::readBool(std::string& line)
|
||||
{
|
||||
if (line.find("true") != std::string::npos)
|
||||
@@ -231,6 +239,12 @@ void MbD::ASMTItem::storeOnLevelInt(std::ofstream& os, size_t level, int i)
|
||||
os << i << std::endl;
|
||||
}
|
||||
|
||||
void MbD::ASMTItem::storeOnLevelSize_t(std::ofstream& os, size_t level, size_t i)
|
||||
{
|
||||
storeOnLevelTabs(os, level);
|
||||
os << i << std::endl;
|
||||
}
|
||||
|
||||
void MbD::ASMTItem::storeOnLevelBool(std::ofstream& os, size_t level, bool value)
|
||||
{
|
||||
storeOnLevelTabs(os, level);
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace MbD {
|
||||
FColDsptr readColumnOfDoubles(std::string& line);
|
||||
double readDouble(std::string& line);
|
||||
int readInt(std::string& line);
|
||||
size_t readSize_t(std::string& line);
|
||||
bool readBool(std::string& line);
|
||||
std::string readString(std::string& line);
|
||||
void readName(std::vector<std::string>& lines);
|
||||
@@ -53,6 +54,7 @@ namespace MbD {
|
||||
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 storeOnLevelSize_t(std::ofstream& os, size_t level, size_t i);
|
||||
virtual void storeOnLevelBool(std::ofstream& os, size_t level, bool value);
|
||||
//template<typename T>
|
||||
//void storeOnLevelArray(std::ofstream& os, size_t level, std::vector<T> array);
|
||||
|
||||
@@ -21,7 +21,7 @@ void GEFullMat::backSubstituteIntoDU()
|
||||
{
|
||||
answerX = std::make_shared<FullColumn<double>>(n);
|
||||
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
|
||||
for (int i = (int)n - 2; i >= 0; i--) //Use int because of decrement
|
||||
{
|
||||
auto rowi = matrixA->at(i);
|
||||
double sum = answerX->at(n) * rowi->at(n);
|
||||
|
||||
@@ -118,7 +118,7 @@ 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--) //Use int because of decrement
|
||||
for (int i = (int)n - 2; i >= 0; i--) //Use int because of decrement
|
||||
{
|
||||
auto& rowi = matrixA->at(i);
|
||||
sum = 0.0; // rhsZeroElement copy.
|
||||
|
||||
@@ -54,7 +54,7 @@ void GESpMatParPv::backSubstituteIntoDU()
|
||||
answerX = std::make_shared<FullColumn<double>>(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--) //Use int because of decrement
|
||||
for (int i = (int)n - 2; i >= 0; i--) //Use int because of decrement
|
||||
{
|
||||
auto rowi = matrixA->at(i);
|
||||
sum = 0.0; // rhsZeroElement copy.
|
||||
|
||||
@@ -26,7 +26,7 @@ void GESpMatParPvMarko::doPivoting(size_t p)
|
||||
SpRowDsptr spRowi;
|
||||
rowPositionsOfNonZerosInPivotColumn->clear();
|
||||
auto lookForFirstNonZeroInPivotCol = true;
|
||||
i = m - 1;
|
||||
i = (int)m - 1;
|
||||
while (lookForFirstNonZeroInPivotCol) {
|
||||
spRowi = matrixA->at(i);
|
||||
if (spRowi->find(p) == spRowi->end()) {
|
||||
|
||||
@@ -57,7 +57,7 @@ void GESpMatParPvMarkoFast::doPivoting(size_t p)
|
||||
SpRowDsptr spRowi;
|
||||
rowPositionsOfNonZerosInPivotColumn->clear();
|
||||
auto lookForFirstNonZeroInPivotCol = true;
|
||||
i = m - 1;
|
||||
i = (int)m - 1;
|
||||
while (lookForFirstNonZeroInPivotCol) {
|
||||
spRowi = matrixA->at(i);
|
||||
if (spRowi->find(p) == spRowi->end()) {
|
||||
|
||||
@@ -26,7 +26,7 @@ void GESpMatParPvPrecise::doPivoting(size_t p)
|
||||
SpRowDsptr spRowi;
|
||||
rowPositionsOfNonZerosInPivotColumn->clear();
|
||||
auto lookForFirstNonZeroInPivotCol = true;
|
||||
i = m - 1;
|
||||
i = (int)m - 1;
|
||||
while (lookForFirstNonZeroInPivotCol) {
|
||||
spRowi = matrixA->at(i);
|
||||
if (spRowi->find(p) == spRowi->end()) {
|
||||
|
||||
@@ -36,7 +36,7 @@ void MbD::GeneralSpline::arguments(Symsptr args)
|
||||
{
|
||||
auto array = args->getTerms();
|
||||
auto& arg = array->at(0);
|
||||
size_t order = array->at(1)->getValue();
|
||||
size_t order = (size_t)array->at(1)->getValue();
|
||||
size_t n = (array->size() - 2) / 2;
|
||||
auto xarray = std::make_shared<std::vector<double>>(n);
|
||||
auto yarray = std::make_shared<std::vector<double>>(n);
|
||||
@@ -136,7 +136,7 @@ void MbD::GeneralSpline::computeDerivatives()
|
||||
}
|
||||
}
|
||||
|
||||
bool MbD::GeneralSpline::isCyclic()
|
||||
bool MbD::GeneralSpline::isCyclic() const
|
||||
{
|
||||
return (ys->size() > 3) && (ys->front() == ys->back());
|
||||
}
|
||||
@@ -149,9 +149,9 @@ double MbD::GeneralSpline::derivativeAt(size_t n, double xxx)
|
||||
calcIndexAndDeltaFor(xxx);
|
||||
auto& derivsi = derivs->at(index);
|
||||
double sum = 0.0;
|
||||
for (int j = degree; j >= n + 1; j--) //Use int because of decrement
|
||||
for (int j = (int)degree; j >= n + 1; j--) //Use int because of decrement
|
||||
{
|
||||
sum = (sum + derivsi->at(j - 1)) * delta / (j - n);
|
||||
sum = (sum + derivsi->at((size_t)j - 1)) * delta / (j - n);
|
||||
}
|
||||
return derivsi->at(n - 1) + sum;
|
||||
}
|
||||
@@ -209,7 +209,7 @@ void MbD::GeneralSpline::searchIndexFromto(size_t first, size_t last)
|
||||
index = first;
|
||||
}
|
||||
else {
|
||||
auto middle = std::floor((first + last) / 2);
|
||||
auto middle = (size_t)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--) //Use int because of decrement
|
||||
for (int j = (int)degree; j >= 1; j--) //Use int because of decrement
|
||||
{
|
||||
sum = (sum + derivsi->at(j - 1)) * delta / j;
|
||||
sum = (sum + derivsi->at((size_t)j - 1)) * delta / j;
|
||||
}
|
||||
return ys->at(index) + sum;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace MbD {
|
||||
void arguments(Symsptr args) override;
|
||||
void initxdegreexsys(Symsptr arg, size_t order, std::shared_ptr<std::vector<double>> xarr, std::shared_ptr<std::vector<double>> yarr);
|
||||
void computeDerivatives();
|
||||
bool isCyclic();
|
||||
bool isCyclic() const;
|
||||
double derivativeAt(size_t derivativeOrder, double arg);
|
||||
void calcIndexAndDeltaFor(double xxx);
|
||||
void calcCyclicIndexAndDelta();
|
||||
|
||||
@@ -156,11 +156,11 @@ void LDUFullMat::backSubstituteIntoDU()
|
||||
//| rowi sum |
|
||||
answerX = std::make_shared<FullColumn<double>>(n);
|
||||
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
|
||||
for (int i = (int)n - 2; i >= 0; i--) //Use int because of decrement
|
||||
{
|
||||
auto& rowi = matrixA->at(i);
|
||||
double sum = answerX->at((size_t)n - 1) * rowi->at((size_t)n - 1);
|
||||
for (size_t j = i + 1; j < n - 1; j++)
|
||||
for (int j = i + 1; j < n - 1; j++)
|
||||
{
|
||||
sum += answerX->at(j) * rowi->at(j);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ void LDUSpMat::forwardSubstituteIntoL()
|
||||
vectorc->at(0) = rightHandSideB->at(0);
|
||||
for (size_t i = 1; i < n; i++)
|
||||
{
|
||||
auto rowi = matrixA->at(i);
|
||||
auto& rowi = matrixA->at(i);
|
||||
double sum = 0.0;
|
||||
for (auto const& keyValue : *rowi) {
|
||||
size_t j = keyValue.first;
|
||||
@@ -69,9 +69,9 @@ void LDUSpMat::backSubstituteIntoDU()
|
||||
}
|
||||
answerX = std::make_shared<FullColumn<double>>(m);
|
||||
answerX->at(n - 1) = rightHandSideB->at(m - 1);
|
||||
for (int i = n - 2; i >= 0; i--) //Use int because of decrement
|
||||
for (int i = (int)n - 2; i >= 0; i--) //Use int because of decrement
|
||||
{
|
||||
auto rowi = matrixU->at(i);
|
||||
auto& rowi = matrixU->at(i);
|
||||
sum = 0.0;
|
||||
for (auto const& keyValue : *rowi) {
|
||||
auto j = keyValue.first;
|
||||
|
||||
@@ -24,7 +24,7 @@ void LDUSpMatParPvMarko::doPivoting(size_t p)
|
||||
SpRowDsptr spRowi;
|
||||
rowPositionsOfNonZerosInPivotColumn->clear();
|
||||
auto lookForFirstNonZeroInPivotCol = true;
|
||||
i = m - 1;
|
||||
i = (int)m - 1;
|
||||
while (lookForFirstNonZeroInPivotCol) {
|
||||
spRowi = matrixA->at(i);
|
||||
if (spRowi->find(p) == spRowi->end()) {
|
||||
|
||||
@@ -24,7 +24,7 @@ void LDUSpMatParPvPrecise::doPivoting(size_t p)
|
||||
SpRowDsptr spRowi;
|
||||
rowPositionsOfNonZerosInPivotColumn->clear();
|
||||
auto lookForFirstNonZeroInPivotCol = true;
|
||||
i = m - 1;
|
||||
i = (int)m - 1;
|
||||
while (lookForFirstNonZeroInPivotCol) {
|
||||
spRowi = matrixA->at(i);
|
||||
if (spRowi->find(p) == spRowi->end()) {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include <cstddef>
|
||||
#include <limits>
|
||||
|
||||
#include "MbDMath.h"
|
||||
|
||||
@@ -64,7 +64,7 @@ void MbD::SymbolicParser::parseString(std::string expr)
|
||||
}
|
||||
source = std::make_shared<std::istringstream>(expr);
|
||||
hereChar = source->get();
|
||||
prevEnd = SIZE_MAX;
|
||||
prevEnd = -1;
|
||||
scanToken();
|
||||
expression();
|
||||
if (tokenType != "end") expected("Nothing more");
|
||||
@@ -480,12 +480,12 @@ bool MbD::SymbolicParser::peekForTypevalue(std::string type, std::string symbol)
|
||||
return false;
|
||||
}
|
||||
|
||||
void MbD::SymbolicParser::notify(std::string msg)
|
||||
void MbD::SymbolicParser::notify(std::string msg) const
|
||||
{
|
||||
notifyat(msg, mark);
|
||||
}
|
||||
|
||||
void MbD::SymbolicParser::notifyat(std::string, int)
|
||||
void MbD::SymbolicParser::notifyat(std::string, int) const
|
||||
{
|
||||
//"Temporarily reset source in order to get full contents"
|
||||
auto p = source->tellg();
|
||||
@@ -501,7 +501,7 @@ void MbD::SymbolicParser::notifyat(std::string, int)
|
||||
//raiseSignal
|
||||
}
|
||||
|
||||
void MbD::SymbolicParser::combineStackTo(size_t pos)
|
||||
void MbD::SymbolicParser::combineStackTo(size_t pos) const
|
||||
{
|
||||
auto args = std::make_shared<std::vector<Symsptr>>();
|
||||
while (stack->size() > pos) {
|
||||
@@ -515,7 +515,7 @@ void MbD::SymbolicParser::combineStackTo(size_t pos)
|
||||
stack->push(sum);
|
||||
}
|
||||
|
||||
bool MbD::SymbolicParser::isNextLineTag(char c)
|
||||
bool MbD::SymbolicParser::isNextLineTag(char c) const
|
||||
{
|
||||
//Skip <n> tag in asmt file
|
||||
auto pos = source->tellg();
|
||||
|
||||
@@ -49,16 +49,16 @@ namespace MbD {
|
||||
bool expected(std::string msg);
|
||||
bool signedNumber();
|
||||
bool peekForTypevalue(std::string type, std::string symbol);
|
||||
void notify(std::string msg);
|
||||
void notifyat(std::string msg, int mrk);
|
||||
void combineStackTo(size_t pos);
|
||||
bool isNextLineTag(char c);
|
||||
void notify(std::string msg) const;
|
||||
void notifyat(std::string msg, int mrk) const;
|
||||
void combineStackTo(size_t pos) const;
|
||||
bool isNextLineTag(char c) const;
|
||||
|
||||
ASMTItem* owner = nullptr;
|
||||
std::shared_ptr<std::map<std::string, Symsptr>> variables;
|
||||
std::shared_ptr<std::vector<ASMTItemIJ>> geoIJs;
|
||||
std::shared_ptr<Units> units;
|
||||
int mark = SIZE_MAX, prevEnd = SIZE_MAX;
|
||||
int mark = -1, prevEnd = -1;
|
||||
char hereChar = '\0';
|
||||
std::string token, tokenType;
|
||||
double tokenNum = -1.0e100;
|
||||
|
||||
Reference in New Issue
Block a user