WIP: fixes mac errors and warnings (#34)

* fixes mac errors and warnings; check on TODO items

* renamed function as override was not of virtual

* removed another using

* experimental adjustment

* move fcDot to public

* renaming things
This commit is contained in:
John Dupuy
2023-11-21 09:16:25 -06:00
committed by GitHub
parent 6f4fca7efb
commit 3952f45945
41 changed files with 137 additions and 146 deletions

View File

@@ -192,6 +192,7 @@ set(ONDSELSOLVER_SRC
OndselSolver/IndependentVariable.cpp
OndselSolver/InLineJoint.cpp
OndselSolver/InPlaneJoint.cpp
OndselSolver/Integral.cpp
OndselSolver/Integrator.cpp
OndselSolver/IntegratorInterface.cpp
OndselSolver/Item.cpp
@@ -220,6 +221,7 @@ set(ONDSELSOLVER_SRC
OndselSolver/MBDynBody.cpp
OndselSolver/MBDynControlData.cpp
OndselSolver/MBDynData.cpp
OndselSolver/MBDynDrive.cpp
OndselSolver/MBDynElement.cpp
OndselSolver/MBDynInitialValue.cpp
OndselSolver/MBDynItem.cpp
@@ -244,9 +246,11 @@ set(ONDSELSOLVER_SRC
OndselSolver/Part.cpp
OndselSolver/PartFrame.cpp
OndselSolver/PerpendicularJoint.cpp
OndselSolver/PiecewiseFunction.cpp
OndselSolver/PlanarJoint.cpp
OndselSolver/PointInLineJoint.cpp
OndselSolver/PointInPlaneJoint.cpp
OndselSolver/Polynomial.cpp
OndselSolver/PosICKineNewtonRaphson.cpp
OndselSolver/PosICNewtonRaphson.cpp
OndselSolver/PosKineNewtonRaphson.cpp
@@ -260,6 +264,7 @@ set(ONDSELSOLVER_SRC
OndselSolver/RackPinConstraintIqcJc.cpp
OndselSolver/RackPinConstraintIqcJqc.cpp
OndselSolver/RackPinJoint.cpp
OndselSolver/RampStepFunction.cpp
OndselSolver/Reciprocal.cpp
OndselSolver/RedundantConstraint.cpp
OndselSolver/RevCylJoint.cpp

View File

@@ -18,7 +18,7 @@ namespace MbD {
//
public:
void deleteMbD();
void createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits);
void createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits) override;
Symsptr expandUntil(Symsptr sptr, std::shared_ptr<std::unordered_set<Symsptr>> set) override;
Symsptr simplifyUntil(Symsptr sptr, std::shared_ptr<std::unordered_set<Symsptr>> set) override;
bool isVariable() override;

View File

@@ -126,18 +126,17 @@ void AccNewtonRaphson::preRun()
void MbD::AccNewtonRaphson::handleSingularMatrix()
{
std::string str = typeid(*matrixSolver).name();
auto& r = *matrixSolver;
std::string str = typeid(r).name();
if (str.find("GESpMatParPvMarkoFast") != std::string::npos) {
matrixSolver = CREATE<GESpMatParPvPrecise>::With();
this->solveEquations();
}
else {
str = typeid(*matrixSolver).name();
} else {
str = typeid(r).name();
if (str.find("GESpMatParPvPrecise") != std::string::npos) {
this->logSingularMatrixMessage();
matrixSolver->throwSingularMatrixError("AccAccNewtonRaphson");
}
else {
} else {
assert(false);
}
}

View File

@@ -29,7 +29,7 @@ void MbD::AngleZIecJec::calcPostDynCorrectorIteration()
auto diffOfSquares = sthez * sthez - (cthez * cthez);
auto sumOfSquaresSquared = sumOfSquares * sumOfSquares;
auto thez0to2pi = Numeric::arcTan0to2piYoverX(sthez, cthez);
thez = std::round(thez - thez0to2pi / (2.0 * M_PI)) * (2.0 * M_PI) + thez0to2pi;
thez = std::round(thez - thez0to2pi / (2.0 * OS_M_PI)) * (2.0 * OS_M_PI) + thez0to2pi;
cosOverSSq = cthez / sumOfSquares;
sinOverSSq = sthez / sumOfSquares;
twoCosSinOverSSqSq = 2.0 * cthez * sthez / sumOfSquaresSquared;

View File

@@ -9,29 +9,28 @@
#include <memory>
#include "DirectionCosineIecJec.h"
#include "FullColumn.h"
#include "EndFramec.h"
using namespace MbD;
namespace MbD {
DirectionCosineIecJec::DirectionCosineIecJec()
= default;
DirectionCosineIecJec::DirectionCosineIecJec()
{
DirectionCosineIecJec::DirectionCosineIecJec(EndFrmsptr frmi, EndFrmsptr frmj, int axisi, int axisj) :
KinematicIeJe(frmi, frmj), axisI(axisi), axisJ(axisj)
{
}
void DirectionCosineIecJec::calcPostDynCorrectorIteration()
{
aAjOIe = frmI->aAjOe(axisI);
aAjOJe = frmJ->aAjOe(axisJ);
aAijIeJe = aAjOIe->dotVec(aAjOJe);
}
double MbD::DirectionCosineIecJec::value()
{
return aAijIeJe;
}
}
DirectionCosineIecJec::DirectionCosineIecJec(EndFrmsptr frmi, EndFrmsptr frmj, int axisi, int axisj) :
KinematicIeJe(frmi, frmj), axisI(axisi), axisJ(axisj)
{
}
void DirectionCosineIecJec::calcPostDynCorrectorIteration()
{
aAjOIe = frmI->aAjOe(axisI);
aAjOJe = frmJ->aAjOe(axisJ);
aAijIeJe = aAjOIe->dot(aAjOJe);
}
double MbD::DirectionCosineIecJec::value()
{
return aAijIeJe;
}

View File

@@ -10,11 +10,10 @@
#include <memory>
#include "FullColumn.h"
#include "KinematicIeJe.h"
namespace MbD {
template<typename T>
class FullColumn;
class DirectionCosineIecJec : public KinematicIeJe
{
@@ -26,8 +25,8 @@ namespace MbD {
void calcPostDynCorrectorIteration() override;
double value() override;
int axisI, axisJ; //0, 1, 2 = x, y, z
double aAijIeJe;
int axisI{}, axisJ{}; //0, 1, 2 = x, y, z
double aAijIeJe{};
FColDsptr aAjOIe, aAjOJe;
};
}

View File

@@ -56,7 +56,7 @@ void DirectionCosineIeqcJec::calcPostDynCorrectorIteration()
auto& ppAjOIepEIipEI = ppAjOIepEIpEI->at(i);
for (int j = 0; j < 4; j++)
{
ppAijIeJepEIipEI->at(j) = ppAjOIepEIipEI->at(j)->dot(aAjOJe);
ppAijIeJepEIipEI->at(j) = ppAjOIepEIipEI->at(j)->dotVec(aAjOJe);
}
}
ppAijIeJepEIpEI->symLowerWithUpper();

View File

@@ -45,7 +45,7 @@ void DirectionCosineIeqcJeqc::calcPostDynCorrectorIteration()
pAjOJepEJT = std::static_pointer_cast<EndFrameqc>(frmJ)->pAjOepET(axisJ);
for (int i = 0; i < 4; i++)
{
pAijIeJepEJ->at(i) = aAjOIe->dot(pAjOJepEJT->at(i));
pAijIeJepEJ->at(i) = aAjOIe->dotVec(pAjOJepEJT->at(i));
}
for (int i = 0; i < 4; i++)
{
@@ -61,7 +61,7 @@ void DirectionCosineIeqcJeqc::calcPostDynCorrectorIteration()
auto& ppAjOJepEJipEJ = ppAjOJepEJpEJ->at(i);
for (int j = 0; j < 4; j++)
{
ppAijIeJepEJipEJ->at(j) = aAjOIe->dot(ppAjOJepEJipEJ->at(j));
ppAijIeJepEJipEJ->at(j) = aAjOIe->dotVec(ppAjOJepEJipEJ->at(j));
}
}
ppAijIeJepEJpEJ->symLowerWithUpper();

View File

@@ -60,7 +60,7 @@ void DirectionCosineIeqctJeqc::preVelIC()
{
Item::preVelIC();
auto pAjOIept = std::static_pointer_cast<EndFrameqct>(frmI)->pAjOept(axisI);
pAijIeJept = pAjOIept->dot(aAjOJe);
pAijIeJept = pAjOIept->dotVec(aAjOJe);
}
double DirectionCosineIeqctJeqc::pvaluept()
@@ -82,7 +82,7 @@ void DirectionCosineIeqctJeqc::preAccIC()
}
for (int i = 0; i < 4; i++)
{
ppAijIeJepEJpt->atiput(i, pAjOIept->dot(pAjOJepEJT->at(i)));
ppAijIeJepEJpt->atiput(i, pAjOIept->dotVec(pAjOJepEJT->at(i)));
}
ppAijIeJeptpt = ppAjOIeptpt->dot(aAjOJe);
ppAijIeJeptpt = ppAjOIeptpt->dotVec(aAjOJe);
}

View File

@@ -23,7 +23,7 @@ void MbD::DispCompIecJecIe::calc_value()
{
aAjOIe = frmI->aAjOe(axis);
rIeJeO = frmJ->rOeO->minusFullColumn(frmI->rOeO);
riIeJeIe = aAjOIe->dot(rIeJeO);
riIeJeIe = aAjOIe->dotVec(rIeJeO);
}
void MbD::DispCompIecJecIe::calcPostDynCorrectorIteration()

View File

@@ -37,7 +37,7 @@ void DispCompIecJecKeqc::calcPostDynCorrectorIteration()
auto efrmKqc = std::static_pointer_cast<EndFrameqc>(efrmK);
aAjOKe = efrmKqc->aAjOe(axisK);
rIeJeO = frmJqc->rOeO->minusFullColumn(frmIqc->rOeO);
riIeJeKe = aAjOKe->dot(rIeJeO);
riIeJeKe = aAjOKe->dotVec(rIeJeO);
pAjOKepEKT = efrmKqc->pAjOepET(axisK);
ppAjOKepEKpEK = efrmKqc->ppAjOepEpE(axisK);
for (int i = 0; i < 4; i++)
@@ -45,10 +45,10 @@ void DispCompIecJecKeqc::calcPostDynCorrectorIteration()
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));
ppriIeJeKepEKipEK->at(i) = ((ppAjOKepEKipEK->at(i))->dotVec(rIeJeO));
for (int j = i + 1; j < 4; j++)
{
auto ppriIeJeKepEKipEKj = (ppAjOKepEKipEK->at(i))->dot(rIeJeO);
auto ppriIeJeKepEKipEKj = (ppAjOKepEKipEK->at(i))->dotVec(rIeJeO);
ppriIeJeKepEKipEK->at(j) = ppriIeJeKepEKipEKj;
ppriIeJeKepEKpEK->at(j)->at(i) = ppriIeJeKepEKipEKj;
}

View File

@@ -31,10 +31,10 @@ void MbD::DispCompIeqcJecIe::calc_ppvaluepEIpEI()
auto ppriIeJeIepEIipEI = ppriIeJeIepEIpEI->at(i);
for (int j = i; j < 4; j++)
{
auto term1 = ppAjOIepEIipEI->at(j)->dot(rIeJeO);
auto term1 = ppAjOIepEIipEI->at(j)->dotVec(rIeJeO);
auto mterm2 = pAjOIepEIT->at(i)->dot(mprIeJeOpEIT->at(j));
auto mterm3 = (i == j) ? mterm2 : pAjOIepEIT->at(j)->dot(mprIeJeOpEIT->at(i));
auto mterm4 = aAjOIe->dot(mpprIeJeOpEIipEI->at(j));
auto mterm4 = aAjOIe->dotVec(mpprIeJeOpEIipEI->at(j));
ppriIeJeIepEIipEI->atiput(j, term1 - mterm2 - mterm3 - mterm4);
}
}
@@ -60,7 +60,7 @@ void MbD::DispCompIeqcJecIe::calc_pvaluepEI()
auto mprIeJeOpEIT = frmIeqc->prOeOpE->transpose();
for (int i = 0; i < 4; i++)
{
priIeJeIepEI->atiput(i, pAjOIepEIT->at(i)->dot(rIeJeO) - aAjOIe->dot(mprIeJeOpEIT->at(i)));
priIeJeIepEI->atiput(i, pAjOIepEIT->at(i)->dot(rIeJeO) - aAjOIe->dotVec(mprIeJeOpEIT->at(i)));
}
}

View File

@@ -41,7 +41,7 @@ void DispCompIeqcJecKeqc::calcPostDynCorrectorIteration()
}
for (int i = 0; i < 4; i++)
{
priIeJeKepEI->at(i) = 0.0 - (aAjOKe->dot(mprIeJeOpEIT->at(i)));
priIeJeKepEI->at(i) = 0.0 - (aAjOKe->dotVec(mprIeJeOpEIT->at(i)));
}
for (int i = 0; i < 3; i++)
{
@@ -55,10 +55,10 @@ void DispCompIeqcJecKeqc::calcPostDynCorrectorIteration()
{
auto& mpprIeJeOpEIipEI = mpprIeJeOpEIpEI->at(i);
auto& ppriIeJeKepEIipEI = ppriIeJeKepEIpEI->at(i);
ppriIeJeKepEIipEI->at(i) = 0.0 - (aAjOKe->dot(mpprIeJeOpEIipEI->at(i)));
ppriIeJeKepEIipEI->at(i) = 0.0 - (aAjOKe->dotVec(mpprIeJeOpEIipEI->at(i)));
for (int j = 0; j < 4; j++)
{
auto ppriIeJeKepEIipEIj = 0.0 - (aAjOKe->dot(mpprIeJeOpEIipEI->at(j)));
auto ppriIeJeKepEIipEIj = 0.0 - (aAjOKe->dotVec(mpprIeJeOpEIipEI->at(j)));
ppriIeJeKepEIipEI->at(j) = ppriIeJeKepEIipEIj;
ppriIeJeKepEIpEI->at(j)->at(i) = ppriIeJeKepEIipEIj;
}

View File

@@ -41,7 +41,7 @@ void MbD::DispCompIeqcJeqcIe::calc_ppvaluepEJpEJ()
auto ppriIeJeIepEJipEJ = ppriIeJeIepEJpEJ->at(i);
for (int j = i; j < 4; j++)
{
auto term1 = aAjOIe->dot(pprIeJeOpEJipEJ->at(j));
auto term1 = aAjOIe->dotVec(pprIeJeOpEJipEJ->at(j));
ppriIeJeIepEJipEJ->atiput(j, term1);
}
}
@@ -54,7 +54,7 @@ void MbD::DispCompIeqcJeqcIe::calc_pvaluepEJ()
auto prIeJeOpEJT = frmJeqc->prOeOpE->transpose();
for (int i = 0; i < 4; i++)
{
priIeJeIepEJ->atiput(i, aAjOIe->dot(prIeJeOpEJT->at(i)));
priIeJeIepEJ->atiput(i, aAjOIe->dotVec(prIeJeOpEJT->at(i)));
}
}

View File

@@ -41,7 +41,7 @@ void DispCompIeqcJeqcKeqc::calcPostDynCorrectorIteration()
}
for (int i = 0; i < 4; i++)
{
priIeJeKepEJ->atiput(i, aAjOKe->dot(prIeJeOpEJT->at(i)));
priIeJeKepEJ->atiput(i, aAjOKe->dotVec(prIeJeOpEJT->at(i)));
}
for (int i = 0; i < 3; i++)
{
@@ -55,10 +55,10 @@ void DispCompIeqcJeqcKeqc::calcPostDynCorrectorIteration()
{
auto& pprIeJeOpEJipEJ = pprIeJeOpEJpEJ->at(i);
auto& ppriIeJeKepEJipEJ = ppriIeJeKepEJpEJ->at(i);
ppriIeJeKepEJipEJ->atiput(i, aAjOKe->dot(pprIeJeOpEJipEJ->at(i)));
ppriIeJeKepEJipEJ->atiput(i, aAjOKe->dotVec(pprIeJeOpEJipEJ->at(i)));
for (int j = 0; j < 4; j++)
{
auto ppriIeJeKepEJipEJj = (aAjOKe->dot(pprIeJeOpEJipEJ->at(j)));
auto ppriIeJeKepEJipEJj = (aAjOKe->dotVec(pprIeJeOpEJipEJ->at(j)));
ppriIeJeKepEJipEJ->atiput(j, ppriIeJeKepEJipEJj);
ppriIeJeKepEJpEJ->atijput(j, i, ppriIeJeKepEJipEJj);
}

View File

@@ -47,7 +47,7 @@ void DispCompIeqcJeqcKeqct::preVelIC()
{
Item::preVelIC();
auto pAjOKept = std::static_pointer_cast<EndFrameqct>(efrmK)->pAjOept(axisK);
priIeJeKept = pAjOKept->dot(rIeJeO);
priIeJeKept = pAjOKept->dotVec(rIeJeO);
}
double DispCompIeqcJeqcKeqct::pvaluept()
@@ -100,9 +100,9 @@ void DispCompIeqcJeqcKeqct::preAccIC()
}
for (int i = 0; i < 4; i++)
{
ppriIeJeKepEIpt->atiput(i, pAjOKept->dot(prIeJeOpEIT->at(i)));
ppriIeJeKepEJpt->atiput(i, pAjOKept->dot(prIeJeOpEJT->at(i)));
ppriIeJeKepEIpt->atiput(i, pAjOKept->dotVec(prIeJeOpEIT->at(i)));
ppriIeJeKepEJpt->atiput(i, pAjOKept->dotVec(prIeJeOpEJT->at(i)));
ppriIeJeKepEKpt->atiput(i, ppAjOKepEKTpt->at(i)->dot(rIeJeO));
}
ppriIeJeKeptpt = ppAjOKeptpt->dot(rIeJeO);
ppriIeJeKeptpt = ppAjOKeptpt->dotVec(rIeJeO);
}

View File

@@ -33,7 +33,9 @@ void MbD::DispCompIeqctJeqcIe::calc_ppvaluepEIpt()
auto pAjOIepEITi = pAjOIepEIT->at(i);
auto mprIeJeOpEITi = mprIeJeOpEIT->at(i);
auto mpprIeJeOpEITpti = mpprIeJeOpEITpt->at(i);
auto ppriIeJeIepEIpti = ppAjOIepEITpti->dot(rIeJeO) - pAjOIepEITi->dot(mprIeJeOpt) - pAjOIept->dot(mprIeJeOpEITi) - aAjOIe->dot(mpprIeJeOpEITpti);
auto ppriIeJeIepEIpti = ppAjOIepEITpti->dot(rIeJeO) - pAjOIepEITi->dot(mprIeJeOpt) -
pAjOIept->dotVec(mprIeJeOpEITi) -
aAjOIe->dotVec(mpprIeJeOpEITpti);
ppriIeJeIepEIpt->atiput(i, ppriIeJeIepEIpti);
}
}
@@ -46,7 +48,7 @@ void MbD::DispCompIeqctJeqcIe::calc_ppvaluepEJpt()
auto prIeJeOpEJT = frmJeqct->prOeOpE->transpose();
for (int i = 0; i < 4; i++)
{
ppriIeJeIepEJpt->atiput(i, pAjOIept->dot(prIeJeOpEJT->at(i)));
ppriIeJeIepEJpt->atiput(i, pAjOIept->dotVec(prIeJeOpEJT->at(i)));
}
}
@@ -57,7 +59,8 @@ void MbD::DispCompIeqctJeqcIe::calc_ppvalueptpt()
auto ppAjOIeptpt = frmIeqct->ppAjOeptpt(axis);
auto mprIeJeOpt = frmIeqct->prOeOpt;
auto mpprIeJeOptpt = frmIeqct->pprOeOptpt;
ppriIeJeIeptpt = ppAjOIeptpt->dot(rIeJeO) - pAjOIept->dot(mprIeJeOpt) - pAjOIept->dot(mprIeJeOpt) - aAjOIe->dot(mpprIeJeOptpt);
ppriIeJeIeptpt = ppAjOIeptpt->dotVec(rIeJeO) - pAjOIept->dotVec(mprIeJeOpt) - pAjOIept->dotVec(mprIeJeOpt) -
aAjOIe->dotVec(mpprIeJeOptpt);
}
void MbD::DispCompIeqctJeqcIe::calc_ppvaluepXIpt()
@@ -85,7 +88,7 @@ void MbD::DispCompIeqctJeqcIe::calc_pvaluept()
auto frmIeqct = std::static_pointer_cast<EndFrameqct>(frmI);
auto pAjOIept = frmIeqct->pAjOept(axis);
auto mprIeJeOpt = frmIeqct->prOeOpt;
priIeJeIept = pAjOIept->dot(rIeJeO) - aAjOIe->dot(mprIeJeOpt);
priIeJeIept = pAjOIept->dotVec(rIeJeO) - aAjOIe->dotVec(mprIeJeOpt);
}
void MbD::DispCompIeqctJeqcIe::calcPostDynCorrectorIteration()

View File

@@ -23,7 +23,7 @@ void DispCompIeqctJeqcKeqct::preVelIC()
{
DispCompIeqcJeqcKeqct::preVelIC();
auto& mprIeJeOpt = std::static_pointer_cast<EndFrameqct>(frmI)->prOeOpt;
priIeJeKept -= aAjOKe->dot(mprIeJeOpt);
priIeJeKept -= aAjOKe->dotVec(mprIeJeOpt);
}
void DispCompIeqctJeqcKeqct::preAccIC()
@@ -36,8 +36,8 @@ void DispCompIeqctJeqcKeqct::preAccIC()
auto& mpprIeJeOptpt = efrmIqct->pprOeOptpt;
for (int i = 0; i < 4; i++)
{
ppriIeJeKepEIpt->atiminusNumber(i, aAjOKe->dot(mpprIeJeOpEITpt->at(i)));
ppriIeJeKepEIpt->atiminusNumber(i, aAjOKe->dotVec(mpprIeJeOpEITpt->at(i)));
ppriIeJeKepEKpt->atiminusNumber(i, pAjOKepEKT->at(i)->dot(mprIeJeOpt));
}
ppriIeJeKeptpt += -(2.0 * pAjOKept->dot(mprIeJeOpt)) - aAjOKe->dot(mpprIeJeOptpt);
ppriIeJeKeptpt += -(2.0 * pAjOKept->dotVec(mprIeJeOpt)) - aAjOKe->dotVec(mpprIeJeOptpt);
}

View File

@@ -63,7 +63,7 @@ void MbD::DistIeqcJec::calcPrivate()
for (int j = 0; j < 4; j++)
{
auto element = mprIeJeOpEIiT->dot(mprIeJeOpEIT->at(j))
- mpprIeJeOpEIipEI->at(j)->dot(rIeJeO) - prIeJepEIi * prIeJepEI->at(j);
- mpprIeJeOpEIipEI->at(j)->dotVec(rIeJeO) - prIeJepEIi * prIeJepEI->at(j);
pprIeJepEIipEI->atiput(j, element / rIeJe);
}
}

View File

@@ -111,7 +111,7 @@ void MbD::DistIeqcJeqc::calcPrivate()
for (int j = 0; j < 4; j++)
{
auto element = prIeJeOpEJiT->dot(prIeJeOpEJT->at(j))
+ pprIeJeOpEJipEJ->at(j)->dot(rIeJeO) - prIeJepEJi * prIeJepEJ->at(j);
+ pprIeJeOpEJipEJ->at(j)->dotVec(rIeJeO) - prIeJepEJi * prIeJepEJ->at(j);
pprIeJepEJipEJ->atiput(j, element / rIeJe);
}
}

View File

@@ -126,7 +126,7 @@ namespace MbD {
template<typename T>
T FullColumn<T>::transposeTimesFullColumn(const FColsptr<T> fullCol)
{
return this->dot(fullCol);
return this->dotVec(fullCol);
}
template<typename T>
void FullColumn<T>::equalSelfPlusFullColumntimes(FColsptr<T> fullCol, T factor)
@@ -170,16 +170,6 @@ namespace MbD {
template class FullColumn<double>;
template class FullColumn<int>;
template<typename T>
double FullColumn<T>::dot(std::shared_ptr<FullVector<T>> vec)
{
int n = (int)this->size();
double answer = 0.0;
for (int i = 0; i < n; i++) {
answer += this->at(i) * vec->at(i);
}
return answer;
}
template<typename T>
std::shared_ptr<FullVector<T>> FullColumn<T>::dot(std::shared_ptr<std::vector<std::shared_ptr<FullColumn<T>>>> vecvec)
{
int ncol = (int)this->size();
@@ -195,10 +185,4 @@ namespace MbD {
}
return answer;
}
template<typename T>
std::shared_ptr<FullColumn<T>> FullColumn<T>::clonesptr()
{
return std::make_shared<FullColumn<T>>(*this);
}
}

View File

@@ -47,8 +47,8 @@ namespace MbD {
void equalSelfPlusFullColumntimes(FColsptr<T> fullCol, T factor);
FColsptr<T> cross(FColsptr<T> fullCol);
FColsptr<T> simplified();
std::shared_ptr<FullColumn<T>> clonesptr();
double dot(std::shared_ptr<FullVector<T>> vec);
std::shared_ptr<FullColumn<T>> cloneFcSptr();
double dotVec(std::shared_ptr<FullVector<T>> vec);
std::shared_ptr<FullVector<T>> dot(std::shared_ptr<std::vector<std::shared_ptr<FullColumn<T>>>> vecvec);
std::ostream& printOn(std::ostream& s) const override;
@@ -66,4 +66,20 @@ namespace MbD {
s << "}";
return s;
}
template<typename T>
std::shared_ptr<FullColumn<T>> FullColumn<T>::cloneFcSptr()
{
return std::make_shared<FullColumn<T>>(*this);
}
template<typename T>
double FullColumn<T>::dotVec(std::shared_ptr<FullVector<T>> vec)
{
int n = (int)this->size();
double answer = 0.0;
for (int i = 0; i < n; i++) {
answer += this->at(i) * vec->at(i);
}
return answer;
}
}

View File

@@ -602,12 +602,12 @@ namespace MbD {
if (std::abs(sthe1y) > 0.9999) {
if (sthe1y > 0.0) {
the0x = std::atan2(this->at(1)->at(0), this->at(1)->at(1));
the1y = M_PI / 2.0;
the1y = OS_M_PI / 2.0;
the2z = 0.0;
}
else {
the0x = std::atan2(this->at(2)->at(1), this->at(2)->at(0));
the1y = M_PI / -2.0;
the1y = OS_M_PI / -2.0;
the2z = 0.0;
}
}

View File

@@ -47,21 +47,6 @@ namespace MbD {
return answer;
}
// TODO: can't get the following to work, but CLion says the routine that calls it in FullMatrixFullMatrixDouble is also
// never called.
// template<>
// FRowsptr<std::shared_ptr<FullMatrixDouble>> FullRow<std::shared_ptr<FullMatrixDouble>>::timesTransposeFullMatrixForFMFMDsptr(
// std::shared_ptr<FullMatrixFullMatrixDouble> fullMat)
// {
// //"a*bT = a(1,j)b(k,j)"
// int ncol = fullMat->nrow();
// auto answer = std::make_shared<FullRow<std::shared_ptr<FullMatrixDouble>>>(ncol);
// for (int k = 0; k < ncol; k++) {
// answer->at(k) = this->dot(fullMat->at(k));
// }
// return answer;
// }
template<>
FRowsptr<double> FullRow<double>::timesFullMatrix(std::shared_ptr<FullMatrixDouble> fullMat)
{

View File

@@ -22,7 +22,7 @@ namespace MbD {
void forwardEliminateWithPivot(int p) override;
void postSolve() override;
void preSolvesaveOriginal(FMatDsptr fullMat, bool saveOriginal);
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);

View File

@@ -65,7 +65,7 @@ std::vector<std::string> MbD::MBDynItem::collectArgumentsFor(std::string title,
//Need to find matching '"'
auto it = std::find_if(arguments.begin() + 1, arguments.end(), [](const std::string& s) {
auto nn = std::count(s.begin(), s.end(), '"');
if ((nn % 2) == 1) return true;
return ((nn % 2) == 1);
});
std::vector<std::string> needToCombineArgs(arguments.begin(), it + 1);
arguments.erase(arguments.begin(), it + 1);

View File

@@ -14,7 +14,7 @@ namespace MbD {
class MBDynMarker : public MBDynItem
{
public:
void parseMBDyn(std::vector<std::string>& args);
void parseMBDyn(std::vector<std::string>& args) override;
void parseMBDynClamp(std::vector<std::string>& args);
void createASMT() override;

View File

@@ -15,7 +15,7 @@ void MbD::MomentOfInertiaSolver::example1()
auto rpPp = std::make_shared<FullColumn<double>>(ListD{ 0, 0, 1 });
auto rotAxis = std::make_shared<FullColumn<double>>(ListD{ 0, 0, 1 });
auto aApP = std::make_shared<EulerParameters<double>>(rotAxis, M_PI*10/180)->aA;
auto aApP = std::make_shared<EulerParameters<double>>(rotAxis, OS_M_PI * 10 / 180)->aA;
auto solver = std::make_shared<MomentOfInertiaSolver>();
solver->setm(4.0);
solver->setJPP(aJpp);
@@ -350,7 +350,7 @@ void MbD::MomentOfInertiaSolver::calcJppFromFullJcmP()
auto q = (c + (2.0 * aDiv3 * aDiv3 * aDiv3) - (aDiv3 * b)) / 2.0;
auto phiDiv3 = modifiedArcCos(-q / std::sqrt(-p * p * p)) / 3.0;
auto twoSqrtMinusp = 2.0 * std::sqrt(-p);
auto piDiv3 = M_PI / 3.0;
auto piDiv3 = OS_M_PI / 3.0;
auto sortedJ = std::make_shared<DiagonalMatrix>();
sortedJ->push_back(twoSqrtMinusp * std::cos(phiDiv3));
sortedJ->push_back(twoSqrtMinusp * -std::cos(phiDiv3 + piDiv3));
@@ -392,7 +392,7 @@ double MbD::MomentOfInertiaSolver::modifiedArcCos(double val)
}
else {
if (val < -1.0) {
return M_PI;
return OS_M_PI;
}
else {
return std::acos(val);

View File

@@ -26,22 +26,22 @@ double MbD::Numeric::arcTan0to2piYoverX(double y, double x)
}
else {
//"Forth quadrant."
return 2.0 * M_PI + std::atan2(y, x);
return 2.0 * OS_M_PI + std::atan2(y, x);
}
}
else {
if (x < 0.0) {
//"Second and Third quadrants."
return M_PI + std::atan2(y, x);
return OS_M_PI + std::atan2(y, x);
}
else {
//"x = 0"
if (y > 0.0) {
return M_PI / 2.0;
return OS_M_PI / 2.0;
}
else {
if (y < 0.0) {
return 1.5 * M_PI;
return 1.5 * OS_M_PI;
}
else {
throw std::invalid_argument("atan2(0, 0) is not defined.");

View File

@@ -29,7 +29,7 @@ void MbD::OrbitAngleZIecJec::calcPostDynCorrectorIteration()
auto diffOfSquares = y * y - (x * x);
auto sumOfSquaresSquared = sumOfSquares * sumOfSquares;
auto thez0to2pi = Numeric::arcTan0to2piYoverX(y, x);
thez = std::round((thez - thez0to2pi) / (2.0 * M_PI)) * (2.0 * M_PI) + thez0to2pi;
thez = std::round((thez - thez0to2pi) / (2.0 * OS_M_PI)) * (2.0 * OS_M_PI) + thez0to2pi;
auto cosOverSSq = x / sumOfSquares;
auto sinOverSSq = y / sumOfSquares;
twoCosSinOverSSqSq = 2.0 * x * y / sumOfSquaresSquared;

View File

@@ -102,18 +102,17 @@ void PosICNewtonRaphson::handleSingularMatrix()
matrixSolver = this->matrixSolverClassNew();
}
else {
std::string str = typeid(*matrixSolver).name();
auto& r = *matrixSolver;
std::string str = typeid(r).name();
if (str.find("GESpMatParPvMarkoFast") != std::string::npos) {
matrixSolver = CREATE<GESpMatParPvPrecise>::With();
this->solveEquations();
}
else {
str = typeid(*matrixSolver).name();
matrixSolver = CREATE<GESpMatParPvPrecise>::With();
this->solveEquations();
} else {
str = typeid(r).name();
if (str.find("GESpMatParPvPrecise") != std::string::npos) {
this->lookForRedundantConstraints();
matrixSolver = this->matrixSolverClassNew();
}
else {
} else {
assert(false);
}
}

View File

@@ -20,7 +20,7 @@ void MbD::ScrewConstraintIJ::calcPostDynCorrectorIteration()
{
auto z = zIeJeIe->value();
auto thez = thezIeJe->value();
aG = (2.0 * M_PI * z) - (pitch * thez) - aConstant;
aG = (2.0 * OS_M_PI * z) - (pitch * thez) - aConstant;
}
void MbD::ScrewConstraintIJ::init_zthez()
@@ -50,7 +50,7 @@ void MbD::ScrewConstraintIJ::postInput()
{
zIeJeIe->postInput();
thezIeJe->postInput();
aConstant = (2.0 * M_PI * zIeJeIe->value()) - (thezIeJe->value() * pitch);
aConstant = (2.0 * OS_M_PI * zIeJeIe->value()) - (thezIeJe->value() * pitch);
ConstraintIJ::postInput();
}

View File

@@ -45,23 +45,23 @@ void MbD::ScrewConstraintIqcJc::addToJointTorqueI(FColDsptr jointTorque)
void MbD::ScrewConstraintIqcJc::calc_pGpEI()
{
pGpEI = zIeJeIe->pvaluepEI()->times(2.0 * M_PI)->minusFullRow(thezIeJe->pvaluepEI()->times(pitch));
pGpEI = zIeJeIe->pvaluepEI()->times(2.0 * OS_M_PI)->minusFullRow(thezIeJe->pvaluepEI()->times(pitch));
}
void MbD::ScrewConstraintIqcJc::calc_pGpXI()
{
pGpXI = zIeJeIe->pvaluepXI()->times(2.0 * M_PI)->minusFullRow(thezIeJe->pvaluepXI()->times(pitch));
pGpXI = zIeJeIe->pvaluepXI()->times(2.0 * OS_M_PI)->minusFullRow(thezIeJe->pvaluepXI()->times(pitch));
}
void MbD::ScrewConstraintIqcJc::calc_ppGpEIpEI()
{
ppGpEIpEI = zIeJeIe->ppvaluepEIpEI()->times(2.0 * M_PI)
ppGpEIpEI = zIeJeIe->ppvaluepEIpEI()->times(2.0 * OS_M_PI)
->minusFullMatrix(thezIeJe->ppvaluepEIpEI()->times(pitch));
}
void MbD::ScrewConstraintIqcJc::calc_ppGpXIpEI()
{
ppGpXIpEI = zIeJeIe->ppvaluepXIpEI()->times(2.0 * M_PI)
ppGpXIpEI = zIeJeIe->ppvaluepXIpEI()->times(2.0 * OS_M_PI)
->minusFullMatrix(thezIeJe->ppvaluepXIpEI()->times(pitch));
}

View File

@@ -22,29 +22,29 @@ MbD::ScrewConstraintIqcJqc::ScrewConstraintIqcJqc(EndFrmsptr frmi, EndFrmsptr fr
void MbD::ScrewConstraintIqcJqc::calc_pGpEJ()
{
pGpEJ = zIeJeIe->pvaluepEJ()->times(2.0 * M_PI)->minusFullRow(thezIeJe->pvaluepEJ()->times(pitch));
pGpEJ = zIeJeIe->pvaluepEJ()->times(2.0 * OS_M_PI)->minusFullRow(thezIeJe->pvaluepEJ()->times(pitch));
}
void MbD::ScrewConstraintIqcJqc::calc_pGpXJ()
{
pGpXJ = zIeJeIe->pvaluepXJ()->times(2.0 * M_PI)->minusFullRow(thezIeJe->pvaluepXJ()->times(pitch));
pGpXJ = zIeJeIe->pvaluepXJ()->times(2.0 * OS_M_PI)->minusFullRow(thezIeJe->pvaluepXJ()->times(pitch));
}
void MbD::ScrewConstraintIqcJqc::calc_ppGpEIpEJ()
{
ppGpEIpEJ = zIeJeIe->ppvaluepEIpEJ()->times(2.0 * M_PI)
ppGpEIpEJ = zIeJeIe->ppvaluepEIpEJ()->times(2.0 * OS_M_PI)
->minusFullMatrix(thezIeJe->ppvaluepEIpEJ()->times(pitch));
}
void MbD::ScrewConstraintIqcJqc::calc_ppGpEIpXJ()
{
ppGpEIpXJ = zIeJeIe->ppvaluepEIpXJ()->times(2.0 * M_PI)
ppGpEIpXJ = zIeJeIe->ppvaluepEIpXJ()->times(2.0 * OS_M_PI)
->minusFullMatrix(thezIeJe->ppvaluepEIpXJ()->times(pitch));
}
void MbD::ScrewConstraintIqcJqc::calc_ppGpEJpEJ()
{
ppGpEJpEJ = zIeJeIe->ppvaluepEJpEJ()->times(2.0 * M_PI)
ppGpEJpEJ = zIeJeIe->ppvaluepEJpEJ()->times(2.0 * OS_M_PI)
->minusFullMatrix(thezIeJe->ppvaluepEJpEJ()->times(pitch));
}

View File

@@ -79,7 +79,7 @@ FColDsptr MbD::StableBackwardDifference::derivativepresentpast(int deriv, FColDs
//"Answer ith derivative given present value and past values."
if (deriv == 0) {
return y->clonesptr();
return y->cloneFcSptr();
}
else {
if (deriv <= order) {

View File

@@ -17,13 +17,13 @@ namespace MbD {
//
public:
FColDsptr derivativepresentpast(int order, FColDsptr y, std::shared_ptr<std::vector<FColDsptr>> ypast) override;
void instantiateTaylorMatrix();
void formTaylorRowwithTimeNodederivative(int i, int ii, int k);
void instantiateTaylorMatrix() override;
void formTaylorRowwithTimeNodederivative(int i, int ii, int k) override;
void formTaylorMatrix() override;
double pvdotpv() override;
FColDsptr derivativepresentpastpresentDerivativepastDerivative(int n,
FColDsptr y, std::shared_ptr<std::vector<FColDsptr>> ypast,
FColDsptr ydot, std::shared_ptr<std::vector<FColDsptr>> ydotpast);
FColDsptr ydot, std::shared_ptr<std::vector<FColDsptr>> ydotpast) override;
FColDsptr derivativewith(int deriv, std::shared_ptr<std::vector<FColDsptr>> series);
};

View File

@@ -330,7 +330,7 @@ bool MbD::SymbolicParser::constant()
return true;
}
if (peekForTypevalue("word", "pi")) {
auto symconst = std::make_shared<Constant>(M_PI);
auto symconst = std::make_shared<Constant>(OS_M_PI);
stack->push(symconst);
return true;
}

View File

@@ -51,13 +51,14 @@ void SystemNewtonRaphson::basicSolveEquations()
void SystemNewtonRaphson::handleSingularMatrix()
{
std::string str = typeid(*matrixSolver).name();
auto& r = *matrixSolver;
std::string str = typeid(r).name();
if (str.find("GESpMatParPvMarkoFast") != std::string::npos) {
matrixSolver = CREATE<GESpMatParPvPrecise>::With();
this->solveEquations();
}
else {
str = typeid(*matrixSolver).name();
str = typeid(r).name();
if (str.find("GESpMatParPvPrecise") != std::string::npos) {
str = "MbD: Singular Matrix Error. ";
system->logString(str);

View File

@@ -27,7 +27,7 @@ namespace MbD {
bool isConverged() override;
void xEqualxoldPlusdx() override;
virtual void basicSolveEquations() = 0;
virtual void handleSingularMatrix();
virtual void handleSingularMatrix() override;
std::shared_ptr<MatrixSolver> matrixSolver;
int n;

View File

@@ -24,13 +24,14 @@ void VelSolver::basicSolveEquations()
void VelSolver::handleSingularMatrix()
{
std::string str = typeid(*matrixSolver).name();
auto& r = *matrixSolver;
std::string str = typeid(r).name();
if (str.find("GESpMatParPvMarkoFast") != std::string::npos) {
matrixSolver = CREATE<GESpMatParPvPrecise>::With();
this->solveEquations();
}
else {
str = typeid(*matrixSolver).name();
str = typeid(r).name();
if (str.find("GESpMatParPvPrecise") != std::string::npos) {
this->logSingularMatrixMessage();
matrixSolver = this->matrixSolverClassNew();

View File

@@ -19,12 +19,12 @@
// #define M_LOG10E 0.434294481903251827651 // log10(e)
// #define M_LN2 0.693147180559945309417 // ln(2)
// #define M_LN10 2.30258509299404568402 // ln(10)
#define M_PI 3.14159265358979323846 // pi
#define OS_M_PI 3.14159265358979323846264338327950288 // pi
// #define M_PI_2 1.57079632679489661923 // pi/2
// #define M_PI_4 0.785398163397448309616 // pi/4
// #define M_1_PI 0.318309886183790671538 // 1/pi
// #define M_2_PI 0.636619772367581343076 // 2/pi
#define M_2_SQRTPI 1.12837916709551257390 // 2/sqrt(pi)
#define M_SQRT2 1.41421356237309504880 // sqrt(2)
#define OS_M_2_SQRTPI 1.12837916709551257389615890312154517 // 2/sqrt(pi)
#define OS_M_SQRT2 1.41421356237309504880168872420969808 // sqrt(2)
// #define M_SQRT1_2 0.707106781186547524401 // 1/sqrt(2)
#endif