aboutsummaryrefslogtreecommitdiffstats
path: root/libprakpp/include/prakmath.hpp
diff options
context:
space:
mode:
authorjustanothercatgirl <sotov@twistea.su>2024-12-02 20:44:44 +0300
committerjustanothercatgirl <sotov@twistea.su>2024-12-02 20:44:44 +0300
commit35f687f6a4e306585a263b2611f9a5c8b3c2a3a8 (patch)
treebdcd162a5c8b6341638974b00287a425d905fcbc /libprakpp/include/prakmath.hpp
parent3fd86ca01c1d2b0e6e8ffe46de12d6e68054a217 (diff)
finished 110
Diffstat (limited to 'libprakpp/include/prakmath.hpp')
-rw-r--r--libprakpp/include/prakmath.hpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/libprakpp/include/prakmath.hpp b/libprakpp/include/prakmath.hpp
index f8024c9..54b902d 100644
--- a/libprakpp/include/prakmath.hpp
+++ b/libprakpp/include/prakmath.hpp
@@ -235,6 +235,18 @@ T sigma(function_t<T> f, const std::vector<T> &args, const std::vector<T> &sigma
return std::sqrt(sum);
}
+template <std::floating_point T>
+pvalue<T> function(function_t<T> func, const std::vector<pvalue<T>> &args) {
+ std::vector<T> _args(args.size()),
+ _sgms(args.size());
+ for (size_t i = 0; const auto & [val, err] : args) {
+ _args[i] = val;
+ _sgms[i++] = err;
+ }
+ pvalue<T> ret = {func(_args), sigma(func, _args, _sgms)};
+ return ret;
+}
+
/// calculate least-squares linear approximation to fit data
/// ax+b = y (ss is an error of Y value)
template <std::floating_point T>