%% options copyright owner = Dirk Krause copyright year = 2014 license = bsd %% header #ifdef __cplusplus extern "C" { #endif /** Get left point first derivative value for parabola through x=-1, x=0, and x=1. @param yneg Y value for x=-1. @param y0 Y value for x=0. @param ypos Y value for x=1. @param ec Pointer to error code variable, may be NULL. @return Result. */ double f2lpara_derived_left(double yneg, double y0, double ypos, int *ec); /** Get center point first derivative value for parabola through x=-1, x=0, and x=1. @param yneg Y value for x=-1. @param y0 Y value for x=0. @param ypos Y value for x=1. @param ec Pointer to error code variable, may be NULL. @return Result. */ double f2lpara_derived_center(double yneg, double y0, double ypos, int *ec); /** Get right point first derivative value for parabola through x=-1, x=0, and x=1. @param yneg Y value for x=-1. @param y0 Y value for x=0. @param ypos Y value for x=1. @param ec Pointer to error code variable, may be NULL. @return Result. */ double f2lpara_derived_right(double yneg, double y0, double ypos, int *ec); #ifdef __cplusplus } #endif %% module #include "dk3ma.h" #include "f2lpara.h" double f2lpara_derived_left(double yneg, double y0, double ypos, int *ec) { double back = 0.0; int myec = 0; /* back = 2 * y0 - 0.5 * ypos - 1.5 * yneg */ back = dk3ma_d_sub_ok( dk3ma_d_mul_ok(2.0, y0, &myec), dk3ma_d_add_ok( (0.5 * ypos), dk3ma_d_mul_ok(1.5, yneg, &myec), &myec ), &myec ); if (myec) { if (ec) { *ec = myec; } } return back; } double f2lpara_derived_center(double yneg, double y0, double ypos, int *ec) { double back = 0.0; int myec = 0; /* back = 0.5 * (ypos - yneg) */ back = 0.5 * dk3ma_d_sub_ok(ypos, yneg, &myec); if (myec) { if (ec) { *ec = myec; } } return back; } double f2lpara_derived_right(double yneg, double y0, double ypos, int *ec) { double back = 0.0; int myec = 0; /* back = 1.5 * ypos + 0.5 * yneg - 2 * y0 */ back = dk3ma_d_sub_ok( dk3ma_d_add_ok( dk3ma_d_mul_ok(1.5, ypos, &myec), (0.5 * yneg), &myec ), dk3ma_d_mul_ok(2.0, y0, &myec), &myec ); if (myec) { if (ec) { *ec = myec; } } return back; }