From fcf77faf19dcb9d75b7842ec7138551bd73418cf Mon Sep 17 00:00:00 2001 From: justanothercatgirl Date: Sun, 24 Nov 2024 19:42:42 +0300 Subject: Added 101 prak --- 107/main.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 107/main.cpp (limited to '107/main.cpp') diff --git a/107/main.cpp b/107/main.cpp new file mode 100644 index 0000000..e731a06 --- /dev/null +++ b/107/main.cpp @@ -0,0 +1,46 @@ +#include "include/praktable.hpp" +#include + +using table = prak::table; + +double mu(const std::vector &ab) { + return ab[0] / ab[1]; +} + +void proc_table(table &t) { + using namespace std::placeholders; + + t.fill_column("sb", 0.003); // 3 millimeters + t.apply(prak::avg, {"a1", "a2", "a3"}, "a"); + t.apply([](const std::vector& args) -> double { + return std::sqrt(std::pow(prak::stddev(args), 2) + 0.003*0.003); + }, {"a1", "a2", "a3"}, "sa"); // error = sqrt(stddev^2 + systerr^2) + t.apply(mu, {"a", "b"}, "mu"); + t.apply([](const std::vector &arg) -> double { + std::vector args = {arg[0], arg[1]}; + std::vector sargs = {arg[2], arg[3]}; + return prak::sigma(mu, args, sargs); + }, {"a", "b", "sa", "sb"}, "smu"); +} + +void ex1(void) { + table t; + t.read("data1"); + proc_table(t); + std::cout << "Таблица для 1 упражнения: " << t; +} +void ex2(void) { + table a1, a2; + a1.read("data21"); + a2.read("data22"); + proc_table(a1); + proc_table(a2); + std::cout << "Таблица для 2.1: " << a1; + std::cout << "Таблица для 2.2: " << a2; +} + +int main() { + ex1(); + ex2(); + return 0; +} -- cgit v1.2.3-70-g09d2