| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <cmath> | ||
| 4 | #include <tuple> | ||
| 5 | #include <utility> | ||
| 6 | |||
| 7 | #include "task/include/task.hpp" | ||
| 8 | |||
| 9 | namespace kutuzov_i_simpson_integration { | ||
| 10 | |||
| 11 | // n, x_min-x_max, y_min-y_max, function_id | ||
| 12 | using InType = std::tuple<int, std::pair<double, double>, std::pair<double, double>, int>; | ||
| 13 | using OutType = double; | ||
| 14 | // n, x_min-x_max, y_min-y_max, function_id | ||
| 15 | using TestType = std::tuple<int, std::pair<double, double>, std::pair<double, double>, int>; | ||
| 16 | using BaseTask = ppc::task::Task<InType, OutType>; | ||
| 17 | |||
| 18 | 9500 | inline double FunctionPolynomial(double x, double y) { | |
| 19 | 9500 | return pow(x, 3) + (0.5 * pow(x, 2)) + (3.0 * pow(y, 6)) + (15.0 * y) + 37.0; | |
| 20 | } | ||
| 21 | |||
| 22 | 9500 | inline double FunctionTrigonometric(double x, double y) { | |
| 23 | 9500 | return pow(sin(x), 5) + (1.3 * cos(0.7 * x) * sin(1.4 * y)) - atan((15.0 * x) + (7.0 * y)); | |
| 24 | } | ||
| 25 | |||
| 26 | 9500 | inline double FunctionExponents(double x, double y) { | |
| 27 | 9500 | return (1.7 * exp(3.7 * x)) + (exp(3.0 * x * y) * log(pow(x + y, 2) + 1.0)) - | |
| 28 | 9500 | log(pow((17.0 * x) - (8.0 * y), 4) + 0.1); | |
| 29 | } | ||
| 30 | |||
| 31 | 9500 | inline double FunctionComplex(double x, double y) { | |
| 32 | double sum = 0.0; | ||
| 33 |
2/2✓ Branch 0 taken 1900000 times.
✓ Branch 1 taken 9500 times.
|
1909500 | for (int i = 1; i <= 200; i++) { |
| 34 | 1900000 | double add = (sin((0.3 * pow(x * i, 4) * pow(y, 2)) + (0.5 * cos(y / i) * pow(x, 7)) + (1.8 * pow(y, 5)))); | |
| 35 |
2/2✓ Branch 0 taken 950000 times.
✓ Branch 1 taken 950000 times.
|
1900000 | if (i % 2 == 0) { |
| 36 | 950000 | sum += add; | |
| 37 | } else { | ||
| 38 | 950000 | sum -= add; | |
| 39 | } | ||
| 40 | } | ||
| 41 | 9500 | return sum; | |
| 42 | } | ||
| 43 | |||
| 44 | 38000 | inline double CallFunction(int function_id, double x, double y) { | |
| 45 |
4/5✓ Branch 0 taken 9500 times.
✓ Branch 1 taken 9500 times.
✓ Branch 2 taken 9500 times.
✓ Branch 3 taken 9500 times.
✗ Branch 4 not taken.
|
38000 | switch (function_id) { |
| 46 | 9500 | case 1: | |
| 47 | 9500 | return FunctionPolynomial(x, y); | |
| 48 | 9500 | case 2: | |
| 49 | 9500 | return FunctionTrigonometric(x, y); | |
| 50 | 9500 | case 3: | |
| 51 | 9500 | return FunctionExponents(x, y); | |
| 52 | 9500 | case 4: | |
| 53 | 9500 | return FunctionComplex(x, y); | |
| 54 | default: | ||
| 55 | return 1.0; | ||
| 56 | } | ||
| 57 | } | ||
| 58 | |||
| 59 | } // namespace kutuzov_i_simpson_integration | ||
| 60 |