get rid of piForeach
apply some code analyzer recommendations ICU flag now check if libicu exists prepare for more accurate growth of containers (limited PoT, then constantly increase size)
This commit is contained in:
@@ -633,7 +633,7 @@ public:
|
||||
//! \~russian
|
||||
//! \brief Транспонирование матрицы.
|
||||
//! \details Работает только с квадратными матрицами.
|
||||
//! \return копия транспонированной матрицы.
|
||||
//! \return Копия транспонированной матрицы.
|
||||
PIMathMatrixT<Cols, Rows, Type> transposed() const {
|
||||
PIMathMatrixT<Cols, Rows, Type> tm;
|
||||
PIMM_FOR tm[c][r] = m[r][c];
|
||||
@@ -647,8 +647,8 @@ public:
|
||||
//! \~russian
|
||||
//! \brief Операция поворота матрицы.
|
||||
//! \details Работает только с матрицами 2x2.
|
||||
//! \return повернутая матрица.
|
||||
PIMathMatrixT<Rows, Cols, Type> rotate(Type angle) {
|
||||
//! \return Эта повернутая матрица.
|
||||
PIMathMatrixT<Rows, Cols, Type> & rotate(Type angle) {
|
||||
static_assert(Rows == 2 && Cols == 2, "Works only with 2x2 matrix");
|
||||
Type c = std::cos(angle);
|
||||
Type s = std::sin(angle);
|
||||
@@ -667,8 +667,8 @@ public:
|
||||
//! \~russian
|
||||
//! \brief Операция поворота матрицы.
|
||||
//! \details Работает только с матрицами 2x2.
|
||||
//! \return копия повернутой матрицы.
|
||||
PIMathMatrixT<Rows, Cols, Type> & rotated(Type angle) {
|
||||
//! \return Копия повернутой матрицы.
|
||||
PIMathMatrixT<Rows, Cols, Type> rotated(Type angle) {
|
||||
static_assert(Rows == 2 && Cols == 2, "Works only with 2x2 matrix");
|
||||
PIMathMatrixT<Cols, Rows, Type> outm;
|
||||
Type c = std::cos(angle);
|
||||
|
||||
@@ -34,6 +34,11 @@ const char PIMathSolver::methods_desc[] = "b{Methods:}\
|
||||
PIMathSolver::Method PIMathSolver::method_global = PIMathSolver::Eyler_2;
|
||||
|
||||
|
||||
PIMathSolver::PIMathSolver() {
|
||||
times.resize(4);
|
||||
}
|
||||
|
||||
|
||||
void PIMathSolver::solve(double u, double h) {
|
||||
switch (method) {
|
||||
case Global:
|
||||
@@ -128,6 +133,12 @@ void PIMathSolver::fromTF(const TransferFunction & TF) {
|
||||
}
|
||||
|
||||
|
||||
void PIMathSolver::setTime(double time) {
|
||||
times.pop_back();
|
||||
times.push_front(time);
|
||||
}
|
||||
|
||||
|
||||
void PIMathSolver::solveEyler1(double u, double h) {
|
||||
F[0] = A * X + d * u;
|
||||
X += F[0] * h;
|
||||
@@ -258,3 +269,41 @@ void PIMathSolver::solvePA(double u, double h, uint deg) {
|
||||
}
|
||||
moveF();
|
||||
}
|
||||
|
||||
|
||||
void PIMathSolver::solvePA2(double u, double h) {
|
||||
if (step > 0)
|
||||
solvePA(u, h, 2);
|
||||
else
|
||||
solveEyler1(u, h);
|
||||
}
|
||||
|
||||
|
||||
void PIMathSolver::solvePA3(double u, double h) {
|
||||
if (step > 1)
|
||||
solvePA(u, h, 3);
|
||||
else
|
||||
solvePA2(u, h);
|
||||
}
|
||||
|
||||
|
||||
void PIMathSolver::solvePA4(double u, double h) {
|
||||
if (step > 2)
|
||||
solvePA(u, h, 4);
|
||||
else
|
||||
solvePA3(u, h);
|
||||
}
|
||||
|
||||
|
||||
void PIMathSolver::solvePA5(double u, double h) {
|
||||
if (step > 3)
|
||||
solvePA(u, h, 5);
|
||||
else
|
||||
solvePA4(u, h);
|
||||
}
|
||||
|
||||
|
||||
void PIMathSolver::moveF() {
|
||||
for (uint i = F.size() - 1; i > 0; --i)
|
||||
F[i] = F[i - 1];
|
||||
}
|
||||
|
||||
@@ -48,18 +48,12 @@ public:
|
||||
PolynomialApproximation_5 = 35
|
||||
};
|
||||
|
||||
PIMathSolver() {
|
||||
times.resize(4);
|
||||
step = 0;
|
||||
}
|
||||
PIMathSolver();
|
||||
|
||||
void solve(double u, double h);
|
||||
void fromTF(const TransferFunction & TF);
|
||||
void setMethod(Method m) { method = m; }
|
||||
void setTime(double time) {
|
||||
times.pop_back();
|
||||
times.push_front(time);
|
||||
}
|
||||
void setTime(double time);
|
||||
|
||||
void solveEyler1(double u, double h);
|
||||
void solveEyler2(double u, double h);
|
||||
@@ -68,40 +62,17 @@ public:
|
||||
void solveABM3(double u, double h);
|
||||
void solveABM4(double u, double h);
|
||||
void solvePA(double u, double h, uint deg);
|
||||
void solvePA2(double u, double h) {
|
||||
if (step > 0)
|
||||
solvePA(u, h, 2);
|
||||
else
|
||||
solveEyler1(u, h);
|
||||
}
|
||||
void solvePA3(double u, double h) {
|
||||
if (step > 1)
|
||||
solvePA(u, h, 3);
|
||||
else
|
||||
solvePA2(u, h);
|
||||
}
|
||||
void solvePA4(double u, double h) {
|
||||
if (step > 2)
|
||||
solvePA(u, h, 4);
|
||||
else
|
||||
solvePA3(u, h);
|
||||
}
|
||||
void solvePA5(double u, double h) {
|
||||
if (step > 3)
|
||||
solvePA(u, h, 5);
|
||||
else
|
||||
solvePA4(u, h);
|
||||
}
|
||||
void solvePA2(double u, double h);
|
||||
void solvePA3(double u, double h);
|
||||
void solvePA4(double u, double h);
|
||||
void solvePA5(double u, double h);
|
||||
|
||||
PIMathVectord X;
|
||||
static Method method_global;
|
||||
static const char methods_desc[];
|
||||
|
||||
private:
|
||||
void moveF() {
|
||||
for (uint i = F.size() - 1; i > 0; --i)
|
||||
F[i] = F[i - 1];
|
||||
}
|
||||
void moveF();
|
||||
|
||||
PIMathMatrixd A, M;
|
||||
PIMathVectord d, a1, b1;
|
||||
@@ -109,10 +80,10 @@ private:
|
||||
PIMathVectord XX, Y, pY;
|
||||
PIVector<PIMathVectord> F;
|
||||
PIVector<double> times;
|
||||
uint size, step;
|
||||
Method method;
|
||||
double sum, td, ct, lp, dh, t, x1, x0;
|
||||
bool ok;
|
||||
uint size = 0, step = 0;
|
||||
Method method = Global;
|
||||
double sum = 0., td = 0., ct = 0., lp = 0., dh = 0., t = 0., x1 = 0., x0 = 0.;
|
||||
bool ok = false;
|
||||
};
|
||||
|
||||
#endif // PIMATHSOLVER_H
|
||||
|
||||
Reference in New Issue
Block a user