#include #include "spline.h" extern "C" { double Compute (double); void plot (); }; static constexpr Pair measured [] = { { +133.9, 125.000 }, { +152.2, 120.000 }, { +198.3, 110.000 }, { +260.0, 100.000 }, { +343.6, 90.000 }, { +456.9, 80.000 }, { +609.9, 70.000 }, //{ +705.1, 65.000 }, { +814.5, 60.000 }, //{ +940.1, 55.000 }, { +1082.6, 50.000 }, //{ +1242.9, 45.000 }, { +1421.2, 40.000 }, //{ +1616.3, 35.000 }, //{ +1826.2, 30.000 }, { +2047.5, 25.000 }, //{ +2275.6, 20.000 }, //{ +2504.7, 15.000 }, { +2729.0, 10.000 }, //{ +2942.4, 5.000 }, { +3139.8, 0.000 }, //{ +3317.3, -5.000 }, { +3472.7, -10.000 }, //{ +3605.2, -15.000 }, { +3715.6, -20.000 }, //{ +3805.4, -25.000 }, { +3876.9, -30.000 }, { +3960.2, -38.000 }, { +3976.0, -40.000 }, }; static const SPLINE spline (measured, false); double Compute (double x) { try { const real r = spline.interpolate (to_real(x, 16)); return from_real(r); } catch (const char * e) { fprintf(stderr, "%s at x = %f\n", e, x); }; return 0; } void plot () { printf("Cubic Spline Coefficients - počet bodů : %zd\n", array_size (measured) - 1ul); for (auto & e: spline) { printf ("%12g: a = %+13g, b = %+13g, c = %+13g, d = %+13g\n", +e.x, +e.a, +e.b, +e.c, +e.d); } printf("half ~ %f\n", Compute(2047.45)); }