admb-project / admb

AD Model Builder
http://admb-project.org
Other
64 stars 19 forks source link

Natural cubic spline option of spline in linad99/vspline.cpp #180

Closed yukio-takeuchi closed 3 years ago

yukio-takeuchi commented 3 years ago

Although it is not advertised well spline function implemented in ADMB in linad99/vvspline.cpp allows users to model natural cubic spline (2nd derivative of boundary nodes is set to zero) as an alternative of use of 1st derivative of boundary nodes. This can be accomplished by setting yp1 and ypn of function spline to >0.99e30.

/** \ingroup cub_spline
 *  Cubic spline interpolation.
 *
 * \param _x array of abscissa
 * \param _y array of corresponding values \f$y_i=f(x_i)\f$
 * \param yp1 value of the first derivative of \f$f\f$ at the left
 *        end point
 * \param ypn value of the first derivative of \f$f\f$ at the right
 *        end point
 * \return an array containing the second derivatives
*/
dvar_vector spline(const dvector &_x,const dvar_vector&_y,dvariable yp1,
    dvariable ypn)

It may be worthwhile if this information is included somewhere in documentation.

johnoel commented 3 years ago

Is this okay?

/** \ingroup cub_spline
 * Cubic spline interpolation allows users to model natural cubic spline (2nd derivative of boundary nodes is set to zero) as 
 * an alternative of use of 1st derivative of boundary nodes. This can be accomplished by setting yp1 and ypn of function 
 * spline to >0.99e30.
...
yukio-takeuchi commented 3 years ago

I can go with you. Thank you for your quick work.

johnoel commented 3 years ago

Done in revision fe10b9d.