| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <cmath> | ||
| 4 | #include <tuple> | ||
| 5 | |||
| 6 | #include "task/include/task.hpp" | ||
| 7 | |||
| 8 | namespace luzan_e_simps_int { | ||
| 9 | |||
| 10 | // n, a-b, c-d, func_num | ||
| 11 | using InType = std::tuple<int, std::tuple<double, double>, std::tuple<double, double>, int>; | ||
| 12 | using OutType = double; | ||
| 13 | // n, a-b, c-d, func_num | ||
| 14 | using TestType = std::tuple<int, std::tuple<double, double>, std::tuple<double, double>, int>; | ||
| 15 | using BaseTask = ppc::task::Task<InType, OutType>; | ||
| 16 | |||
| 17 | const double kEpsilon = 0.001; | ||
| 18 | |||
| 19 | 487122 | inline double F1(double x, double y) { | |
| 20 | 487122 | return (pow(x, 5) / 5.0) + (y * sin(y)) + 2.0; | |
| 21 | } | ||
| 22 | |||
| 23 | 3230 | inline double F2(double x, double y) { | |
| 24 | 3230 | return (pow(x, 5) / 5.0) + (y * cos(y)) + 2.0; | |
| 25 | } | ||
| 26 | |||
| 27 | 779494 | inline double F3(double x, double y) { | |
| 28 | 779494 | return (exp(-(x * x) - (y * y)) * sin(10 * x)) * cos(10 * y); | |
| 29 | } | ||
| 30 | |||
| 31 | 2027015 | inline double F4(double x, double y) { | |
| 32 | 2027015 | double r = sqrt((x * x) + (y * y)); | |
| 33 | 2027015 | return (exp(-r) * sin(20 * r)) + log(1 + (x * x) + (y * y)); | |
| 34 | } | ||
| 35 | |||
| 36 | 475 | inline double F5(double x, double y) { | |
| 37 | double s = 0.0; | ||
| 38 |
2/2✓ Branch 0 taken 71250 times.
✓ Branch 1 taken 475 times.
|
71725 | for (int k = 1; k <= 150; k++) { |
| 39 | 71250 | s += (sin(pow(x, 5)) * cos(k * y)) + (log(1 + (x * x) + (y * y)) * 5); | |
| 40 | } | ||
| 41 | 475 | return s; | |
| 42 | } | ||
| 43 | |||
| 44 | inline double GetWeight(int i, int n) { | ||
| 45 |
4/4✓ Branch 0 taken 20102 times.
✓ Branch 1 taken 608 times.
✓ Branch 2 taken 3255916 times.
✓ Branch 3 taken 41420 times.
|
3318046 | if (i == 0 || i == n) { |
| 46 | return 1.0; | ||
| 47 | } | ||
| 48 |
4/4✓ Branch 0 taken 10203 times.
✓ Branch 1 taken 9899 times.
✓ Branch 2 taken 1638313 times.
✓ Branch 3 taken 1617603 times.
|
3276018 | if (i % 2 == 1) { |
| 49 | 1648516 | return 4.0; | |
| 50 | } | ||
| 51 | return 2.0; | ||
| 52 | } | ||
| 53 | |||
| 54 | inline auto GetFunc(int num) { | ||
| 55 |
5/5✓ Branch 0 taken 40 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 20 times.
✓ Branch 4 taken 120 times.
|
320 | switch (num) { |
| 56 | case 1: | ||
| 57 | return &F1; | ||
| 58 | 40 | case 2: | |
| 59 | 40 | return &F2; | |
| 60 | 40 | case 3: | |
| 61 | 40 | return &F3; | |
| 62 | 100 | case 4: | |
| 63 | 100 | return &F4; | |
| 64 | 20 | case 5: | |
| 65 | 20 | return &F5; | |
| 66 | default: | ||
| 67 | return &F1; | ||
| 68 | } | ||
| 69 | } | ||
| 70 | |||
| 71 | } // namespace luzan_e_simps_int | ||
| 72 |