aboutsummaryrefslogtreecommitdiff
path: root/math/curfit/doc
diff options
context:
space:
mode:
Diffstat (limited to 'math/curfit/doc')
-rw-r--r--math/curfit/doc/curfit.hd24
-rw-r--r--math/curfit/doc/curfit.hlp163
-rw-r--r--math/curfit/doc/curfit.men20
-rw-r--r--math/curfit/doc/curfit.spc479
-rw-r--r--math/curfit/doc/cvaccum.hlp51
-rw-r--r--math/curfit/doc/cvacpts.hlp54
-rw-r--r--math/curfit/doc/cvcoeff.hlp36
-rw-r--r--math/curfit/doc/cvepower.hlp55
-rw-r--r--math/curfit/doc/cverrors.hlp53
-rw-r--r--math/curfit/doc/cveval.hlp33
-rw-r--r--math/curfit/doc/cvfit.hlp62
-rw-r--r--math/curfit/doc/cvfree.hlp26
-rw-r--r--math/curfit/doc/cvinit.hlp55
-rw-r--r--math/curfit/doc/cvpower.hlp40
-rw-r--r--math/curfit/doc/cvrefit.hlp52
-rw-r--r--math/curfit/doc/cvreject.hlp41
-rw-r--r--math/curfit/doc/cvrestore.hlp32
-rw-r--r--math/curfit/doc/cvsave.hlp35
-rw-r--r--math/curfit/doc/cvset.hlp56
-rw-r--r--math/curfit/doc/cvsolve.hlp39
-rw-r--r--math/curfit/doc/cvstati.hlp47
-rw-r--r--math/curfit/doc/cvstatr.hlp44
-rw-r--r--math/curfit/doc/cvvector.hlp41
-rw-r--r--math/curfit/doc/cvzero.hlp26
24 files changed, 1564 insertions, 0 deletions
diff --git a/math/curfit/doc/curfit.hd b/math/curfit/doc/curfit.hd
new file mode 100644
index 00000000..b8a00640
--- /dev/null
+++ b/math/curfit/doc/curfit.hd
@@ -0,0 +1,24 @@
+# Help directory for the CURFIT (curve fitting) package.
+
+$curfit = "math$curfit/"
+
+cvaccum hlp = cvaccum.hlp, src = curfit$cvaccum.gx
+cvacpts hlp = cvacpts.hlp, src = curfit$cvacpts.gx
+cvcoeff hlp = cvcoeff.hlp, src = curfit$cvcoeff.gx
+cvepower hlp = cvepower.hlp, src = curfit$cvepower.gx
+cverrors hlp = cverrors.hlp, src = curfit$cverrors.gx
+cveval hlp = cveval.hlp, src = curfit$cveval.gx
+cvinit hlp = cvinit.hlp, src = curfit$cvinit.gx
+cvfit hlp = cvfit.hlp, src = curfit$cvfit.gx
+cvfree hlp = cvfree.hlp, src = curfit$cvfree.gx
+cvpower hlp = cvpower.hlp, src = curfit$cvpower.gx
+cvrefit hlp = cvrefit.hlp, src = curfit$cvrefit.gx
+cvreject hlp = cvreject.hlp, src = curfit$cvreject.gx
+cvrestore hlp = cvrestore.hlp, src = curfit$cvrestore.gx
+cvsave hlp = cvsave.hlp, src = curfit$cvsave.gx
+cvsolve hlp = cvsolve.hlp, src = curfit$cvsolve.gx
+cvstati hlp = cvstati.hlp, src = curfit$cvstat.gx
+cvstatr hlp = cvstatr.hlp, src = curfit$cvstat.gx
+cvvector hlp = cvvector.hlp, src = curfit$cvvector.gx
+cvzero hlp = cvzero.hlp, src = curfit$cvzero.gx
+cvset hlp = cvset.hlp, src = curfit$cvset.gx
diff --git a/math/curfit/doc/curfit.hlp b/math/curfit/doc/curfit.hlp
new file mode 100644
index 00000000..35950c08
--- /dev/null
+++ b/math/curfit/doc/curfit.hlp
@@ -0,0 +1,163 @@
+.help curfit Jul84 "Math Package"
+.ih
+NAME
+curfit -- curve fitting package
+.ih
+SYNOPSIS
+
+.nf
+ cvinit (cv, curve_type, order, xmin, xmax)
+ cvzero (cv)
+ cvaccum (cv, x, y, weight, wtflag)
+ cvreject (cv, x, y, weight)
+ cvsolve (cv, ier)
+ cvfit (cv, x, y, weight, npts, wtflag, ier)
+ cvrefit (cv, x, y, weight, ier)
+ y = cveval (cv, x)
+ cvvector (cv, x, yfit, npts)
+ cvcoeff (cv, coeff, ncoeff)
+ cverrors (cv, y, weight, yfit, rms, errors)
+ cvsave (cv, fit)
+ cvstati (cv, parameter, ival)
+ cvstatr (cv, parameter, ival)
+ cvrestore (cv, fit)
+ cvset (cv, curve_type, xmin, xmax, coeff, ncoeff)
+ cvfree (cv)
+.fi
+.ih
+DESCRIPTION
+The curfit package provides a set of routines for fitting data to functions
+linear in their coefficients using least squares techniques. The numerical
+technique employed is the solution of the normal equations by the
+Cholesky method.
+.ih
+NOTES
+The fitting function curve_type is chosen at run time from the following
+list.
+
+.nf
+ LEGENDRE # Legendre polynomials
+ CHEBYSHEV # Chebyshev polynomials
+ SPLINE3 # cubic spline with uniformly spaced break points
+ SPLINE1 # linear spline with uniformly spaced break points
+.fi
+
+
+The CURFIT package performs a weighted fit.
+The weighting options are WTS_USR, WTS_UNIFORM and WTS_SPACING.
+The user must supply a weight array. In WTS_UNIFORM mode the curfit
+routines set the weights to 1. In WTS_USER mode the user must supply an
+array of weight values.
+In WTS_SPACING mode
+the weights are set to the difference between adjacent data points.
+The data must be sorted in x in order to use the WTS_SPACING mode.
+In WTS_UNIFORM mode the reduced chi-squared returned by CVERRORS
+is the variance of the fit and the errors in the coefficients are scaled
+by the square root of this variance. Otherwise the weights are
+interpreted as one over the variance of the data and the true reduced
+chi-squared is returned.
+
+The routines assume that all the x values of interest lie in the region
+xmin <= x <= xmax. Checking for out of bounds x values is the responsibility
+of the calling program. The package routines assume that INDEF values
+have been removed from the data set prior to entering the package
+routines.
+
+In order to make the package definitions available to the calling program
+an include <curfit.h> statement must be included in the user program.
+CVINIT must be called before each fit. CVFREE frees space used by the
+CURFIT package.
+.ih
+EXAMPLES
+.nf
+Example 1: Fit curve to data, unifrom weighting
+
+ include <math/curfit.h>
+
+ ...
+
+ call cvinit (cv, CHEBYSHEV, 4, 1., 512.)
+
+ call cvfit (cv, x, y, weight, 512, WTS_UNIFORM, ier)
+ if (ier != OK)
+ call error (...)
+
+ do i = 1, 512 {
+ x = i
+ call printf ("%g %g\n")
+ call pargr (x)
+ call pargr (cveval (cv, x))
+ }
+
+ call cvfree (cv)
+
+
+Example 2: Fit curve using accumulate mode, weight based on spacing
+
+ include <math/curfit.h>
+
+ ...
+
+ old_x = x
+ do i = 1, 512 {
+ x = real (i)
+ if (y[i] != INDEF) {
+ call cvaccum (cv, x, y, weight, x - old_x, WTS_USER)
+ old_x = x
+ }
+ }
+
+ call cvsolve (cv, ier)
+ if (ier != OK)
+ call error (...)
+
+ ...
+
+ call cvfree (cv)
+
+
+Example 3: Fit and subtract smooth curve from image lines
+
+ include <math/curfit.h>
+
+ ...
+
+ call cvinit (cv, CHEBYSHEV, order, 1., 512.)
+
+ do line = 1, nlines {
+ inpix = imgl2r (im, line)
+ outpix = impl2r (im, line)
+ if (line == 1)
+ call cvfit (cv, x, Memr[inpix], weight, 512, WTS_UNIFORM, ier)
+ else
+ call cvrefit (cv, x, Memr[inpix], weight, ier)
+ if (ier != OK)
+ ...
+ call cvvector (cv, x, y, 512)
+ call asubr (Memr[inpix], y, Memr[outpix], 512)
+ }
+
+ call cvfree (cv)
+
+
+Example 4: Fit curve, save fit for later use by CVEVAL. LEN_FIT must be a least
+ order + 7 elements long.
+
+ include <math/curfit.h>
+
+ real fit[LEN_FIT]
+
+ ...
+ call cvinit (cv, CHEBYSHEV, order, xmin, xmax)
+ call cvfit (cv, x, y, w, npts, WTS_UNIFORM, ier)
+ if (ier != OK)
+ ...
+ call cvsave (cv, fit)
+ call cvfree (cv)
+ ...
+ call cvrestore (cv, fit)
+ do i = 1, npts
+ yfit[i] = cveval (cv, x[i])
+ call cvfree (cv)
+ ...
+.fi
diff --git a/math/curfit/doc/curfit.men b/math/curfit/doc/curfit.men
new file mode 100644
index 00000000..b061badc
--- /dev/null
+++ b/math/curfit/doc/curfit.men
@@ -0,0 +1,20 @@
+ cvaccum - Accumulate point into data set
+ cvacpts - Accumulate points into a data set
+ cvcoeff - Get coefficients
+ cvepower - Convert errors to power series equivalents
+ cverrors - Calculate chi-squared and errors in coefficients
+ cveval - Evaluate curve at x
+ cvfit - Fit curve
+ cvfree - Free space allocated by cvinit
+ cvinit - Make ready to fit a curve; set up parameters of fit
+ cvpower - Convert coefficients to power series coefficients
+ cvrefit - Refit curve, same x and weight, different y
+ cvreject - Reject point from data set
+ cvrestore - Restore curve parameters and coefficients
+ cvsave - Save curve parameters and coefficients
+ cvset - Input coefficients derived external to the CURFIT package
+ cvsolve - Solve matrix for coefficients
+ cvstati - Get integer parameter
+ cvstatr - Get real parameter
+ cvvector - Evaluate curve at an array of x
+ cvzero - Zero arrays for new fit
diff --git a/math/curfit/doc/curfit.spc b/math/curfit/doc/curfit.spc
new file mode 100644
index 00000000..f5e555a3
--- /dev/null
+++ b/math/curfit/doc/curfit.spc
@@ -0,0 +1,479 @@
+.help curfit May84 "Math Package"
+.ce
+Specifications for the Curfit Package
+.ce
+Lindsey Davis
+.ce
+July 1984
+
+.sh
+1. Introduction
+
+The CURFIT package provides a set of routines for fitting data to
+functions linear in their coefficients using least
+squares techniques. The basic numerical technique employed
+is the solution of the normal equations by the Cholesky method.
+This document presents the formal requirements for the package
+and describes the algorithms used.
+
+.sh
+2. Requirements
+
+.ls 4
+.ls (1)
+The package shall take as input a set of x and y values and their
+corresponding weights. The package routines asssume that data values
+equal to INDEF have been rejected from the data set or replaced with
+appropriate interpolated values prior to entering the package
+routines. The input data may be arbitrarily spaced in x. No assumptions
+are made about the ordering of the x values, but see (3) below.
+.le
+.ls (2)
+The package shall perform the following operations:
+.ls o
+Determine the coefficients of the fitting function by solving the normal
+equations. The fitting function is selected at run time from the following
+list: (1) LEGENDRE, Legendre polynomials, (2) CHEBYSHEV,
+Chebyshev polynomials, (3) SPLINE3, Cubic spline
+with uniformly spaced break points, SPLINE1, Linear spline with evenly
+spaced break points. The calling sequence must be
+invariant to the form of the fitting function.
+.le
+.ls o
+Set an error code if the numerical routines are unable to fit the
+specified function.
+.le
+.ls o
+Output the values of the coefficients.
+The coefficients are stored internal to the CURFIT package.
+However in some applications it is the coefficients which are of primary
+interest. A package routine shall exist to extract the
+the coefficients from the curve descriptor structure.
+.le
+.ls o
+Evaluate the fitting function at arbitrary value(s) of x. The evaluating
+routines shall use the coefficients calculated and
+the user supplied x value(s).
+.le
+.ls o
+Calculate the standard deviation of the coefficients and the standard deviation
+of the fit.
+.le
+.le
+.ls (3)
+The program shall perform a weighted fit using a user supplied weight
+array and weight flag. The weighting options are WTS_USER, WTS_UNIFORM and
+WTS_SPACING. In WTS_USER mode the package routines apply user supplied
+weights to the individual data points, otherwise the package routines
+calculate the weights. In WTS_SPACING mode the program assumes that the data
+are sorted in x, and sets the individual weights to the difference between
+adjacent x values. In WTS_UNIFORM mode the weights are set to 1.
+.le
+.ls (4)
+The input data set and output coefficent, error, and fitted y arrays are single
+precision real quantities. All package arithmetic shall be done in single
+precision. The package shall however be designed with
+conversion to double precision arithmetic in mind.
+.le
+.le
+
+.sh
+3. Specifications
+
+.sh
+3.1. List of Routines
+
+The package prefix will be cv for curve fit.
+The following procedures shall be part of the package.
+Detailed documentation for each procedure can be found by invoking
+the help facility.
+
+.nf
+ cvinit (cv, curvetype, order, xmin, xmax)
+ cvzero (cv)
+ cvaccum (cv, x, y, w, wtflag)
+ cvreject (cv, x, y, w)
+ cvsolve (cv, ier)
+ cvfit (cv, x, y, w, npts, wtflag, ier)
+ cvrefit (cv, x, y, w, ier)
+ y = cveval (cv, x)
+ cvvector (cv, x, yfit, npts)
+ cvcoeff (cv, coeff, ncoeff)
+ cverrors (cv, y, w, yfit, rms, errors)
+ cvsave (cv, fit)
+ cvrestore (cv, fit)
+ cvset (cv, curve_type, xmin, xmax, coeff, ncoeff)
+ cvfree (cv)
+.fi
+
+.sh
+3.2. Algorithms
+
+.sh
+3.2.1. Polynomial Basis Functions
+
+The approximating function is assumed to be of the form
+
+.nf
+ f(x) = a(1)*F(1,x) + a(2)*F(2,x) + ... + a(ncoeff)*F(ncoeff,x)
+.fi
+
+where the F(n,x) are polynomial basis functions containing terms
+of order x**(n-1), and the a(n) are the coefficients.
+In order to avoid a very ill-conditioned linear system for moderate or large n
+the Legendre and Chebyshev polynomials were chosen for the basis functions.
+The Chebyshev and Legendre polynomials are
+orthogonal over -1. <= x <= 1. The data x values are normalized to
+this regime using minimum and maximum x values supplied by the user.
+For each data point the ncoeff basis functions are calculated using the
+following recursion relations.
+
+.nf
+ Legendre series
+ F(1,x) = 1.
+ F(2,x) = x
+ F(n,x) = [(2*n-3)*x*F(n-1,x)-(n-2)*F(n-2,x)]/(n-1)
+
+ Chebyshev series
+ F(1,x) = 1.
+ F(2,x) = x
+ F(n,x) = 2*x*F(n-1,x)-F(n-2,x)
+.fi
+
+.sh
+3.2.2. Cubic Cardinal B-Spline
+
+The approximating function is assumed to be of the form
+
+.nf
+ f(x) = a(1)*F(1,x) + a(2)*F(2,x) + ... a(ncoeff)*F(ncoeff,x)
+.fi
+
+where the basis functions, F(n, x), are the cubic cardinal B-splines
+(Prenter 1975).
+The user supplies minimum and maximum x values and the number of polynomial
+pieces, npieces, to be fit to the data set. The number of cubic spline
+coefficents, ncoeff, will be
+
+.nf
+ ncoeff = npieces + 3
+.fi
+
+The cardinal B-spline is stored in a lookup table. For each x the appropriate
+break point is selected and the four non-zero B-splines are calculated by
+nearest neighbour interpolation in the lookup table.
+
+.sh
+3.2.3. The Normal Equations
+
+The coefficients, a, are determined by the solution of the normal equations
+
+.nf
+ c * a = b
+.fi
+
+where
+
+.nf
+ c[i,j] = (F(i,x), F(j,x))
+ b[j] = (F(j,x), f(x))
+.fi
+
+F(i,x) is the ith basis function at x, f(x) is the function to be
+approximated and the inner product of two functions G and H, (G,H),
+is given by
+
+.nf
+ (G, H) = sum (G(x[i]) * H(x[i]) * weight[i]) i=1,...npts
+.fi
+
+The resulting matrix is symmetric and positive semi-definite.
+Therefore it is necessary to store the ncoeff bands at or below the
+diagonal. Storage is particularly efficient for the cubic spline
+as only the diagonal and three adjacent lower bands are non-zero
+(deBoor 1978).
+
+.sh
+3.2.4. Method of Solution
+
+Since the matrix is symmetric, positive semi-definite and banded
+it may be solved by the Cholesky method. The data matrix c may be
+written as
+
+.nf
+ c = l * d * l-transpose
+.fi
+
+where l is a unit lower triangular matrix and d is the diagonal of c
+(deBoor 1978). Near zero pivots are handled in the following way.
+At the nth elimination step the current value of the nth diagonal
+element is compared with the original nth diagonal element. If the diagonal
+element has been reduced by one computer word length, the entire nth
+row is declared linearly dependent on the previous n-1 rows and
+a(n) = 0.
+
+The triangular system
+
+.nf
+ l * w = b
+.fi
+
+is solved for w (forward substitution), the vector d ** (-1) * w
+is computed and the triangular system
+
+.nf
+ l-transpose * a = d ** (-1) * w
+.fi
+
+solved for the coefficients, a (backward substitution).
+
+.sh
+3.2.5. Errors
+
+The reduced ch-squared of the fit is defined as the weighted sum of
+the squares of the residuals divided by the number of degrees of
+freedom.
+
+.nf
+ rms = sqrt (sum (weight * (y - yfit) ** 2) / nfree)
+ nfree = npts - ncoeff
+.fi
+
+The error of the j-th coefficient, error[j], is equal to the square root
+of the j-th diagonal element of inverse data matrix times a scale factor.
+
+.nf
+ error[j] = sqrt (c[j,j]-inverse) * scale
+.fi
+
+The scale factor is the square root of the variance of the data when
+all the weights are equal, otherwise scale is one.
+
+.sh
+4. Usage
+
+.sh
+4.1. User Notes
+
+The following series of steps illustrates the use of the package.
+
+.ls 4
+.ls (1)
+Insert an include <curfit.h> statement in the calling program to
+make the CURFIT package definitions available to the user program.
+.le
+.ls (2)
+Call CVINIT to initialize the curve fitting parameters.
+.le
+.ls (3)
+Call CVACCUM to select a weighting function
+and accumulate data points into the appropriate arrays and vectors.
+.le
+.ls (4)
+Call CVSOLVE to solve the normal equations and calculate the coefficients
+of the fitting function. Test for an error condition.
+.le
+.ls (5)
+Call CVEVAL or CVVECTOR to evaluated the fitted function at the
+x value(s) of interest.
+.le
+.ls (6)
+Call CVCOEFF to fetch the number and value of the coefficients of the fitting
+function.
+.le
+.ls (7)
+Call CVERRORS to calculate the standard deviations in the
+coefficients and the standard deviation of the fit.
+.le
+.ls (8)
+Call CVFREE to release the space allocated for the fit.
+.le
+.le
+
+Steps (2) and (3) may be combined in a single step by calling CVFIT
+and inputting an array of x, y and weight values. Individual points may
+be rejected from the fit by calling CVREJECT and CVSOLVE to determine
+a new set of coefficients. If the x and weight values remain the same
+and only the y values change from fit to fit, CVREFIT can be called.
+
+
+.sh
+4.2. Examples
+
+.nf
+Example 1: Fit curve to data, no weighting
+
+ include <curfit.h>
+ ...
+ call cvinit (cv, CHEBYSHEV, 4, 1., 512.)
+
+ call cvfit (cv, x, y, w, 512, WTS_UNIFORM, ier)
+ if (ier != OK)
+ call error (...)
+
+ do i = 1, 512 {
+ x = i
+ call printf ("%g %g\n")
+ call pargr (x)
+ call pargr (cveval (cv, x))
+ }
+
+ call cvfree (cv)
+
+Example 2: Fit curve using accumulate mode, weight based on spacing
+
+ include <curfit.h>
+ ...
+ call cvinit (cv, SPLINE3, npolypieces, 1., 512.)
+
+ old_x = 0.0
+ do i =1, 512 {
+ x = real (i)
+ if (y[i] != INDEF) {
+ call cvaccum (cv, x, y, x - old_x, WTS_USER)
+ old_x = x
+ }
+ }
+
+ call cvsolve (cv, ier)
+ if (ier != OK)
+ call error (...)
+ ...
+ call cvfree (cv)
+
+Example 3: Fit and subtract smooth curve from image lines
+
+ include <curfit.h>
+ ...
+ call cvinit (cv, CHEBYSHEV, order, 1., 512.)
+
+ do line = 1, nlines {
+ inpix = imgl2r (im, line)
+ outpix = impl2r (im, line)
+ if (line == 1)
+ call cvfit (cv, x, Memr[inpix], w, 512, WTS_USER, ier)
+ else
+ call cvrefit (cv, x, Memr[inpix], w, WTS_USER, ier)
+ if (ier != OK)
+ ...
+ call cvvector (cv, x, y, 512)
+ call asubr (Memr[inpix], y, Memr[outpix], 512)
+ }
+
+ call cvfree (cv)
+
+Example 4: Fit curve and save parameters for later use by CVEVAL
+ Fit must be at least order + 7 elements long.
+
+ include <curfit.h>
+
+ real fit[LEN_FIT)
+ ...
+ call cvinit (cv, LEGENDRE, order, xmin, xmax)
+ call cvfit (cv, x, y, w, npts, WTS_UNIFORM, ier)
+ if (ier != OK)
+ ...
+ call cvsave (cv, fit)
+ call cvfree (cv)
+ ...
+ call cvrestore (cv, fit)
+ do i = 1, npts
+ yfit[i] = cveval (cv, x[i])
+ call cvfree (cv)
+ ...
+
+.fi
+
+.sh
+5. Detailed Design
+
+.sh
+5.1. Curve Descriptor Structure
+
+The CURFIT parameters, and the
+size and location of the arrays and vectors used in the fitting procedure
+are stored in the curve descriptor structure. The structure is referenced
+by the pointer cv returned by the CVINIT routine. The curve
+descriptor structure is defined in the package
+header file curfit.h. The structure is listed below.
+
+.nf
+define LEN_CVSTRUCT 17
+
+# CURFIT parameters
+
+define CV_TYPE Memi[$1] # Type of curve to be fitted
+define CV_ORDER Memi[$1+1] # Order of the fit
+define CV_NPIECES Memi[$1+2] # Number of polynomial pieces (spline)
+define CV_NCOEFF Memi[$1+3] # Number of coefficients
+define CV_XMAX Memr[$1+4] # Maximum x value
+define CV_XMIN Memr[$1+5] # Minimum x value
+define CV_RANGE Memr[$1+6] # Xmax minus xmin
+define CV_MAXMIN Memr[$1+7] # Xmax plus xmin
+define CV_SPACING Memr[$1+8] # Break point spacing (spline)
+define CV_NPTS Memi[$1+9] # Number of data points
+
+# Pointers to storage arrays and vectors
+
+define CV_XBASIS Memi[$1+10] # Basis functions single x
+define CV_MATRIX Memi[$1+11] # Pointer to matrix
+define CV_CHOFAC Memi[$1+12] # Pointer to Cholesky factorization
+define CV_VECTOR Memi[$1+13] # Pointer to vector
+define CV_COEFF Memi[$1+14] # Pointer to coefficient vector
+
+# Used only by CVREFIT
+
+define CV_BASIS Memi[$1+15] # Pointer to basis functions all x
+define CV_LEFT Memi[$1+16] # Pointer to index array (spline)
+.fi
+
+.sh
+5.2. Storage Requirements
+
+The storage requirements are listed below.
+
+.ls 4
+.ls real MATRIX[order,ncoeff]
+The real array, matrix, stores the original accumulated data. Storage of this
+array is required by the CURFIT routines CVACCUM and CVREJECT which accumulate
+and reject individual points from the data set respectively. If the fitting
+function is SPLINE3 then order = 4, otherwise order = ncoeff.
+.le
+.ls real CHOFAC[order, ncoeff]
+The real array chofac stores the Cholesky factorization of matrix.
+Storage of CHOFAC is required by the CURFIT routines CVERRORS and
+CVREFIT.
+.le
+.ls real VECTOR[ncoeff]
+Ncoeff real storage units must be allocated for the vector containing
+the right side of the matrix equation. VECTOR is stored for use by the
+CVREJECT and CVACCUM routines. Vector is zeroed before every CVREFIT call.
+.le
+.ls real COEFF[ncoeff]
+The coefficients of the fitted function must be stored for use by
+the CVEVAL, CVVECTOR, and CVCOEFF routines.
+.le
+.ls real BASIS[order,npts]
+Space is allocated for the basis functions only if the routine CVREFIT is
+called. The first call to CVREFIT generates an array of basis functions and
+subsequent calls reference the array.
+.le
+.ls int LEFT[npts]
+Space for the array left is allocated only if
+CVREFIT is called. The array indicates to which element of
+the matrix a given spline function should be accumulated.
+.le
+.le
+
+.sh
+6. References
+
+.ls (1)
+Carl de Boor, "A Practical Guide to Splines", 1978, Springer-Verlag New
+York Inc.
+.le
+.ls (2)
+P.M. Prenter, "Splines and Variational Methods", 1975, John Wiley and Sons
+Inc.
+.le
+.endhelp
diff --git a/math/curfit/doc/cvaccum.hlp b/math/curfit/doc/cvaccum.hlp
new file mode 100644
index 00000000..4fc3a37b
--- /dev/null
+++ b/math/curfit/doc/cvaccum.hlp
@@ -0,0 +1,51 @@
+.help cvaccum Jun84 "Curfit Package"
+.ih
+NAME
+cvaccum -- accumulate a single data point into the matrix
+.ih
+SYNOPSIS
+include <math/curfit.h>
+
+cvaccum (cv, x, y, weight, wtflag)
+
+.nf
+pointer cv # curve descriptor
+real x # x value
+real y # y value
+real weight # weight
+int wtflag # type of weighting
+.fi
+.ih
+ARGUMENTS
+.ls cv
+Pointer to the curve descriptor structure.
+.le
+.ls x
+X value. Checking for out of bounds x values is the responsibility of the
+user.
+.le
+.ls y
+Y value.
+.le
+.ls weight
+Weight assigned to the data point.
+.le
+.ls wtflag
+Type of weighting. The options are WTS_USER, WTS_UNIFORM or WTS_SPACING.
+If wtflag equals WTS_USER the weight for each point is supplied by the user.
+If wtflag is either WTS_UNIFORM or WTS_SPACING the routine sets weight
+to one.
+.le
+.ih
+DESCRIPTION
+Calculate the non-zero basis functions for the given value of x.
+Compute the contribution of the data point to the normal equations and
+sum into the appropriate arrays and vectors.
+.ih
+NOTES
+The WTS_SPACING option cannot be used with CVACCUM. Weights will be set
+to 1.
+.ih
+SEE ALSO
+cvfit, cvrefit
+.endhelp
diff --git a/math/curfit/doc/cvacpts.hlp b/math/curfit/doc/cvacpts.hlp
new file mode 100644
index 00000000..c5a6cffd
--- /dev/null
+++ b/math/curfit/doc/cvacpts.hlp
@@ -0,0 +1,54 @@
+.help cvacpts Jun84 "Curfit Package"
+.ih
+NAME
+include <math/curfit.h>
+
+cvacpts -- fit a curve to a set of data values
+.ih
+SYNOPSIS
+cvacpts (cv, x, y, weight, npts, wtflag)
+
+.nf
+pointer cv # curve descriptor
+real x[] # array of x values
+real y[] # array of y values
+real weight[] # array of weights
+int npts # number of data points
+int wtflag # type of weighting
+.fi
+.ih
+ARGUMENTS
+.ls cv
+Pointer to the curve descriptor structure.
+.le
+.ls x
+Array of x values.
+.le
+.ls y
+Array of y values
+.le
+.ls weight
+Array of weights
+.le
+.ls wtflag
+Type of weighting. The options are WTS_USER, WTS_SPACING and
+WTS_UNIFORM. If wtflag = WTS_USER individual weights for each data point
+are supplied by the calling program and points with zero-valued weights are
+not included in the fit. If wtflag = WTS_UNIFORM, all weights are assigned
+values of 1. If wtflag = WTS_SPACING, the weights are set equal to the
+difference between adjacent data points. In order to correctly use the
+WTS_SPACING option the data must be sorted in x.
+.le
+.ih
+DESCRIPTION
+CVACPTS zeroes the matrix and vectors, calculates the non-zero basis functions,
+calculates the contribution
+of each data point to the normal equations and accumulates it into the
+appropriate array and vector elements.
+.ih
+NOTES
+Checking for out of bounds x values is the responsibility of the user.
+.ih
+SEE ALSO
+cvaccum
+.endhelp
diff --git a/math/curfit/doc/cvcoeff.hlp b/math/curfit/doc/cvcoeff.hlp
new file mode 100644
index 00000000..6467cd60
--- /dev/null
+++ b/math/curfit/doc/cvcoeff.hlp
@@ -0,0 +1,36 @@
+.help cvcoeff Jun84 "Curfit Package"
+.ih
+NAME
+cvcoeff -- get the number and values of the coefficients
+.ih
+SYNOPSIS
+cvcoeff (cv, coeff, ncoeff)
+
+.nf
+pointer cv # curve descriptor
+real coeff[] # the coefficient array
+int ncoeff # the number of coefficients
+.fi
+.ih
+ARGUMENTS
+.ls pointer
+Pointer to the curve descriptor.
+.le
+.ls coeff
+Array of coefficients.
+.le
+.ls ncoeff
+The number of coefficients.
+.le
+.ih
+DESCRIPTION
+CVCOEFF fetches the coefficient array and the number of coefficients from the
+curve descriptor structure.
+.ih
+NOTES
+The variable ncoeff is only equal to the order specified in CVINIT if the
+curve_type is LEGENDRE or CHEBYSHEV. If curve_type is SPLINE3 then
+ncoeff = order + 3. If curve_type is SPLINE1 then ncoeff = order + 1.
+.ih
+SEE ALSO
+.endhelp
diff --git a/math/curfit/doc/cvepower.hlp b/math/curfit/doc/cvepower.hlp
new file mode 100644
index 00000000..58e78dae
--- /dev/null
+++ b/math/curfit/doc/cvepower.hlp
@@ -0,0 +1,55 @@
+.help cvepower Jun95 "Curfit Package"
+.ih
+NAME
+cvepower -- compute the errors of the equivalent power series
+.ih
+SYNOPSIS
+cvepower (cv, y, weight, yfit, npts, chisqr, errors)
+
+.nf
+pointer cv # curve descriptor
+real y[] # array of y data points
+weight weight[] # array of weights
+real yfit[] # array of fitted data points
+int npts # number of points
+real chisqr # the standard deviation of the fit
+real errors[] # standard deviations of the power series coefficients
+.fi
+.ih
+ARGUMENTS
+.ls cv
+Pointer to the curve descriptor structure
+.le
+.ls y
+Array of y data points
+.le
+.ls yfit
+Array of fitted y values
+.le
+.ls npts
+The number of points
+.le
+.ls chisqr
+Reduced chi-squared of the fit.
+.le
+.ls errors
+Array of standard deviations of the equivalent power series coefficients.
+.le
+.ih
+DESCRIPTION
+Calculate the reduced chi-squared of the fit and the standard deviation
+of the equivalent power series coefficients for fitted Legendre and
+Chebyshev polynomials. The errors are rescaled to the equivalent power
+series and to the original data range.
+.ih
+NOTES
+The standard deviation of the fit is the square root of the sum of the
+weighted squares of the residuals divided by the number of degrees of freedom.
+If the weights are equal, then the reduced chi-squared is the
+variance of the fit
+The error of the j-th coefficient is the square root of the j-th diagonal
+element of the inverse of the data matrix. If the weights are equal to one,
+then the errors are scaled by the square root of the variance of the data.
+.ih
+SEE ALSO
+.endhelp
diff --git a/math/curfit/doc/cverrors.hlp b/math/curfit/doc/cverrors.hlp
new file mode 100644
index 00000000..a0a0fbb2
--- /dev/null
+++ b/math/curfit/doc/cverrors.hlp
@@ -0,0 +1,53 @@
+.help cverrors Jun84 "Curfit Package"
+.ih
+NAME
+cverrors -- calculate the standard deviation of the fit and errors
+.ih
+SYNOPSIS
+cverrors (cv, y, weight, yfit, npts, chisqr, errors)
+
+.nf
+pointer cv # curve descriptor
+real y[] # array of y data points
+weight weight[] # array of weights
+real yfit[] # array of fitted data points
+int npts # number of points
+real chisqr # the standard deviation of the fit
+real errors[] # standard deviations of the coefficients
+.fi
+.ih
+ARGUMENTS
+.ls cv
+Pointer to the curve descriptor structure
+.le
+.ls y
+Array of y data points
+.le
+.ls yfit
+Array of fitted y values
+.le
+.ls npts
+The number of points
+.le
+.ls chisqr
+Reduced chi-squared of the fit.
+.le
+.ls errors
+Array of standard deviations of the coefficients.
+.le
+.ih
+DESCRIPTION
+Calculate the reduced chi-squared of the fit and the standard deviation
+of the coefficients.
+.ih
+NOTES
+The standard deviation of the fit is the square root of the sum of the
+weighted squares of the residuals divided by the number of degrees of freedom.
+If the weights are equal, then the reduced chi-squared is the
+variance of the fit
+The error of the j-th coefficient is the square root of the j-th diagonal
+element of the inverse of the data matrix. If the weights are equal to one,
+then the errors are scaled by the square root of the variance of the data.
+.ih
+SEE ALSO
+.endhelp
diff --git a/math/curfit/doc/cveval.hlp b/math/curfit/doc/cveval.hlp
new file mode 100644
index 00000000..48cd7f10
--- /dev/null
+++ b/math/curfit/doc/cveval.hlp
@@ -0,0 +1,33 @@
+.help cveval Jun84 "Curfit Package"
+.ih
+NAME
+cveval -- evaluate the fitted function at a single x value
+.ih
+SYNOPSIS
+y = cveval (cv, x)
+
+.nf
+pointer cv # curve descriptor
+real x # x value
+.fi
+.ih
+ARGUMENTS
+.ls cv
+Pointer to the curve descriptor structure.
+.le
+.ls x
+X value at which the curve is to be evaluated.
+.le
+.ih
+DESCRIPTION
+Evaluate the curve at the specified value of x. CVEVAL is a real
+function which returns the fitted y value.
+.ih
+NOTES
+It uses the coefficient array stored in the curve descriptor structure.
+The x values are assumed to lie in the region xmin <= x <= xmax. Checking
+for out of bounds x values is the responsibility of the user.
+.ih
+SEE ALSO
+cvvector
+.endhelp
diff --git a/math/curfit/doc/cvfit.hlp b/math/curfit/doc/cvfit.hlp
new file mode 100644
index 00000000..cb6beb24
--- /dev/null
+++ b/math/curfit/doc/cvfit.hlp
@@ -0,0 +1,62 @@
+.help cvfit Jun84 "Curfit Package"
+.ih
+NAME
+cvfit -- fit a curve to a set of data values
+.ih
+SYNOPSIS
+cvfit (cv, x, y, weight, npts, wtflag, ier)
+
+.nf
+pointer cv # curve descriptor
+real x[] # array of x values
+real y[] # array of y values
+real weight[] # array of weights
+int npts # number of data points
+int wtflag # type of weighting
+int ier # error code
+.fi
+.ih
+ARGUMENTS
+.ls cv
+Pointer to the curve descriptor structure.
+.le
+.ls x
+Array of x values.
+.le
+.ls y
+Array of y values
+.le
+.ls weight
+Array of weights
+.le
+.ls wtflag
+Type of weighting. The options are WTS_USER, WTS_SPACING and
+WTS_UNIFORM. If wtflag = WTS_USER individual weights for each data point
+are supplied by the calling program and points with zero-valued weights are
+not included in the fit. If wtflag = WTS_UNIFORM, all weights are assigned
+values of 1. If wtflag = WTS_SPACING, the weights are set equal to the
+difference between adjacent data points. In order to correctly use the
+WTS_SPACING option the data must be sorted in x.
+.le
+.ls ier
+Error code for the fit. The options are OK, SINGULAR and
+NO_DEG_FREEDON. If ier = SINGULAR, the numerical routines will compute a
+solution but one or more of the coefficients will be
+zero. If ier = NO_DEG_FREEDOM, there were too few data points to solve the
+matrix equations and the routine returns without fitting the data.
+.le
+.ih
+DESCRIPTION
+CVFIT zeroes the matrix and vectors, calculates the non-zero basis functions,
+calculates the contribution
+of each data point to the normal equations and accumulates it into the
+appropriate array and vector elements. The Cholesky factorization of the
+data array is computed and the coefficients of the fitting function are
+calculated.
+.ih
+NOTES
+Checking for out of bounds x values is the responsibility of the user.
+.ih
+SEE ALSO
+cvrefit, cvaccum, cvsolve, cvchofac, cvcholsv
+.endhelp
diff --git a/math/curfit/doc/cvfree.hlp b/math/curfit/doc/cvfree.hlp
new file mode 100644
index 00000000..c486b306
--- /dev/null
+++ b/math/curfit/doc/cvfree.hlp
@@ -0,0 +1,26 @@
+.help cvfree Jun84 "Curfit Package"
+.ih
+NAME
+cvfree -- free the curve descriptor structure
+.ih
+SYNOPSIS
+cvfree (cv)
+
+.nf
+pointer cv # curve descriptor
+.fi
+.ih
+ARGUMENTS
+.ls cv
+Pointer to the curve descriptor structure.
+.le
+.ih
+DESCRIPTION
+Frees the curve descriptor structure.
+.ih
+NOTES
+CVFREE should be called after each curve fit.
+.ih
+SEE ALSO
+cvinit
+.endhelp
diff --git a/math/curfit/doc/cvinit.hlp b/math/curfit/doc/cvinit.hlp
new file mode 100644
index 00000000..dc891ed2
--- /dev/null
+++ b/math/curfit/doc/cvinit.hlp
@@ -0,0 +1,55 @@
+.help cvinit Jun84 "Curfit Package"
+.ih
+NAME
+cvinit -- initialise curve descriptor
+.ih
+SYNOPSIS
+include <math/curfit.h>
+
+cvinit (cv, curve_type, order, xmin, xmax)
+
+.nf
+pointer cv # curve descriptor
+int curve_type # the fitting function
+int order # order of the fit
+real xmin # minimum x value
+real xmax # maximum x value
+.fi
+.ih
+ARGUMENTS
+.ls cv
+Pointer to the curve descriptor structure.
+.le
+.ls curve_type
+Fitting function.
+Permitted values are LEGENDRE and CHEBYSHEV, for Legendre and
+Chebyshev polynomials and SPLINE3 and SPLINE1 for a cubic spline
+and linear spline with uniformly spaced
+break points.
+.le
+.ls order
+Order of the polynomial to be fit or the number of polynomial pieces
+to be fit by a cubic spline. Order must be greater than or equal to one.
+If curve_type is set to LEGENDRE or CHEBYSHEV and order equals one, a constant
+term is fit to the data.
+.le
+.ls xmax, xmin
+Minimum and maximum x values. All x values of interest
+including the data x values and the x values of any curve to be evaluated
+must fall in the range xmin <= x <= xmax. Checking for out of bounds x
+values is the responsibility of user.
+.le
+.ih
+DESCRIPTION
+Allocate space for the curve descriptor structure and the arrays and
+vectors used by the numerical routines. Initialize all arrays and vectors
+to zero. Return the
+curve descriptor to the calling routine.
+.ih
+NOTES
+CVINIT must be the first CURFIT routine called. CVINIT returns if an
+illegal curve type is requested.
+.ih
+SEE ALSO
+cvfree
+.endhelp
diff --git a/math/curfit/doc/cvpower.hlp b/math/curfit/doc/cvpower.hlp
new file mode 100644
index 00000000..386558ce
--- /dev/null
+++ b/math/curfit/doc/cvpower.hlp
@@ -0,0 +1,40 @@
+.help cvpower Jan86 "Curfit Package"
+.ih
+NAME
+cvpower -- convert coefficients to power series coefficients.
+.ih
+SYNOPSIS
+.nf
+include <math/curfit.h>
+include "curfitdef.h"
+
+cvpower (cv, ps_coeff, ncoeff)
+
+pointer cv # Curve descriptor
+real ps_coeff[ncoeff] # Power series coefficients
+int ncoeff # Number of coefficients in fit
+.fi
+.ih
+ARGUMENTS
+.ls cv
+Pointer to the curve descriptor structure.
+.le
+.ls ps_coeff
+The output array of power series coefficients.
+.le
+.ls ncoeff
+The output number of coefficients in the fit.
+.le
+.ih
+DESCRIPTION
+This routine routines the equivlalent power series fit coefficients
+and the number of coefficients.
+
+The coefficients of either a legendre or chebyshev solution can be converted
+to power series coefficients of the form y = a0 + a1*x + a2*x**2 + a3*x**3...
+The output coefficients are scaled to the original data range.
+.ih
+NOTES
+Only legendre and chebyshev coefficients are converted. An error is
+reported for other curve types.
+.endhelp
diff --git a/math/curfit/doc/cvrefit.hlp b/math/curfit/doc/cvrefit.hlp
new file mode 100644
index 00000000..4612b4c6
--- /dev/null
+++ b/math/curfit/doc/cvrefit.hlp
@@ -0,0 +1,52 @@
+.help cvrefit Jun84 "Curfit Package"
+.ih
+NAME
+cvrefit -- refit new y vector using old x vector and weights
+.ih
+SYNOPSIS
+cvrefit (cv, x, y, w, ier)
+
+.nf
+pointer cv # curve descriptor
+real x[] # array of x values
+real y[] # array of y values
+real weight[] # array of weights
+int ier # error code
+.fi
+.ih
+ARGUMENTS
+.ls cv
+Pointer to the curve descriptor
+.le
+.ls x
+Array of x values.
+.le
+.ls y
+Array of y values.
+.le
+.ls weight
+Array of weights.
+.le
+.ls ier
+Error code. The options are OK, SINGULAR and NO_DEG_FREEDOM. If ier equals
+singular a solution is computed but one or more of the coefficients may
+be zero. If ier equals NO_DEG_FREEDOM, there are insufficient data points
+to compute a solution and CVREFIT returns without solving for the coefficients.
+.le
+.ih
+DESCRIPTION
+In some application the x and weight values remain unchanged from fit to fit
+and only the y values vary. In this case it is redundant to reaccumulate
+the matrix and perform the Cholesky factorization. CVREFIT zeros and
+reaccumulates the vector on the right hand side of the matrix equation
+and performs the forward and back substitution phase to fit for a new
+coefficient vector.
+.ih
+NOTES
+In the first call to CVREFIT space is allocated for the non-zero basis
+functions. Subsequent call to CVREFIT reference this array to avoid
+recaculating basis functions at every call.
+.ih
+SEE ALSO
+cvfit, cvaccum, cvsolve, cvchoslv
+.endhelp
diff --git a/math/curfit/doc/cvreject.hlp b/math/curfit/doc/cvreject.hlp
new file mode 100644
index 00000000..52e5ca4f
--- /dev/null
+++ b/math/curfit/doc/cvreject.hlp
@@ -0,0 +1,41 @@
+.help cvreject June84 "Curfit Package"
+.ih
+NAME
+cvreject -- reject a single data point from the data set to be fit
+.ih
+SYNOPSIS
+cvreject (cv, x, y, weight)
+
+.nf
+pointer cv # curve descriptor
+real x # x value
+real y # y value
+real weight # weight value
+.fi
+.ih
+ARGUMENTS
+.ls cv
+Pointer to the curve descriptor structure.
+.le
+.ls x
+X value.
+.le
+.ls y
+Y value.
+.le
+.ls weight
+The weight value.
+.le
+.ih
+DESCRIPTION
+CVREJECT removes an individul data point from the data set.
+The non-zero basis functions for each x are calculated. The contribution
+of each x to the normal equations is computed and subtracted from the
+appropriate arrays and vectors.
+An array of points can be removed from the fit by repeated calls to CVREJECT
+followed by a single call to CVSOLVE to calculate a new set of coefficients.
+.ih
+NOTES
+.ih
+SEE ALSO
+.endhelp
diff --git a/math/curfit/doc/cvrestore.hlp b/math/curfit/doc/cvrestore.hlp
new file mode 100644
index 00000000..84d352ee
--- /dev/null
+++ b/math/curfit/doc/cvrestore.hlp
@@ -0,0 +1,32 @@
+.help cvrestore Aug84 "Curfit Package"
+.ih
+NAME
+cvrestore -- restore fit parameters
+.ih
+SYNOPSIS
+cvrestore (cv, fit)
+
+.nf
+pointer cv # pointer to curve descriptor
+real fit[] # array containing curve parameters
+.fi
+.ih
+ARGUMENTS
+.ls cv
+Pointer to curve descriptor structure. Returned by CVRESTORE.
+.le
+.ls fit
+Array containing the curve parameters. Must have at least 7 + order
+elements, where order is the parameter set in CVINIT.
+.le
+.ih
+DESCRIPTION
+CVRESTORE returns oldcv the pointer to the curve descriptor and
+stores the curve parameters in fit in the structure ready for
+use by cveval or cvvector.
+.ih
+NOTES
+.ih
+SEE ALSO
+cvsave
+.endhelp
diff --git a/math/curfit/doc/cvsave.hlp b/math/curfit/doc/cvsave.hlp
new file mode 100644
index 00000000..144beaff
--- /dev/null
+++ b/math/curfit/doc/cvsave.hlp
@@ -0,0 +1,35 @@
+.help cvsave Aug84 "Curfit Package"
+.ih
+NAME
+cvsave -- save parameters of fit
+.ih
+SYNOPSIS
+call cvsave (cv, fit)
+
+.nf
+pointer cv # curve descriptor
+real fit[] # array containing the fit parameters
+.fi
+.ih
+ARGUMENTS
+.ls cv
+The pointer to the curve descriptor structure.
+.le
+.ls fit
+Array containing the fit parameters.
+Fit must contain at least 7 + order elements, where order is the order of the
+fit as set in CVINIT.
+.le
+.ih
+DESCRIPTION
+CVSAVE saves the curve parameters in the real array fit.
+The first four elements of fit contain the curve_type, order, xmin and xmax.
+The coefficients are stored in the remaining array elements.
+.ih
+NOTES
+CVSAVE does not preserve the matrices and vectors used by the fitting
+routines.
+.ih
+SEE ALSO
+cvrestore
+.endhelp
diff --git a/math/curfit/doc/cvset.hlp b/math/curfit/doc/cvset.hlp
new file mode 100644
index 00000000..5eb79f30
--- /dev/null
+++ b/math/curfit/doc/cvset.hlp
@@ -0,0 +1,56 @@
+.help cvset Nov84 "Curfit Package"
+.ih
+NAME
+cvset -- input fit parameters derived external to CURFIT
+.ih
+SYNOPSIS
+include <math/curfit.h>
+
+cvset (cv, curve_type, xmin, xmax, coeff, ncoeff)
+
+.nf
+pointer cv # pointer to curve descriptor
+int curve_type # functional form of the curve to be fitted
+real xmin, xmax # minimum and maximum x values
+real coeff[ncoeff] # coefficient array
+int ncoeff # number of coefficients
+.fi
+.ih
+ARGUMENTS
+.ls cv
+Pointer to curve descriptor structure. Returned by CVSET.
+.le
+.ls curve_type
+Type of curve to be input. Must be one of LEGENDRE, CHEBYSHEV, SPLINE3
+or SPLINE1.
+.le
+.ls xmin, xmax
+The minimum and maximum data or fitted x values. The Legendre and
+Chebyshev polynomials are assumed to be normalized over this range.
+For the cubic and linear spline functions, the data range (xmax - xmin) is
+divided into (ncoeff - 3) and (ncoeff - 1) evenly spaced polynomial pieces
+respectively.
+.le
+.ls coeff
+Array containing the coefficients. Must have at least 7 + order
+elements, where order has the same meaning as the order parameter set in CVINIT.
+.le
+.ls ncoeff
+The number of coefficients. For polynomial functions, ncoeff
+equals 1 plus the order of the polynomial, e.g. a second order
+polynomial curve will have three coefficients. For the cubic
+and linear spline the number of polynomial pieces fit are
+(ncoeff - 3) and (ncoeff - 1) respectively.
+.le
+.ih
+DESCRIPTION
+CVSET returns cv the pointer to the curve descriptor and
+stores the curve parameters in the CURFIT structure ready for
+use by CVEVAL or CVVECTOR.
+.ih
+NOTES
+The splines are assumed to have been fit in the least squares sense.
+.ih
+SEE ALSO
+cvsave
+.endhelp
diff --git a/math/curfit/doc/cvsolve.hlp b/math/curfit/doc/cvsolve.hlp
new file mode 100644
index 00000000..16badae2
--- /dev/null
+++ b/math/curfit/doc/cvsolve.hlp
@@ -0,0 +1,39 @@
+.help cvsolve Jun84 "Curfit Package"
+.ih
+NAME
+cvsolve -- solve a linear system of eqns by the Cholesky method
+.ih
+SYNOPSIS
+cvsolve (cv, ier)
+
+.nf
+pointer cv # curve descriptor
+int ier # error code
+.fi
+.ih
+ARGUMENTS
+.ls cv
+Pointer to the curve descriptor
+.le
+.ls ier
+Error code returned by the fitting routines. The options are
+OK, SINGULAR and NO_DEG_FREEDOM. If ier is SINGULAR the matrix is singular,
+CVSOLVE will compute a solution to the normal equationsbut one or more of the
+coefficients will be zero.
+If ier equals NO_DEG_FREEDOM, too few data points exist for a reasonable
+solution to be computed. CVSOLVE returns
+without fitting the data.
+.le
+.ih
+DESCRIPTION
+CVSOLVE call two routines CVCHOFAC and CVCHOSLV. CVCHOFAC computes the
+Cholesky factorization of the data matrix. CVCHOSLV solves for the
+coefficients of the fitting function by forward and back substitution.
+An error code is returned by CVSOLVE if it is unable to solve the normal
+equations as formulated.
+.ih
+NOTES
+.ih
+SEE ALSO
+cvchofac, cvchoslv
+.endhelp
diff --git a/math/curfit/doc/cvstati.hlp b/math/curfit/doc/cvstati.hlp
new file mode 100644
index 00000000..ffd05d0a
--- /dev/null
+++ b/math/curfit/doc/cvstati.hlp
@@ -0,0 +1,47 @@
+.help cvstati May85 "Curfit Package"
+.ih
+NAME
+cvstati -- get integer parameter
+.ih
+SYNOPSIS
+include <math/curfit.h>
+
+ival = cvstati (cv, parameter)
+
+.nf
+pointer cv # curve descriptor
+int parameter # parameter to be returned
+.fi
+.ih
+ARGUMENTS
+.ls cv
+The pointer to the curve descriptor structure.
+.le
+.ls parameter
+Parameter to be return. Definitions in curfit.h are:
+.nf
+ define CVTYPE 1 # curve type
+ define CVORDER 2 # order
+ define CVNCOEFF 3 # number of coefficients
+ define CVNSAVE 4 # length of save buffer
+.fi
+.le
+.ih
+DESCRIPTION
+The values of integer parameters are returned. The parameters include
+the curve type, the order, the number of coefficients, and the length
+of the buffer required by CVSAVE (which is of TY_REAL).
+.ih
+EXAMPLES
+.nf
+ include <curfit.h>
+
+ int cvstati()
+
+ call malloc (buf, cvstati (cv, CVNSAVE), TY_REAL)
+ call cvsave (cv, Memr[buf])
+.fi
+.ih
+SEE ALSO
+cvstatr
+.endhelp
diff --git a/math/curfit/doc/cvstatr.hlp b/math/curfit/doc/cvstatr.hlp
new file mode 100644
index 00000000..f4d959c2
--- /dev/null
+++ b/math/curfit/doc/cvstatr.hlp
@@ -0,0 +1,44 @@
+.help cvstatr May85 "Curfit Package"
+.ih
+NAME
+cvstatr -- get real parameter
+.ih
+SYNOPSIS
+include <math/curfit.h>
+
+rval = cvstatr (cv, parameter)
+
+.nf
+pointer cv # curve descriptor
+int parameter # parameter to be returned
+.fi
+.ih
+ARGUMENTS
+.ls cv
+The pointer to the curve descriptor structure.
+.le
+.ls parameter
+Parameter to be return. Definitions in curfit.h are:
+.nf
+ define CVXMIN 5 # minimum ordinate
+ define CVORDER 6 # maximum ordinate
+.fi
+.le
+.ih
+DESCRIPTION
+The values of real parameters are returned. The parameters include
+the minimum and maximum ordinate values of the curve.
+.ih
+EXAMPLES
+.nf
+ include <curfit.h>
+
+ real cvstatr()
+
+ xmin = cvstatr (cv, CVXMIN)
+ xmax = cvstatr (cv, CVXMAX)
+.fi
+.ih
+SEE ALSO
+cvstati
+.endhelp
diff --git a/math/curfit/doc/cvvector.hlp b/math/curfit/doc/cvvector.hlp
new file mode 100644
index 00000000..79c0282f
--- /dev/null
+++ b/math/curfit/doc/cvvector.hlp
@@ -0,0 +1,41 @@
+.help cvvector Jun84 "Curfit Package"
+.ih
+NAME
+cvvector -- evaluate the fitted curve at a set of points
+.ih
+SYNOPSIS
+cvvector (cv, x, yfit, npts)
+
+.nf
+pointer cv # curve descriptor
+real x[] # x array
+real yfit[] # array of fitted y values
+int npts # number of x values
+.fi
+.ih
+ARGUMENTS
+.ls cv
+Pointer to the curve descriptor structure.
+.le
+.ls x
+Array of x values
+.le
+.ls yfit
+Array of fitted y values
+.le
+.ls npts
+The number of x values at which the curve is to be evaluated.
+.le
+.ih
+DESCRIPTION
+Fit the curve to an array of data points. CVVECTOR uses the coefficients
+stored in the curve descriptor structure.
+.ih
+NOTES
+The x values are assumed to lie
+in the region xmin <= x <= xmax. Checking for out of bounds x values is the
+responsibility of the user.
+.ih
+SEE ALSO
+cveval
+.endhelp
diff --git a/math/curfit/doc/cvzero.hlp b/math/curfit/doc/cvzero.hlp
new file mode 100644
index 00000000..7f9e07e2
--- /dev/null
+++ b/math/curfit/doc/cvzero.hlp
@@ -0,0 +1,26 @@
+.help cvzero Aug84 "Curfit Package"
+.ih
+NAME
+cvzero -- set up for a new curve fit
+.ih
+SYNOPSIS
+cvzero (cv)
+
+.nf
+pointer cv # curve descriptor
+.fi
+.ih
+ARGUMENTS
+.ls cv
+Pointer to the curve descriptor structure.
+.le
+.ih
+DESCRIPTION
+CVZERO zeros the matrix and right side of the matrix equation.
+.ih
+NOTES
+CVZERO can be used to reinitialize the matrix and right side of the matrix
+equation to begin a new fit in accumulate mode.
+.ih
+SEE ALSO
+cvfit, cvinit