aboutsummaryrefslogtreecommitdiffstats
path: root/107
diff options
context:
space:
mode:
Diffstat (limited to '107')
-rw-r--r--107/Makefile18
-rw-r--r--107/README.md5
-rw-r--r--107/compile_flags.txt4
-rw-r--r--107/data15
-rw-r--r--107/data215
-rw-r--r--107/data225
-rwxr-xr-x107/mainbin0 -> 335376 bytes
-rw-r--r--107/main.cpp46
-rw-r--r--107/plots.gp14
9 files changed, 102 insertions, 0 deletions
diff --git a/107/Makefile b/107/Makefile
new file mode 100644
index 0000000..eb309ff
--- /dev/null
+++ b/107/Makefile
@@ -0,0 +1,18 @@
+
+CFLAGS = -std=c++2c -mavx -Iinclude -ggdb
+
+.PHONY: all run_main clean gnuplot
+
+run: gnuplot
+
+gnuplot: plots.gp run_main
+ gnuplot $<
+
+run_main: main
+ ./main
+
+main: main.cpp include/*
+ $(CXX) -o $@ $< $(CFLAGS)
+
+clean:
+ rm -fr main *.png *.plot
diff --git a/107/README.md b/107/README.md
new file mode 100644
index 0000000..96fd716
--- /dev/null
+++ b/107/README.md
@@ -0,0 +1,5 @@
+<!-- Шаблон для прака -->
+<!-- файлы, заканчивающиеся на .plot считаются генерируемыми и удаляются через make clean -->
+# Обработка <> прака
+
+
diff --git a/107/compile_flags.txt b/107/compile_flags.txt
new file mode 100644
index 0000000..34ae930
--- /dev/null
+++ b/107/compile_flags.txt
@@ -0,0 +1,4 @@
+-Iinclude
+-std=c++2c
+-mavx2
+
diff --git a/107/data1 b/107/data1
new file mode 100644
index 0000000..419b8c2
--- /dev/null
+++ b/107/data1
@@ -0,0 +1,5 @@
+__name__ b sb a1 a2 a3 a sa mu smu
+b1_weigh 0.1 ? 0.0315 0.033 0.037 ? ? ? ?
+b1 0.1 ? 0.032 0.028 0.027 ? ? ? ?
+b2_weigh 0.1 ? 0.035 0.029 0.03 ? ? ? ?
+b2 0.1 ? 0.036 0.033 0.027 ? ? ? ?
diff --git a/107/data21 b/107/data21
new file mode 100644
index 0000000..5198f10
--- /dev/null
+++ b/107/data21
@@ -0,0 +1,5 @@
+__name__ b sb a1 a2 a3 a sa mu smu
+b1 0.165 ? 0.046 0.048 0.049 ? ? ? ?
+b1_weig 0.169 ? 0.047 0.046 0.046 ? ? ? ?
+b2 0.203 ? 0.062 0.063 0.063 ? ? ? ?
+b2_weig 0.195 ? 0.058 0.059 0.059 ? ? ? ?
diff --git a/107/data22 b/107/data22
new file mode 100644
index 0000000..e7614ef
--- /dev/null
+++ b/107/data22
@@ -0,0 +1,5 @@
+__name__ b sb a1 a2 a3 a sa mu smu
+b1 0.158 ? 0.046 0.048 0.047 ? ? ? ?
+b1_weig 0.1 ? 0.024 0.029 0.029 ? ? ? ?
+b2 0.1 ? 0.031 0.033 0.033 ? ? ? ?
+b2_weig 0.1 ? 0.030 0.029 0.030 ? ? ? ?
diff --git a/107/main b/107/main
new file mode 100755
index 0000000..3d5308e
--- /dev/null
+++ b/107/main
Binary files differ
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 <functional>
+
+using table = prak::table<double>;
+
+double mu(const std::vector<double> &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<double>, {"a1", "a2", "a3"}, "a");
+ t.apply([](const std::vector<double>& args) -> double {
+ return std::sqrt(std::pow(prak::stddev<double>(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<double> &arg) -> double {
+ std::vector<double> args = {arg[0], arg[1]};
+ std::vector<double> sargs = {arg[2], arg[3]};
+ return prak::sigma<double>(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;
+}
diff --git a/107/plots.gp b/107/plots.gp
new file mode 100644
index 0000000..702408a
--- /dev/null
+++ b/107/plots.gp
@@ -0,0 +1,14 @@
+set term pngcairo size 1000, 800
+set tmargin at screen 0.95
+
+f1(x) = a1*x+b1
+fit f1(x) '.plot' using 1:2:3 yerr via a1, b1
+
+set output ''
+set label "" at graph 0.5, graph 1.025 center
+set xlabel ""
+set ylabel ""
+
+plot '.plot' using 1:2:3 with yerrorbars notitle lc 0 pt 1 lw 2, \
+ f1(x) title "" lc rgb "red", \
+