Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void calcH(double maxh, double hstep, const double delta, double * const*rkf)
- {
- static uint32_t result_i = 0;
- double resultmx = 0;
- double resultmy = 0;
- double resultmxy = 0;
- uint32_t maxCountery = 0;
- uint32_t maxCounterx = 0;
- uint32_t maxCounterxy = 0;
- double h = hstep;
- while (h <= maxh)
- {
- uint32_t counterx = 0;
- uint32_t countery = 0;
- uint32_t counterxy = 0;
- double x1;
- double x2;
- double x0[2]{ 0, 1 };
- uint32_t i = 0;
- for (double step = 0; step < 0.41; step += 0.01)
- {
- x2 = step;
- x1 = x2 - 0.01;
- rungecutte(step, x0, h);
- if (abs(fmax(rkf[i][1], x0[1]) - fmin(rkf[i][1], x0[1])) < delta)
- {
- ++countery;
- }
- if (abs(fmax(rkf[i][0], x0[0]) - fmin(rkf[i][0], x0[0])) < delta)
- {
- ++counterx;
- }
- if (abs(fmax(rkf[i][0], x0[0]) - fmin(rkf[i][0], x0[0])) < delta &&
- abs(fmax(rkf[i][1], x0[1]) - fmin(rkf[i][1], x0[1])) < delta)
- {
- ++counterxy;
- }
- ++i;
- }
- if (maxCounterx <= counterx)
- {
- resultmx = h;
- maxCounterx = counterx;
- }
- if (maxCountery <= countery)
- {
- resultmy = h;
- maxCountery = countery;
- }
- if (maxCounterxy <= counterxy)
- {
- resultmxy = h;
- maxCounterxy = counterxy;
- }
- h += hstep;
- }
- if (result_i != 0 && std::stoi(deltas[result_i][2].get()[0]) == maxCounterxy
- && std::stoi(deltas[result_i][4].get()[0]) == maxCounterx
- && std::stoi(deltas[result_i][6].get()[0]) == maxCountery)
- {
- return;
- }
- ++result_i;
- deltas[result_i][0] = std::to_string(delta);
- deltas[result_i][1] = resultmxy;
- deltas[result_i][2] = maxCounterxy;
- deltas[result_i][3] = resultmx;
- deltas[result_i][4] = maxCounterx;
- deltas[result_i][5] = resultmy;
- deltas[result_i][6] = maxCountery;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement