GCC Code Coverage Report


Directory: ./
File: tasks/kutergin_v_trapezoid_method_of_integration/seq/src/trapezoid_integration_sequential.cpp
Date: 2026-01-10 02:40:41
Exec Total Coverage
Lines: 0 22 0.0%
Functions: 0 6 0.0%
Branches: 0 6 0.0%

Line Branch Exec Source
1 #include "../include/trapezoid_integration_sequential.hpp"
2
3 #include "../../common/include/common.hpp"
4
5 namespace kutergin_v_trapezoid_seq {
6
7 double Func(double x) // интегрируемая функция для примера
8 {
9 return x * x;
10 }
11
12 TrapezoidIntegrationSequential::TrapezoidIntegrationSequential(const InType &in) {
13 SetTypeOfTask(GetStaticTypeOfTask()); // установка типа задачи
14 GetInput() = in; // сохранение входных данных
15 GetOutput() = 0.0; // инициализация выходных данных
16 }
17
18 bool TrapezoidIntegrationSequential::ValidationImpl() {
19 return (GetInput().b >= GetInput().a) &&
20 (GetInput().n > 0); // проверка b >= a (границ интегрирования) и n > 0 (число разбиений)
21 }
22
23 bool TrapezoidIntegrationSequential::PreProcessingImpl() {
24 return true;
25 }
26
27 bool TrapezoidIntegrationSequential::RunImpl() {
28 double a = GetInput().a;
29 double b = GetInput().b;
30 int n = GetInput().n;
31
32 double h = (b - a) / n;
33 double integral_res = (Func(a) + Func(b)) / 2.0;
34
35 for (int i = 1; i < n; ++i) {
36 integral_res += Func(a + (i * h));
37 }
38
39 GetOutput() = integral_res * h;
40
41 return true;
42 }
43
44 bool TrapezoidIntegrationSequential::PostProcessingImpl() {
45 return true;
46 }
47
48 } // namespace kutergin_v_trapezoid_seq
49