diff options
author | justanothercatgirl <sotov2070@gmail.com> | 2025-04-14 00:34:52 +0300 |
---|---|---|
committer | justanothercatgirl <sotov2070@gmail.com> | 2025-04-14 00:34:52 +0300 |
commit | 5ee716791bf7a8ca74c1670a6887a53ab92141f6 (patch) | |
tree | 0a5a522f89d258ec36f4af23cc60aaa578abe7e8 | |
parent | 320bf2f0155edd67557a3042403eeb843b90a41d (diff) |
added 218, 226, 234, 240
-rw-r--r-- | 218/Makefile | 18 | ||||
-rw-r--r-- | 218/README.md | 5 | ||||
-rw-r--r-- | 218/compile_flags.txt | 4 | ||||
-rw-r--r-- | 218/data | 8 | ||||
l--------- | 218/include | 1 | ||||
-rw-r--r-- | 218/main.cpp | 19 | ||||
-rw-r--r-- | 218/plots.gp | 16 | ||||
-rw-r--r-- | 219/main.cpp | 8 | ||||
-rw-r--r-- | 226/Makefile | 18 | ||||
-rw-r--r-- | 226/README.md | 5 | ||||
-rw-r--r-- | 226/compile_flags.txt | 4 | ||||
-rw-r--r-- | 226/data | 8 | ||||
l--------- | 226/include | 1 | ||||
-rw-r--r-- | 226/main.cpp | 32 | ||||
-rw-r--r-- | 226/plot.pdf | bin | 0 -> 142006 bytes | |||
-rw-r--r-- | 226/plots.gp | 24 | ||||
-rw-r--r-- | 234/Makefile | 18 | ||||
-rw-r--r-- | 234/README.md | 5 | ||||
-rw-r--r-- | 234/compile_flags.txt | 4 | ||||
-rw-r--r-- | 234/data3 | 7 | ||||
l--------- | 234/include | 1 | ||||
-rw-r--r-- | 234/main.cpp | 76 | ||||
-rw-r--r-- | 234/plots.gp | 30 | ||||
-rw-r--r-- | 240/Makefile | 18 | ||||
-rw-r--r-- | 240/README.md | 5 | ||||
-rw-r--r-- | 240/compile_flags.txt | 4 | ||||
-rw-r--r-- | 240/data | 11 | ||||
l--------- | 240/include | 1 | ||||
-rw-r--r-- | 240/main.cpp | 28 | ||||
-rw-r--r-- | 240/plots.gp | 16 | ||||
-rw-r--r-- | libprakpp/include/prakphys.hpp | 2 | ||||
-rw-r--r-- | libprakpp/include/praktable.hpp | 4 | ||||
-rw-r--r-- | tempalte/main.cpp | 1 | ||||
-rw-r--r-- | tempalte/plots.gp | 3 |
34 files changed, 397 insertions, 8 deletions
diff --git a/218/Makefile b/218/Makefile new file mode 100644 index 0000000..224506f --- /dev/null +++ b/218/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 $< &>/dev/null + +run_main: main + ./main + +main: main.cpp include/* + $(CXX) -o $@ $< $(CFLAGS) + +clean: + rm -fr main *.png *.plot diff --git a/218/README.md b/218/README.md new file mode 100644 index 0000000..96fd716 --- /dev/null +++ b/218/README.md @@ -0,0 +1,5 @@ +<!-- Шаблон для прака --> +<!-- файлы, заканчивающиеся на .plot считаются генерируемыми и удаляются через make clean --> +# Обработка <> прака + + diff --git a/218/compile_flags.txt b/218/compile_flags.txt new file mode 100644 index 0000000..34ae930 --- /dev/null +++ b/218/compile_flags.txt @@ -0,0 +1,4 @@ +-Iinclude +-std=c++2c +-mavx2 + diff --git a/218/data b/218/data new file mode 100644 index 0000000..fe6e835 --- /dev/null +++ b/218/data @@ -0,0 +1,8 @@ +dp dt +215 7.9 +178 9.5 +150 10.2 +133 11.2 +96 13 +75 15 +56 18 diff --git a/218/include b/218/include new file mode 120000 index 0000000..2225752 --- /dev/null +++ b/218/include @@ -0,0 +1 @@ +../libprakpp/include/
\ No newline at end of file diff --git a/218/main.cpp b/218/main.cpp new file mode 100644 index 0000000..379804a --- /dev/null +++ b/218/main.cpp @@ -0,0 +1,19 @@ +#include <iostream> +#include "include/praktable.hpp" +#include "include/prakphys.hpp" + +int main() { + prak::table<f64> t("data"); + t .add_column("1/dt") + .apply(prak::inv<f64>, "dt", "1/dt") + .write_plot("1dt(dp).plot", "dp", "1/dt", std::nullopt) + .print(); + auto [A, B] = t.least_squares_linear("dp", "1/dt", std::nullopt, 0.00001); + f64 W = 3.82; + prak::pvalue<f64> beta = {1.51e-6, 0.05e-6}, T0 = {298.5, 1}, p0 = {0.99e5, 500}, + CPR = A * W * T0 / beta / p0, CP = CPR * prak::R<f64>, + CVR = CPR - 1.0, CV = CVR * prak::R<f64>, i = 2.0*CV/prak::R<f64>; + + std::cout var(A) var(B) var(beta) var(p0) var(CPR) var(CP) var(CVR) var(CV) var(i) << std::endl; + return 0; +} diff --git a/218/plots.gp b/218/plots.gp new file mode 100644 index 0000000..eb9516c --- /dev/null +++ b/218/plots.gp @@ -0,0 +1,16 @@ +set term pngcairo size 1000, 800 +set grid + +f1(x) = a1*x+b1 +fit f1(x) '1dt(dp).plot' via a1, b1 + +set output '1dt(dp).png' +set title "График зависимости велечины, обратной температуре воздуха, от разницы давлений" +set xlabel "1/T (1/К)" +set ylabel "P (Па)" +set key top left + +set label sprintf("A = %.4g\n B = %.4g", a1, b1) at graph 0.2, 0.9 front boxed +plot '1dt(dp).plot' notitle lc 0 pt 1 lw 2, \ + f1(x) title "1/dT(dP)" lc rgb "red" + diff --git a/219/main.cpp b/219/main.cpp index f6fc4e2..d5a4735 100644 --- a/219/main.cpp +++ b/219/main.cpp @@ -25,14 +25,14 @@ f64p (ex1) (std::string file) { L = {0.25, 0.005}, r_2 = {0.006, 5e-6}, r_1 = {0.075e-3, 5e-6}, k = prak::function<f64>([](vecarg a){ return a[0] * a[1] / (2 * prak::PI * a[2] * a[3]) * std::log(a[4]/a[5]);}, {alpha, B, L, A, r_2, r_1}); - std::cout << "k = " << k << '\n'; + std::cout var(alpha) var (L) var(r_1) var(r_2) << "k = " << k << '\n'; f64p eps = {0.35, 0.005}, sgm = {5.67e-8, 0.01e-8}, S = prak::function<f64>([](vecarg a){ return 2 * prak::PI * a[0] * a[1]; }, {r_1, L}), R = {t.col_avg("R"), 0}, dT = prak::function<f64>([](vecarg a){return std::abs((a[0] - a[1])/(a[1]*a[2]));}, {R, B, alpha}), T_0 = {295, 5}, T_1 = T_0 + dT, W_rad = eps * sgm * (T_1*T_1*T_1*T_1 - T_0*T_0*T_0*T_0)*S, g = {9.8, 0.05}, beta = 1.0 / T_0, nu = {1.6e-5, 0.1e-5}, Gr = g * beta * L * L * L * dT / nu / nu, alpha2 = 0.75 * k / L * ((0.7 * Gr) ^ 0.25), W_con = alpha2 * dT * S; - std::cout var(eps) var(sgm) var(R) var(dT) var(T_0) var(T_1) var(W_rad) var(beta) var(nu) var(Gr) var(alpha2) var(W_con); + std::cout var(eps) var(sgm) var(R) var(dT) var(T_0) var(T_1) var(S) var(W_rad) var(beta) var(nu) var(Gr) var(alpha2) var(W_con); return k; } @@ -54,8 +54,8 @@ f64p (ex2) (const std::string& s) { int (main) (void) { std::cout << ex1("data") / ex2("data2") / 2.0 - << " = C_P\nпо табличным значениям: C_P = " << 0.0259 / 0.001004 / 2 - << "\nПо здравому смыслу:7/2R = " << 7.0/2 * 8.31 << std::endl; + << " = C_V\nпо табличным значениям: C_V = " << 0.0259 / 0.001004 / 2 + << "\nПо здравому смыслу:5/2R = " << 5.0/2 * 8.31 << std::endl; return 0; } diff --git a/226/Makefile b/226/Makefile new file mode 100644 index 0000000..224506f --- /dev/null +++ b/226/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 $< &>/dev/null + +run_main: main + ./main + +main: main.cpp include/* + $(CXX) -o $@ $< $(CFLAGS) + +clean: + rm -fr main *.png *.plot diff --git a/226/README.md b/226/README.md new file mode 100644 index 0000000..96fd716 --- /dev/null +++ b/226/README.md @@ -0,0 +1,5 @@ +<!-- Шаблон для прака --> +<!-- файлы, заканчивающиеся на .plot считаются генерируемыми и удаляются через make clean --> +# Обработка <> прака + + diff --git a/226/compile_flags.txt b/226/compile_flags.txt new file mode 100644 index 0000000..34ae930 --- /dev/null +++ b/226/compile_flags.txt @@ -0,0 +1,4 @@ +-Iinclude +-std=c++2c +-mavx2 + diff --git a/226/data b/226/data new file mode 100644 index 0000000..629cedb --- /dev/null +++ b/226/data @@ -0,0 +1,8 @@ +U T1 T2 T3 sT1 sT2 sT3 T sT dU sdU vpr epr +2.1 575 539 610 63 99 74 ? ? 1 0.01 139 0.02 +2.26 647 651 671 78 64 71 ? ? 1 0.01 143 0.04 +2.4 882 886 872 76 84 99 ? ? 1.02 0.01 171 ? +2.54 1021 1079 1033 151 137 126 ? ? 1.03 0.02 193 ? +2.68 1089 1143 1121 157 87 88 ? ? 1.026 0.01 196 ? +2.82 1111 1160 1053 183 237 287 ? ? 0.997 0.03 206 ? +3.0 1109 1063 1089 251 242 265 ? ? 0.957 0.03 206 ? diff --git a/226/include b/226/include new file mode 120000 index 0000000..2225752 --- /dev/null +++ b/226/include @@ -0,0 +1 @@ +../libprakpp/include/
\ No newline at end of file diff --git a/226/main.cpp b/226/main.cpp new file mode 100644 index 0000000..9584e60 --- /dev/null +++ b/226/main.cpp @@ -0,0 +1,32 @@ +#include "include/praktable.hpp" +#include "include/prakphys.hpp" + +using table = prak::table<f64>; +using f64p = prak::pvalue<f64>; +using f64v = std::vector<f64>; +using vecarg = const std::vector<f64> &; +using argvec = const std::vector<f64> &; + +void ex1(std::string file) { + table t(file); + t .apply(prak::avg<f64>, {"T1", "T2", "T3"}, "T") + .apply([](vecarg a){ + return std::sqrt(std::pow(prak::stddev<f64>({a[0], a[1], a[2]}), 2) + + std::pow(prak::avg<f64>({a[3], a[4], a[5]}), 2)/3.0); + }, {"T1", "T2", "T3", "sT1", "sT2", "sT3"}, "sT") + .add_columns({"Tv", "sTv", "Te", "sTe"}) + .add_columns({"svpr", "sepr"}, 6e3) + .multiply_column("vpr", 1e3) + .multiply_column("epr", conv::eV_to_J<f64>) + .apply_function([](vecarg a){return prak::m_e<f64> * a[0] * a[0] / (2 * prak::k<f64>);}, {"vpr"}, {"svpr"}, "Tv", "sTv") + .apply_function([](vecarg a){return 2 * a[0] / prak::k<f64>;}, {"epr"}, {"sepr"}, "Te", "sTe") + .delete_cols({"svpr", "sepr", "sTe"}) + .write_plot("T(U).plot", "U", "T", "sT") + .write_plot("Tv(U).plot", "U", "Tv", "sTv") + .print(); +} + +int main() { + ex1("data"); + return 0; +} diff --git a/226/plot.pdf b/226/plot.pdf Binary files differnew file mode 100644 index 0000000..339cdf8 --- /dev/null +++ b/226/plot.pdf diff --git a/226/plots.gp b/226/plots.gp new file mode 100644 index 0000000..853d03d --- /dev/null +++ b/226/plots.gp @@ -0,0 +1,24 @@ +set term pngcairo size 2400, 2000 font "Arial,30" +set grid lw 4 + +f1(x) = a1*x + b1 +f2(x) = a2*x + b2 + +fit f1(x) 'T(U).plot' using 1:2:3 yerr via a1,b1 +a2=a1 +fit f2(x) 'Tv(U).plot' using 1:2:3 yerr via a2,b2 + +set output 'plot.png' +set title "Зависимость температур термоэлектронов от напряжения накала" +set xlabel "U, В" +set ylabel "T, К" +set key top left + +set xrange[2.09:3.01] + +plot 'T(U).plot' using 1:2:3 with yerrorbars title "Расчёт по программе" lc rgb("blue") pt 2 lw 5, \ + f1(x) lc rgb "red" lw 3 title "Расчёт по программе", \ + 'Tv(U).plot' using 1:2:3 with yerrorbars title "расчёт по v_{нв}" lc rgb("orange") pt 3 lw 5, \ + f2(x) lc rgb "green" lw 3 title "расчёт по v_{нв}" +#'T(U).plot' with lines smooth csplines lc rgb "red" lw 3 title "Расчёт по ", \ +#'Tv(U).plot' with lines smooth csplines lc rgb "green" lw 3 title "Расчёт по v_{нв}" diff --git a/234/Makefile b/234/Makefile new file mode 100644 index 0000000..224506f --- /dev/null +++ b/234/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 $< &>/dev/null + +run_main: main + ./main + +main: main.cpp include/* + $(CXX) -o $@ $< $(CFLAGS) + +clean: + rm -fr main *.png *.plot diff --git a/234/README.md b/234/README.md new file mode 100644 index 0000000..96fd716 --- /dev/null +++ b/234/README.md @@ -0,0 +1,5 @@ +<!-- Шаблон для прака --> +<!-- файлы, заканчивающиеся на .plot считаются генерируемыми и удаляются через make clean --> +# Обработка <> прака + + diff --git a/234/compile_flags.txt b/234/compile_flags.txt new file mode 100644 index 0000000..34ae930 --- /dev/null +++ b/234/compile_flags.txt @@ -0,0 +1,4 @@ +-Iinclude +-std=c++2c +-mavx2 + diff --git a/234/data3 b/234/data3 new file mode 100644 index 0000000..3b9cb69 --- /dev/null +++ b/234/data3 @@ -0,0 +1,7 @@ +n s s2 sn t +0.3881 0.6102 ? ? 2 +1.97 1.411 ? ? 10 +3.834 1.885 ? ? 20 +7.802 2.738 ? ? 40 +16.08 3.8 ? ? 80 +31.71 5.75 ? ? 160 diff --git a/234/include b/234/include new file mode 120000 index 0000000..2225752 --- /dev/null +++ b/234/include @@ -0,0 +1 @@ +../libprakpp/include/
\ No newline at end of file diff --git a/234/main.cpp b/234/main.cpp new file mode 100644 index 0000000..6762d1c --- /dev/null +++ b/234/main.cpp @@ -0,0 +1,76 @@ +#include <iostream> + +#include "include/praktable.hpp" + +using table = prak::table<f64>; +using f64p = prak::pvalue<f64>; +using f64v = std::vector<f64>; +using vecarg = const std::vector<f64> &; +using argvec = const std::vector<f64> &; + +f64 factorial(u64 times) { + f64 res = 1; + for (; times; res *= times--); + return res; +} + +f64 poisson(u64 at, f64 avg) { + return std::pow(avg, at) * std::exp(-avg) / factorial(at); +} + +template <typename lambda, typename...Args> +f64 distr_sum(lambda f, u64 from, u64 to, Args...args) { + f64 res = 0; + for(; from <= to; res += f(from++, args...)); + return res; +} + +void ex1() { + f64 n = 1.053, s = 0.582553; + std::cout << "ex 1:\n" + var(distr_sum(poisson, n, n, n)) + var(distr_sum(poisson, n, n+1, n)) + var(distr_sum(poisson, std::round(n-s), std::round(n+s), n)) + var(distr_sum(poisson, std::round(n-2*s), std::round(n+2*s), n)) + << std::endl; +} +table ex3(const char* file) { + table t(file); + t .apply([](argvec a){return a[0]*a[0];}, "s", "s2") + .apply([](argvec a){return a[0]/a[1];}, std::vector<std::string>{"s", "n"}, "sn") + .write_plot("s(n).plot" , "n", "s", std::nullopt) + .write_plot("s2(n).plot", "n", "s2", std::nullopt) + .write_plot("sn(n).plot", "n", "sn", std::nullopt) + .print(); + return t; +} +void ex4(table t0) { + table t1({"count", "N", "n1", "s1", "n2", "s2", "s", "s/sn1", "s/sn2", "sqrtn1", "sqrtn2"}, 6, 0); + f64 T1 = 45e-3; + f64 T2 = 0.625; + for (int i = 0; i < 6; ++i) { + t1["count", i] = i+1; + t1["N", i] = t0["n", i] / t0["t", i] * 1000; + t1["s", i] = t0["s", i] / std::sqrt(t0["t", i] / 1000); + } + t1 .apply([T1](vecarg a){return a[0]*T1;}, "N", "n1") + .apply([T1](vecarg a){return a[0]*std::sqrt(T1);}, "s", "s1") + .apply([T2](vecarg a){return a[0]*T2;}, "N", "n2") + .apply([T2](vecarg a){return a[0]*std::sqrt(T2);}, "s", "s2"); + f64 avgn1 = t1.col_avg("n1"), + avgn2 = t1.col_avg("n2"), + savgn1 = t1.col_stddev("n1"), + savgn2 = t1.col_stddev("n2"); + t1 .apply([savgn1](vecarg a){return a[0]/savgn1;}, "s1", "s/sn1") + .apply([savgn2](vecarg a){return a[0]/savgn2;}, "s2", "s/sn2") + .apply([](vecarg a){return std::sqrt(a[0]);}, "n1", "sqrtn1") + .apply([](vecarg a){return std::sqrt(a[0]);}, "n2", "sqrtn2") + .print(); + std::cout var(avgn1)var(avgn2)var(savgn1)var(savgn2); +} + +int main() { + ex1(); + ex4(ex3("data3")); + return 0; +} diff --git a/234/plots.gp b/234/plots.gp new file mode 100644 index 0000000..a357dca --- /dev/null +++ b/234/plots.gp @@ -0,0 +1,30 @@ +set term pngcairo size 1000, 800 +set grid + +f1(x) = a1*sqrt(b1*x) +f2(x) = a2/(x-b2)+c2 +f3(x) = a3*x+b3 +fit f1(x) 's(n).plot' using 1:2 via a1, b1 +fit f2(x) 'sn(n).plot' using 1:2 via a2, b2, c2 +fit f3(x) 's2(n).plot' using 1:2 via a3, b3 + +set output 's(n).png' +set title "График зависимости дисперсии, стандартного отклонения и относительной флуктуации от среднего" +set y2tics +set xlabel "n, среднее" +set ylabel "s, s/n" +set y2label "s^2" +set key top lef +set yrange[0:7] +set y2range[0:35] + + +plot 's(n).plot' with lines title "s(n)" lc rgb('red') lw 2, \ + 'sn(n).plot' with lines title "s/n(n)" lc rgb('blue') lw 2, \ + 's2(n).plot' with lines title "s^2(n)" axes x1y2 lc rgb('green') lw 2, \ + 's(n).plot' lc 0 pt 2 lw 2 notitle,\ + 'sn(n).plot' lc 0 pt 2 lw 2 notitle,\ + 's2(n).plot' lc 0 pt 2 lw 2 axes x1y2 notitle,\ + f1(x) lc 0 lw 1 dashtype(20,10) notitle,\ + f2(x) lc 0 lw 1 dashtype(20,10) notitle,\ + f3(x) axes x1y2 notitle lc 0 lw 1 dashtype(20,10) diff --git a/240/Makefile b/240/Makefile new file mode 100644 index 0000000..224506f --- /dev/null +++ b/240/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 $< &>/dev/null + +run_main: main + ./main + +main: main.cpp include/* + $(CXX) -o $@ $< $(CFLAGS) + +clean: + rm -fr main *.png *.plot diff --git a/240/README.md b/240/README.md new file mode 100644 index 0000000..96fd716 --- /dev/null +++ b/240/README.md @@ -0,0 +1,5 @@ +<!-- Шаблон для прака --> +<!-- файлы, заканчивающиеся на .plot считаются генерируемыми и удаляются через make clean --> +# Обработка <> прака + + diff --git a/240/compile_flags.txt b/240/compile_flags.txt new file mode 100644 index 0000000..34ae930 --- /dev/null +++ b/240/compile_flags.txt @@ -0,0 +1,4 @@ +-Iinclude +-std=c++2c +-mavx2 + diff --git a/240/data b/240/data new file mode 100644 index 0000000..3e38f45 --- /dev/null +++ b/240/data @@ -0,0 +1,11 @@ +t dp1 dp ln +4.14 9.31 1.88 ? +5 5.88 1.04 ? +6 6.66 1.19 ? +7.27 1.88 0.25 ? +8.07 6.07 0.88 ? +10 6.61 0.82 ? +15 7.10 0.56 ? +20 6.42 0.32 ? +31 7.59 0.13 ? + diff --git a/240/include b/240/include new file mode 120000 index 0000000..2225752 --- /dev/null +++ b/240/include @@ -0,0 +1 @@ +../libprakpp/include/
\ No newline at end of file diff --git a/240/main.cpp b/240/main.cpp new file mode 100644 index 0000000..52af396 --- /dev/null +++ b/240/main.cpp @@ -0,0 +1,28 @@ +#include <iostream> + +#include "include/praktable.hpp" +#include "include/prakphys.hpp" + +using table = prak::table<f64>; +using f64p = prak::pvalue<f64>; +using f64v = std::vector<f64>; +using vecarg = const std::vector<f64> &; +using argvec = const std::vector<f64> &; + +void ex1(std::string file) { + table t(file); + t.apply([](argvec a){ return std::log(a[0]/a[1]); }, std::vector<std::string>{"dp1", "dp"}, "ln"); + t.write_plot("mnk.plot", "t", "ln", std::nullopt); + auto [A, B] = t.least_squares_linear("t", "ln", std::nullopt, std::make_optional(0.1)); + f64p gamma = prak::function<f64>([](vecarg a) { return std::exp(a[0]) / (std::exp(a[0]) - 1); }, {B}); + f64p Cv = prak::R<f64> / (gamma - 1.0); + f64p i = 2.0 * Cv / prak::R<f64>, Cp = Cv + prak::R<f64>; + f64 m0 = 1.29 * 0.0127; + f64p alpha = m0 * Cp * A, tau = 1.0 / A; + std::cout << t var(A) var(B) var(gamma) var(Cv) var(i) var(m0) var(Cp) var(alpha) var(tau); +} + +int main() { + ex1("data"); + return 0; +} diff --git a/240/plots.gp b/240/plots.gp new file mode 100644 index 0000000..8c71dc0 --- /dev/null +++ b/240/plots.gp @@ -0,0 +1,16 @@ +set term pngcairo size 1000, 800 +set grid + +f1(x) = a1*x+b1 +fit f1(x) 'mnk.plot' using 1:2 via a1, b1 + +set output 'mnk.png' +set title "зависимтость от t" +set xlabel "t, c" +set ylabel "ln dp1/dp(t), ед." +set key top left + +set label sprintf("A = %.4g\n B = %.4g", a1, b1) at graph 0.2, 0.9 front boxed +plot 'mnk.plot' using 1:2 notitle lc 0 pt 1 lw 2, \ + f1(x) title "y(x)" lc rgb "red" + diff --git a/libprakpp/include/prakphys.hpp b/libprakpp/include/prakphys.hpp index 1eaef5a..1db7a94 100644 --- a/libprakpp/include/prakphys.hpp +++ b/libprakpp/include/prakphys.hpp @@ -19,7 +19,7 @@ TP hh = 1.054571817e-34; TP k = 1.380649e-23; TP G = 6.67430151515e-11; TP e = 1.602176634e-19; -TP m_e = 1.6021766342828e-31; +TP m_e = 9.109383713928e-31; TP m_p = 1.672621925955252e-27; TP m_n = 1.674927500568585e-27; TP R = 8.31446261815324; diff --git a/libprakpp/include/praktable.hpp b/libprakpp/include/praktable.hpp index 2cfa500..f00e7b9 100644 --- a/libprakpp/include/praktable.hpp +++ b/libprakpp/include/praktable.hpp @@ -472,7 +472,7 @@ public: // Fills a specified column with the same value `v` table &fill_column(const std::string &column, dtype v) { - apply([&v](const std::vector<dtype>& _) -> dtype { return v; }, {}, column); + apply([&v](const std::vector<dtype>& _) -> dtype { return v; }, std::vector<std::string>{}, column); return *this; } @@ -538,7 +538,7 @@ public: dtype avg = col_avg(column); for (auto it = begin(column); it != end(column); ++it) accum += (*it - avg)*(*it - avg); - return std::sqrt(accum); + return std::sqrt(accum / rows); } // takes columns [columns], calculates average and standard deviation for each row, puts them into `avg` and `stddev` and deleted original columns diff --git a/tempalte/main.cpp b/tempalte/main.cpp index 2786234..9980fb8 100644 --- a/tempalte/main.cpp +++ b/tempalte/main.cpp @@ -1,6 +1,7 @@ #include <iostream> #include "include/praktable.hpp" +#include "include/prakphys.hpp" using table = prak::table<f64>; using f64p = prak::pvalue<f64>; diff --git a/tempalte/plots.gp b/tempalte/plots.gp index 9c2994f..f197258 100644 --- a/tempalte/plots.gp +++ b/tempalte/plots.gp @@ -8,8 +8,9 @@ set output '' set title "" set xlabel "" set ylabel "" +set key top left -#set label sprintf("A = %.4g\n B = %.4g", a1, b1) at graph 0.1, 0.9 front boxed +#set label sprintf("A = %.4g\n B = %.4g", a1, b1) at graph 0.2, 0.9 front boxed #plot '.plot' using 1:2:3 with yerrorbars notitle lc 0 pt 1 lw 2, \ # f1(x) title "" lc rgb "red" |