add py module

This commit is contained in:
2026-05-19 14:17:14 +02:00
parent 16334e4834
commit 8b62881ae8
10 changed files with 114295 additions and 29 deletions
+15 -5
View File
@@ -1,7 +1,7 @@
#pragma once
#include <cmath>
#include <autoopt/derivative.hpp>
#include <cmath>
namespace autoopt {
@@ -34,6 +34,14 @@ struct quadric {
return quadric(A_new, B_new, C_new, D_new, E_new, F_new);
}
constexpr quadric translated_by(T x_o, T y_o) const {
T D_new = _D - T{2} * _A * x_o - _B * y_o;
T E_new = _E - _B * x_o - T{2} * _C * y_o;
T F_new = _F + _A * x_o * x_o + _B * x_o * y_o + _C * y_o * y_o - _D * x_o -
_E * y_o;
return quadric(_A, _B, _C, D_new, E_new, F_new);
}
constexpr T at(T x) const {
T sign = T{-1};
T Bx_E = _B * x + _E;
@@ -50,10 +58,12 @@ struct quadric {
}
constexpr T slope_at(T x) const {
return derivative([&]<typename U>(U x_val) {
quadric<U> q{U{_A}, U{_B}, U{_C}, U{_D}, U{_E}, U{_F}};
return q.at(x_val);
}, x);
return derivative(
[&]<typename U>(U x_val) {
quadric<U> q{U{_A}, U{_B}, U{_C}, U{_D}, U{_E}, U{_F}};
return q.at(x_val);
},
x);
}
};