#
# curv1
#
@PROBLEM curv1
@FUNCTION curv1
@LIB $(NETSOLVE_ROOT)/lib/$(NETSOLVE_ARCH)/fitpack_$(NETSOLVE_ARCH).a
@LANGUAGE FORTRAN
@MAJOR COL
@PATH  /FitPack/
@DESCRIPTION
subroutine determines the parameters necessary to
compute an interpolatory spline under tension through
a sequence of functional values. the slopes at the two
ends of the curve may be specified or omitted.  for actual
computation of points on the curve it is necessary to call
the function curv2.
http://www.netlib.org/fitpack/index.html
@INPUT 6
@OBJECT VECTOR S x
x is an array of the n increasing abscissae of the
functional values.
@OBJECT VECTOR S y
y is an array of the n ordinates of the values, (i. e.
y(k) is the functional value corresponding to x(k) ).
@OBJECT SCALAR S slp1
slp1 contains the desired value for the first
derivative of the curve at x(1).
the user may omit values for this
parameter and signal this with islpsw.
@OBJECT SCALAR S slpn
slpn contains the desired value for the first
derivative of the curve at x(n), respectively.
the user may omit values for this
parameter and signal this with islpsw.
@OBJECT SCALAR I islpsw
islpsw contains a switch indicating which slope data
should be used and which should be estimated by this
subroutine,
       = 0 if slp1 and slpn are to be used,
       = 1 if slp1 is to be used but not slpn,
       = 2 if slpn is to be used but not slp1,
       = 3 if both slp1 and slpn are to be estimated
           internally.
@OBJECT SCALAR S sigma
sigma contains the tension factor. this value indicates
the curviness desired. if abs(sigma) is nearly zero
(e.g. .001) the resulting curve is approximately a
cubic spline. if abs(sigma) is large (e.g. 50.) the
resulting curve is nearly a polygonal line. if sigma
equals zero a cubic spline results.  a standard value
for sigma is approximately 1. in absolute value.
@OUTPUT 2
@OBJECT VECTOR S yp
yp contains the values of the second derivative of the
curve at the given nodes.

@OBJECT SCALAR I ierr
ierr contains an error flag,
     = 0 for normal return,
     = 1 if n is less than 2,
     = 2 if x-values are not strictly increasing.


@COMPLEXITY 1,3

@CALLINGSEQUENCE
@ARG mI0,mI1
@ARG I0
@ARG I1
@ARG I2
@ARG I3
@ARG I4
@ARG O0
@ARG ?
@ARG I5
@ARG O1

@CODE
extern void curv1(int*,float*,float*,float*,float*,int*,float*,float*,float*,int*);

float *work = NULL;
int lwork;

if (*@mI0@ != *@mI1@)
  return NS_PROT_DIM_MISMATCH;

lwork = *@mI0@;
work = (float *)malloc(sizeof(float)*lwork);

@O1@ = (int *)malloc(sizeof(int));
@O0@ = (float *)malloc(sizeof(float)*(*@mI0@));
*@mO0@ = *@mI0@;

curv1(@mI0@,@I0@,@I1@,@I2@,@I3@,@I4@,@O0@,work,@I5@,@O1@);

@END_CODE
