0)
{
h = (double) (r+1) / (double) p;
for (i=0; iet[i];
ltau[i+hn] = rankcurve->et[i+mprio];
}
/* Set the remaining knots as indicated by del_array. */
for (indx=k, i=0; iet[i+k];
/* Compute an approximation on the new knot vector and store it
in hcurve.
sh1365() will allocate space for hcurve (with icopy==1), local_err
and l2_err.
Need local_err to store the error of the approximation until we know
that we have an approximation with error smaller than the tolerance,
then we can transfer the error to maxerr.
Must remember to free local_err and l2_err since there will be
a memory leak if they were allocated in the previous iteration. */
if (local_err != SISL_NULL) freearray(local_err);
if (l2_err != SISL_NULL) freearray(l2_err);
sh1365(oldcurve, ltau, k, hn, startfix, endfix,
&hcurve, &local_err, &l2_err, &lstat);
if (lstat < 0) goto err;
/* Check the error. big signifies that the error in one of the
components is larger than the tolerance. bigco signifies that
the error in one of the components is larger than the (usually
much smaller) tolerance epsco. */
big = 0;
bigco = 0;
for (i=0; i eps[i]);
bigco = bigco || (local_err[i] > epsco[i]);
}
/* The error is too large if it is big or if it is bigco and the
number of coefficients is smaller than nlim. The latter test is
important when the sum of the number of derivatives to be kept
fixed at the two ends is larger than k. */
big = big || (bigco && hn < nlim);
if (big)
{
/* If the error was too big, we just throw away hcurve and
indicate that an upper bound for the number of knots to
remove is antrem. */
if (hcurve != SISL_NULL) freeCurve(hcurve);
hcurve = SISL_NULL;
maxi = antrem;
}
else
{
/* If the error is acceptable we know that we can remove at least
antrem knots and store hcurve in newcurve. We also save the
error in maxerr. */
mini = antrem;
if (*newcurve != SISL_NULL) freeCurve(*newcurve);
*newcurve = hcurve;
hcurve = SISL_NULL;
for (i=0; i