auto max = 0 to double max = 0.0
This commit is contained in:
@@ -96,7 +96,7 @@ namespace MbD {
|
||||
//template<>
|
||||
//inline double Array<double>::maxMagnitude()
|
||||
//{
|
||||
// auto max = 0.0;
|
||||
// double max = 0.0;
|
||||
// for (int i = 0; i < this->size(); i++)
|
||||
// {
|
||||
// auto element = this->at(i);
|
||||
@@ -108,10 +108,10 @@ namespace MbD {
|
||||
template<typename T>
|
||||
inline double Array<T>::maxMagnitudeOfVector()
|
||||
{
|
||||
auto answer = 0.0;
|
||||
double answer = 0.0;
|
||||
for (int i = 0; i < this->size(); i++)
|
||||
{
|
||||
auto mag = std::abs(this->at(i));
|
||||
double mag = std::abs(this->at(i));
|
||||
if (answer < mag) answer = mag;
|
||||
}
|
||||
return answer;
|
||||
@@ -127,15 +127,15 @@ namespace MbD {
|
||||
//template<>
|
||||
//inline void Array<double>::normalizeSelf()
|
||||
//{
|
||||
// auto length = this->length();
|
||||
// double length = this->length();
|
||||
// if (length == 0.0) throw std::runtime_error("Cannot normalize a null vector.");
|
||||
// this->magnifySelf(1.0 / length);
|
||||
//}
|
||||
//template<>
|
||||
//inline void Array<double>::conditionSelf()
|
||||
//{
|
||||
// constexpr auto epsilon = std::numeric_limits<double>::epsilon();
|
||||
// auto tol = maxMagnitude() * epsilon;
|
||||
// constexpr double epsilon = std::numeric_limits<double>::epsilon();
|
||||
// double tol = maxMagnitude() * epsilon;
|
||||
// conditionSelfWithTol(tol);
|
||||
//}
|
||||
//template<>
|
||||
@@ -143,7 +143,7 @@ namespace MbD {
|
||||
//{
|
||||
// for (int i = 0; i < this->size(); i++)
|
||||
// {
|
||||
// auto element = this->at(i);
|
||||
// double element = this->at(i);
|
||||
// if (element < 0.0) element = -element;
|
||||
// if (element < tol) this->atiput(i, 0.0);
|
||||
// }
|
||||
@@ -156,10 +156,10 @@ namespace MbD {
|
||||
//template<>
|
||||
//inline double Array<double>::length()
|
||||
//{
|
||||
// auto ssq = 0.0;
|
||||
// double ssq = 0.0;
|
||||
// for (int i = 0; i < this->size(); i++)
|
||||
// {
|
||||
// auto elem = this->at(i);
|
||||
// double elem = this->at(i);
|
||||
// ssq += elem * elem;
|
||||
// }
|
||||
// return std::sqrt(ssq);
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace MbD {
|
||||
IntegratorInterface* system;
|
||||
int istep = 0, iTry = 0, maxTry = 0;
|
||||
std::shared_ptr<std::vector<double>> tpast;
|
||||
double t = 0, tnew = 0, h = 0, hnew = 0;
|
||||
double t = 0.0, tnew = 0.0, h = 0, hnew = 0.0;
|
||||
int order = 0, orderNew = 0, orderMax = 0;
|
||||
std::shared_ptr<DifferenceOperator> opBDF;
|
||||
bool _continue = false;
|
||||
|
||||
@@ -610,7 +610,7 @@ void CADSystem::runPiston()
|
||||
systemSolver->errorTolAccKine = 1.0e-6;
|
||||
systemSolver->iterMaxPosKine = 25;
|
||||
systemSolver->iterMaxAccKine = 25;
|
||||
systemSolver->tstart = 0;
|
||||
systemSolver->tstart = 0.0;
|
||||
systemSolver->tend = 25.0;
|
||||
systemSolver->hmin = 2.5e-8;
|
||||
systemSolver->hmax = 25.0;
|
||||
|
||||
@@ -53,7 +53,7 @@ void MbD::ConstVelConstraintIqcJc::fillAccICIterError(FColDsptr col)
|
||||
col->atiplusFullVectortimes(iqEI, pGpEI, lam);
|
||||
auto efrmIqc = std::static_pointer_cast<EndFrameqc>(frmI);
|
||||
auto qEdotI = efrmIqc->qEdot();
|
||||
auto sum = 0.0;
|
||||
double sum = 0.0;
|
||||
sum += pGpEI->timesFullColumn(efrmIqc->qEddot());
|
||||
sum += qEdotI->transposeTimesFullColumn(ppGpEIpEI->timesFullColumn(qEdotI));
|
||||
col->atiplusNumber(iG, sum);
|
||||
|
||||
@@ -67,7 +67,7 @@ void MbD::ConstVelConstraintIqcJqc::fillAccICIterError(FColDsptr col)
|
||||
auto qEdotI = efrmIqc->qEdot();
|
||||
auto efrmJqc = std::static_pointer_cast<EndFrameqc>(frmJ);
|
||||
auto qEdotJ = efrmJqc->qEdot();
|
||||
auto sum = 0.0;
|
||||
double sum = 0.0;
|
||||
sum += pGpEJ->timesFullColumn(efrmJqc->qEddot());
|
||||
sum += 2.0 * qEdotI->transposeTimesFullColumn(ppGpEIpEJ->timesFullColumn(qEdotJ));
|
||||
sum += qEdotJ->transposeTimesFullColumn(ppGpEJpEJ->timesFullColumn(qEdotJ));
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace MbD {
|
||||
int iG = -1;
|
||||
double aG = 0.0; //Constraint function
|
||||
double lam = 0.0; //Lambda is Lagrange Multiplier
|
||||
double mu = 0, lamDeriv = 0;
|
||||
double mu = 0.0, lamDeriv = 0.0;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -121,10 +121,10 @@ namespace MbD {
|
||||
template<>
|
||||
inline double DiagonalMatrix<double>::maxMagnitude()
|
||||
{
|
||||
auto max = 0.0;
|
||||
double max = 0.0;
|
||||
for (int i = 0; i < this->size(); i++)
|
||||
{
|
||||
auto element = this->at(i);
|
||||
double element = this->at(i);
|
||||
if (element < 0.0) element = -element;
|
||||
if (max < element) max = element;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace MbD {
|
||||
|
||||
int iStep = 0, order = 0;
|
||||
FMatDsptr taylorMatrix, operatorMatrix;
|
||||
double time = 0;
|
||||
double time = 0.0;
|
||||
std::shared_ptr<std::vector<double>> timeNodes;
|
||||
static FRowDsptr OneOverFactorials;
|
||||
};
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace MbD {
|
||||
{
|
||||
//| zero phiThePsi phi sphi cphi phidot phiddot cphiddot sphiddot the sthe cthe thedot theddot ctheddot stheddot
|
||||
// psi spsi cpsi psidot psiddot cpsiddot spsiddot phiA theA psiA phiAdot theAdot psiAdot |
|
||||
auto zero = 0.0;
|
||||
double zero = 0.0;
|
||||
auto& phiThePsi = phiThePsiDot->phiThePsi;
|
||||
auto& phi = phiThePsi->at(0);
|
||||
auto sphi = std::sin(phi);
|
||||
|
||||
@@ -619,10 +619,10 @@ namespace MbD {
|
||||
template<typename T>
|
||||
inline double FullMatrix<T>::maxMagnitude()
|
||||
{
|
||||
auto max = 0.0;
|
||||
double max = 0.0;
|
||||
for (int i = 0; i < this->size(); i++)
|
||||
{
|
||||
auto element = this->at(i)->maxMagnitude();
|
||||
double element = this->at(i)->maxMagnitude();
|
||||
if (max < element) max = element;
|
||||
}
|
||||
return max;
|
||||
@@ -683,7 +683,7 @@ namespace MbD {
|
||||
template<typename T>
|
||||
inline bool FullMatrix<T>::isDiagonalToWithin(double ratio)
|
||||
{
|
||||
auto maxMag = this->maxMagnitude();
|
||||
double maxMag = this->maxMagnitude();
|
||||
auto tol = ratio * maxMag;
|
||||
auto nrow = this->nrow();
|
||||
if (nrow == this->ncol()) {
|
||||
|
||||
@@ -125,10 +125,10 @@ namespace MbD {
|
||||
template<>
|
||||
inline double FullVector<double>::maxMagnitude()
|
||||
{
|
||||
auto max = 0.0;
|
||||
double max = 0.0;
|
||||
for (int i = 0; i < this->size(); i++)
|
||||
{
|
||||
auto element = this->at(i);
|
||||
double element = this->at(i);
|
||||
if (element < 0.0) element = -element;
|
||||
if (max < element) max = element;
|
||||
}
|
||||
@@ -143,17 +143,17 @@ namespace MbD {
|
||||
template<>
|
||||
inline void FullVector<double>::normalizeSelf()
|
||||
{
|
||||
auto length = this->length();
|
||||
double length = this->length();
|
||||
if (length == 0.0) throw std::runtime_error("Cannot normalize a null vector.");
|
||||
this->magnifySelf(1.0 / length);
|
||||
}
|
||||
template<typename T>
|
||||
inline double FullVector<T>::length()
|
||||
{
|
||||
auto ssq = 0.0;
|
||||
double ssq = 0.0;
|
||||
for (int i = 0; i < this->size(); i++)
|
||||
{
|
||||
auto elem = this->at(i);
|
||||
double elem = this->at(i);
|
||||
ssq += elem * elem;
|
||||
}
|
||||
return std::sqrt(ssq);
|
||||
@@ -161,8 +161,8 @@ namespace MbD {
|
||||
template<typename T>
|
||||
inline void FullVector<T>::conditionSelf()
|
||||
{
|
||||
constexpr auto epsilon = std::numeric_limits<double>::epsilon();
|
||||
auto tol = this->maxMagnitude() * epsilon;
|
||||
constexpr double epsilon = std::numeric_limits<double>::epsilon();
|
||||
double tol = this->maxMagnitude() * epsilon;
|
||||
this->conditionSelfWithTol(tol);
|
||||
}
|
||||
template<>
|
||||
@@ -170,7 +170,7 @@ namespace MbD {
|
||||
{
|
||||
for (int i = 0; i < this->size(); i++)
|
||||
{
|
||||
auto element = this->at(i);
|
||||
double element = this->at(i);
|
||||
if (element < 0.0) element = -element;
|
||||
if (element < tol) this->atiput(i, 0.0);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ void GEFullMatParPv::doPivoting(int p)
|
||||
|
||||
//| app max rowPivot aip mag |
|
||||
auto app = matrixA->at(p)->at(p);
|
||||
auto max = app * rowScalings->at(p);
|
||||
double max = app * rowScalings->at(p);
|
||||
if (max < 0.0) max = -max;
|
||||
auto rowPivot = p;
|
||||
for (int i = p + 1; i < m; i++)
|
||||
|
||||
@@ -20,7 +20,7 @@ void GESpMatFullPv::doPivoting(int p)
|
||||
//"Swap rows but keep columns in place."
|
||||
//"The elements below the diagonal are removed column by column."
|
||||
|
||||
auto max = 0.0;
|
||||
double max = 0.0;
|
||||
auto pivotRow = p;
|
||||
auto pivotCol = p;
|
||||
for (int j = p; j < n; j++)
|
||||
@@ -169,7 +169,7 @@ void GESpMatFullPv::preSolvewithsaveOriginal(SpMatDsptr spMat, FColDsptr fullCol
|
||||
for (int i = 0; i < m; i++)
|
||||
{
|
||||
auto& spRowi = spMat->at(i);
|
||||
auto maxRowMagnitude = spRowi->maxMagnitude();
|
||||
double maxRowMagnitude = spRowi->maxMagnitude();
|
||||
if (maxRowMagnitude == 0) {
|
||||
throwSingularMatrixError("");
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ void GESpMatFullPvPosIC::doPivoting(int p)
|
||||
//"Swap rows but keep columns in place."
|
||||
//"The elements below the diagonal are removed column by column."
|
||||
|
||||
auto max = 0.0;
|
||||
double max = 0.0;
|
||||
auto pivotRow = p;
|
||||
auto pivotCol = p;
|
||||
for (int j = p; j < n; j++)
|
||||
|
||||
@@ -94,7 +94,7 @@ void GESpMatParPvMarko::preSolvewithsaveOriginal(SpMatDsptr spMat, FColDsptr ful
|
||||
for (int i = 0; i < m; i++)
|
||||
{
|
||||
auto& spRowi = spMat->at(i);
|
||||
auto maxRowMagnitude = spRowi->maxMagnitude();
|
||||
double maxRowMagnitude = spRowi->maxMagnitude();
|
||||
if (maxRowMagnitude == 0) {
|
||||
throwSingularMatrixError("");
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ void GESpMatParPvMarkoFast::preSolvewithsaveOriginal(SpMatDsptr spMat, FColDsptr
|
||||
for (int i = 0; i < m; i++)
|
||||
{
|
||||
auto& spRowi = spMat->at(i);
|
||||
auto maxRowMagnitude = spRowi->maxMagnitude();
|
||||
double maxRowMagnitude = spRowi->maxMagnitude();
|
||||
if (maxRowMagnitude == 0) throwSingularMatrixError("");
|
||||
auto scaling = 1.0 / maxRowMagnitude;
|
||||
matrixA->at(i) = spRowi->timesconditionedWithTol(scaling, singularPivotTolerance);
|
||||
|
||||
@@ -96,7 +96,7 @@ void GESpMatParPvPrecise::preSolvewithsaveOriginal(SpMatDsptr spMat, FColDsptr f
|
||||
for (int i = 0; i < m; i++)
|
||||
{
|
||||
auto& spRowi = spMat->at(i);
|
||||
auto maxRowMagnitude = spRowi->maxMagnitude();
|
||||
double maxRowMagnitude = spRowi->maxMagnitude();
|
||||
if (maxRowMagnitude == 0) throwSingularMatrixError("preSolvewithsaveOriginal");
|
||||
rowScalings->at(i) = 1.0 / maxRowMagnitude;
|
||||
matrixA->at(i) = spRowi->conditionedWithTol(singularPivotTolerance * maxRowMagnitude);
|
||||
|
||||
@@ -69,23 +69,23 @@ void MbD::GeneralSpline::computeDerivatives()
|
||||
auto matrix = std::make_shared<SparseMatrix<double>>(np, np);
|
||||
auto bvector = std::make_shared<FullColumn<double>>(np, 0.0);
|
||||
auto hs = std::make_shared<FullColumn<double>>(n - 1);
|
||||
auto hmax = 0.0;
|
||||
double hmax = 0.0;
|
||||
for (int i = 0; i < n - 1; i++)
|
||||
{
|
||||
auto h = xs->at((size_t)i + 1) - xs->at(i);
|
||||
double h = xs->at((size_t)i + 1) - xs->at(i);
|
||||
hmax = std::max(hmax, std::abs(h));
|
||||
hs->atiput(i, h);
|
||||
}
|
||||
for (int i = 0; i < n - 1; i++)
|
||||
{
|
||||
auto offset = i * p;
|
||||
auto hbar = hs->at(i) / hmax;
|
||||
double offset = i * p;
|
||||
double hbar = hs->at(i) / hmax;
|
||||
for (int j = 1; j < p; j++)
|
||||
{
|
||||
matrix->atijput(offset + j, offset + j - 1, 1.0);
|
||||
matrix->atijput(offset + j, offset + j - 1 + p, -1.0);
|
||||
}
|
||||
auto dum = 1.0;
|
||||
double dum = 1.0;
|
||||
for (int j = 0; j < p; j++)
|
||||
{
|
||||
dum = dum * hbar / (j + 1);
|
||||
@@ -148,7 +148,7 @@ double MbD::GeneralSpline::derivativeAt(int n, double xxx)
|
||||
if (n > degree) return 0.0;
|
||||
calcIndexAndDeltaFor(xxx);
|
||||
auto& derivsi = derivs->at(index);
|
||||
auto sum = 0.0;
|
||||
double sum = 0.0;
|
||||
for (int j = degree; j >= n + 1; j--)
|
||||
{
|
||||
sum = (sum + derivsi->at((size_t)j - 1)) * delta / (j - n);
|
||||
@@ -169,16 +169,16 @@ void MbD::GeneralSpline::calcIndexAndDeltaFor(double xxx)
|
||||
|
||||
void MbD::GeneralSpline::calcCyclicIndexAndDelta()
|
||||
{
|
||||
auto xFirst = xs->front();
|
||||
auto xLast = xs->back();
|
||||
double xFirst = xs->front();
|
||||
double xLast = xs->back();
|
||||
xvalue = std::fmod(xvalue - xFirst, xLast - xFirst) + xFirst;
|
||||
calcIndexAndDelta();
|
||||
}
|
||||
|
||||
void MbD::GeneralSpline::calcNonCyclicIndexAndDelta()
|
||||
{
|
||||
auto xFirst = xs->front();
|
||||
auto xLast = xs->back();
|
||||
double xFirst = xs->front();
|
||||
double xLast = xs->back();
|
||||
if (xvalue <= xFirst) {
|
||||
index = 0;
|
||||
delta = xvalue - xFirst;
|
||||
@@ -230,7 +230,7 @@ double MbD::GeneralSpline::y(double xxx)
|
||||
|
||||
calcIndexAndDeltaFor(xxx);
|
||||
auto& derivsi = derivs->at(index);
|
||||
auto sum = 0.0;
|
||||
double sum = 0.0;
|
||||
for (int j = degree; j >= 1; j--)
|
||||
{
|
||||
sum = (sum + derivsi->at((size_t)j - 1)) * delta / j;
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace MbD {
|
||||
virtual void interpolateAt(double t);
|
||||
|
||||
SystemSolver* system;
|
||||
double tout = 0, hout = 0, hmin = 0, hmax = 0, tstart = 0, tend = 0;
|
||||
double tout = 0.0, hout = 0.0, hmin = 0.0, hmax = 0.0, tstart = 0.0, tend = 0.0;
|
||||
std::shared_ptr<BasicQuasiIntegrator> integrator;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ void LDUFullMatParPv::doPivoting(int p)
|
||||
|
||||
//| app max rowPivot aip mag |
|
||||
auto app = matrixA->at(p)->at(p);
|
||||
auto max = app * rowScalings->at(p);
|
||||
double max = app * rowScalings->at(p);
|
||||
if (max < 0.0) max = -max;
|
||||
auto rowPivot = p;
|
||||
for (int i = p + 1; i < m; i++)
|
||||
|
||||
@@ -64,7 +64,7 @@ void MatrixSolver::findScalingsForRowRange(int begin, int end)
|
||||
rowScalings = std::make_shared<FullColumn<double>>(m);
|
||||
for (int i = begin; i < end; i++)
|
||||
{
|
||||
auto maxRowMagnitude = this->getmatrixArowimaxMagnitude(i);
|
||||
double maxRowMagnitude = this->getmatrixArowimaxMagnitude(i);
|
||||
if (maxRowMagnitude == 0.0) throwSingularMatrixError("");
|
||||
rowScalings->at(i) = 1.0 / maxRowMagnitude;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ void MbD::MomentOfInertiaSolver::example1()
|
||||
|
||||
void MbD::MomentOfInertiaSolver::doFullPivoting(int p)
|
||||
{
|
||||
auto max = 0.0;
|
||||
double max = 0.0;
|
||||
auto pivotRow = p;
|
||||
auto pivotCol = p;
|
||||
for (int i = p; i < 3; i++)
|
||||
|
||||
@@ -267,8 +267,8 @@ void Part::fillqsuWeights(DiagMatDsptr diagMat)
|
||||
|
||||
auto mMax = this->root()->maximumMass();
|
||||
auto aJiMax = this->root()->maximumMomentOfInertia();
|
||||
auto minw = 1.0e3;
|
||||
auto maxw = 1.0e6;
|
||||
double minw = 1.0e3;
|
||||
double maxw = 1.0e6;
|
||||
auto wqX = std::make_shared<DiagonalMatrix<double>>(3);
|
||||
auto wqE = std::make_shared<DiagonalMatrix<double>>(4);
|
||||
if (mMax == 0) { mMax = 1.0; }
|
||||
@@ -313,10 +313,10 @@ void Part::fillqsudotWeights(DiagMatDsptr diagMat)
|
||||
//| mMax aJiMax maxInertia minw maxw aJi wqXdot wqEdot |
|
||||
auto mMax = this->root()->maximumMass();
|
||||
auto aJiMax = this->root()->maximumMomentOfInertia();
|
||||
auto maxInertia = std::max(mMax, aJiMax);
|
||||
double maxInertia = std::max(mMax, aJiMax);
|
||||
if (maxInertia == 0) maxInertia = 1.0;
|
||||
auto minw = 1.0e-12 * maxInertia;
|
||||
auto maxw = maxInertia;
|
||||
double minw = 1.0e-12 * maxInertia;
|
||||
double maxw = maxInertia;
|
||||
auto wqXdot = std::make_shared<DiagonalMatrix<double>>(3);
|
||||
auto wqEdot = std::make_shared<DiagonalMatrix<double>>(4);
|
||||
for (int i = 0; i < 3; i++)
|
||||
|
||||
@@ -43,10 +43,10 @@ namespace MbD {
|
||||
//template<typename T>
|
||||
//inline double RowTypeMatrix<T>::maxMagnitude()
|
||||
//{
|
||||
// auto max = 0.0;
|
||||
// double max = 0.0;
|
||||
// for (int i = 0; i < this->size(); i++)
|
||||
// {
|
||||
// auto element = this->at(i)->maxMagnitude();
|
||||
// double element = this->at(i)->maxMagnitude();
|
||||
// if (max < element) max = element;
|
||||
// }
|
||||
// return max;
|
||||
|
||||
@@ -166,10 +166,10 @@ namespace MbD {
|
||||
template<typename T>
|
||||
inline double SparseMatrix<T>::maxMagnitude()
|
||||
{
|
||||
auto max = 0.0;
|
||||
double max = 0.0;
|
||||
for (int i = 0; i < this->size(); i++)
|
||||
{
|
||||
auto element = this->at(i)->maxMagnitude();
|
||||
double element = this->at(i)->maxMagnitude();
|
||||
if (max < element) max = element;
|
||||
}
|
||||
return max;
|
||||
|
||||
@@ -89,21 +89,21 @@ namespace MbD {
|
||||
int iterMaxAccKine = 25;
|
||||
std::shared_ptr <QuasiIntegrator> basicIntegrator;
|
||||
std::shared_ptr<std::vector<double>> tstartPasts;
|
||||
double tstart = 0;
|
||||
double tstart = 0.0;
|
||||
double tend = 25;
|
||||
double toutFirst = 0.0;
|
||||
double hmin = 1.0e-9;
|
||||
double hmax = 1.0;
|
||||
double hout = 1.0e-1;
|
||||
double direction = 1;
|
||||
double corAbsTol = 0;
|
||||
double corRelTol = 0;
|
||||
double intAbsTol = 0;
|
||||
double intRelTol = 0;
|
||||
double corAbsTol = 0.0;
|
||||
double corRelTol = 0.0;
|
||||
double intAbsTol = 0.0;
|
||||
double intRelTol = 0.0;
|
||||
int iterMaxDyn = 0;
|
||||
int orderMax = 0;
|
||||
double translationLimit = 0;
|
||||
double rotationLimit = 0;
|
||||
double translationLimit = 0.0;
|
||||
double rotationLimit = 0.0;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user