Algorithm 525: ADAPT, Adaptive Smooth Curve Fitting [E2]