smaFunc.c
Interface to FUNC (function) and METH (method) structures in sdssmath
Create a new FUNC
SIGNATURE:
FUNC *smFuncNew(
char *name, /* name of the function: gauss, dpol, bspline,
lin */
VECTOR **va, /* array of vectors with parameter values */
int nHandle /* number of vectors in va */
)
Delete a FUNC
SIGNATURE:
RET_CODE smFuncDel(
FUNC *func /* the FUNC to delete */
)
Create a new METH
SIGNATURE:
METH *smMethNew(
char *name /* name of the method; chi2 */
)
Delete a METH
SIGNATURE:
RET_CODE smMethDel(
METH *meth /* the METH to delete */
)
Evaluate at FUNC at one value of x. Return SH_SUCCESS if the value is
valid, or SH_GENERIC_ERROR if there is trouble.
SIGNATURE:
RET_CODE smaFuncEval(
FUNC *func, /* the FUNC to evaluate */
double x, /* where to evaluate it */
double *y /* the return value */
)
Function definition for an "unknown" which only returns zeros
SIGNATURE:
RET_CODE smaFuncUnknown(
int nVector,
VECTOR **va,
double *param,
double x,
double *y
)
Function definition for gauss
One vector of dimen=3 in va with the position, sigma, and normalization.
SIGNATURE:
RET_CODE smaFuncGauss(
int nVector,
VECTOR **va,
double *param,
double x,
double *y
)
Function definition for Hubble
One vector of dimen=2 in va with I0 and a.
SIGNATURE:
RET_CODE smaFuncHubble(
int nVector,
VECTOR **va,
double *param,
double x,
double *y
)
Function definition for devauc
One vector of dimen=2 in va with Ie and re.
SIGNATURE:
RET_CODE smaFuncDevauc(
int nVector,
VECTOR **va,
double *param,
double x,
double *y
)
Function definition for Freeman
One vector of dimen=2 in va with I0 and r0.
SIGNATURE:
RET_CODE smaFuncFreeman(
int nVector,
VECTOR **va,
double *param,
double x,
double *y
)
Function definition for dpol
We expect to get two vectors in the va:
va[0] is returned from dpolft
va[1] is a vector of length 1, containing the degree of the polynomial
SIGNATURE:
RET_CODE smaFuncDpol(
int nVector,
VECTOR **va,
double *param,
double x,
double *y
)
Function definition for bspline
We expect 6 vectors here:
va[0] is the knot array of length n+4 (t)
va[1] is the coefficient vector of length n (a)
va[2] is the order of the fit spline k >= 1 (k)
va[3] is the derivative to evaluate (0 for example)
va[4] is the inbv parameter; set to 1 and retains state of v[5] (inbv)
va[5] is a work array of length 3*k (work)
SIGNATURE:
RET_CODE smaFuncBspline (
int nVector,
VECTOR **va,
double *param,
double x,
double *y
)
Function definition for lin
One vector in va has intercept and slope of the straight line
SIGNATURE:
RET_CODE smaFuncLin(
int nVector,
VECTOR **va,
double *param,
double x,
double *y
)
Function definition for linMulti
returned by vLinFit
A linear equation with n terms and one unknown,
i.e., Sigma_{0}^{i} a_i x_i = y, with one x_i unknown )
va[0] = constants determined by linear fit
va[1] = values for each x_i (include place holder value for unknown)
va[2] = the y value in va[2]->vec[0]
x = index for the x_i that is the unknown (zero based indexing)
y = the returned value for the unknown x_i
SIGNATURE:
RET_CODE smaFuncLinMulti(
int nVector,
VECTOR **va,
double *param,
double x,
double *y
)
Set some global pointers
SIGNATURE:
void smaGlobalSet(VECTOR *x, VECTOR *y, VECTOR *w, FUNC *func, VECTOR *mask)
Method definition for Chi2
SIGNATURE:
void smaMethChi2 (
int *iflag,
int *m, /* number of data points */
int *n, /* number of parameters */
double *param, /* input array of length n */
double *fvec, /* output array of length m */
double *fjac,
int *ldfjac)
Get the address of the function given its name and do some sanity checks
SIGNATURE:
SMA_FUNC smaFuncAddrGetFromName(
char *name, /* name of the function */
VECTOR **va, /* the va to set */
int nVector /* the number of vectors in va */
)
Get the method address from the name
SIGNATURE:
SMA_METH smaMethAddrGetFromName(
char *name /* the name of the method */
)
Fill in the covariance matrix
SIGNATURE:
RET_CODE smaCovFromFit(
METH *meth, /* the method to use */
FUNC *func, /* the fit function;
cov sigma and chi2 filled in here */
double epsfcn /* step size to use;
0.0 defaults to machine precision */
)
Plot a FUNC on a PGSTATE
SIGNATURE:
int smaFuncPlot(
PGSTATE *pg, /* where to plot and how to plot it */
FUNC *func, /* what to plot */
FUNC *resFunc, /* what to subtract at each point */
double xmin, /* beginning x */
double xmax, /* ending x */
int npt /* number of points to plot */
)