IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 4040


Ignore:
Timestamp:
May 26, 2005, 2:38:08 PM (21 years ago)
Author:
eugene
Message:

added psPolynomial updates

Location:
trunk/doc/pslib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/pslib/ChangeLogSDRS.tex

    r3992 r4040  
    1 %%% $Id: ChangeLogSDRS.tex,v 1.103 2005-05-20 00:43:57 price Exp $
     1%%% $Id: ChangeLogSDRS.tex,v 1.104 2005-05-27 00:38:08 eugene Exp $
    22
    33\subsection{Changes from version 00 to version 01}
     
    613613\item Renamed \code{psMaskToPixels} to \code{psPixelsFromMask} (bug 414).
    614614\item \code{psRegionFromString} returns \code{NaN} for any element that doesn't parse correctly (bug 416).
    615 \end{itemize}
     615
     616\item unified the single and double precision polynomials
     617\item re-ordered the psPolynomial*Alloc arguments
     618\item changed the psPolynomials to be defined in terms of Norder not Nterms
     619\item re-ordered the psVectorFitPoly* arguments
     620\item added mask \& maskValue ot psVectorFitPoly*
     621\item changed the requirements on the input data vectors to psPolynomialFit and Eval
     622\item added the psVectorClipFitPoly* functions
     623
     624\end{itemize}
  • trunk/doc/pslib/psLibSDRS.tex

    r4022 r4040  
    1 %%% $Id: psLibSDRS.tex,v 1.233 2005-05-24 23:56:16 jhoblitt Exp $
     1%%% $Id: psLibSDRS.tex,v 1.234 2005-05-27 00:38:08 eugene Exp $
    22\documentclass[panstarrs,spec]{panstarrs}
    33
     
    23502350typedef struct {
    23512351    psPolynomialType type;              ///< Polynomial type
     2352    psElemType       ctype;             ///< Polynomial precision
    23522353    int n;                              ///< Number of terms
    2353     float *coeff;                       ///< Coefficients
    2354     float *coeffErr;                    ///< Error in coefficients
     2354    union {
     2355      psF32 *F32;                       ///< Coefficients
     2356      psF64 *F64;                       ///< Coefficients
     2357    } coeff;
     2358    union {
     2359      psF32 *F32;                       ///< Error in coefficients
     2360      psF64 *F64;                       ///< Error in coefficients
     2361    } coeffErr;
    23552362    char *mask;                         ///< Coefficient mask
    23562363} psPolynomial1D;
     
    23612368typedef struct {
    23622369    psPolynomialType type;              ///< Polynomial type
     2370    psElemType       ctype;             ///< Polynomial precision
    23632371    int nX, nY;                         ///< Number of terms in x and y
    2364     float **coeff;                      ///< Coefficients
    2365     float **coeffErr;                   ///< Error in coefficients
     2372    union {
     2373      psF32 **F32;                       ///< Coefficients
     2374      psF64 **F64;                       ///< Coefficients
     2375    } coeff;
     2376    union {
     2377      psF32 **F32;                       ///< Error in coefficients
     2378      psF64 **F64;                       ///< Error in coefficients
     2379    } coeffErr;
     2380    char *mask;                         ///< Coefficient mask
    23662381    char **mask;                        ///< Coefficients mask
    23672382} psPolynomial2D;
     
    23792394\end{datatype}
    23802395
    2381 We also define double-precision versions of the polynomials:
    2382 
    2383 \begin{datatype}
    2384 /** Double-precision one-dimensional polynomial */
    2385 typedef struct {
    2386     psPolynomialType type;              ///< Polynomial type
    2387     int n;                              ///< Number of terms
    2388     double *coeff;                      ///< Coefficients
    2389     double *coeffErr;                   ///< Error in coefficients
    2390     char *mask;                         ///< Coefficient mask
    2391 } psDPolynomial1D;
    2392 \end{datatype}
    2393 
    2394 \begin{datatype}
    2395 /** Double-precision two-dimensional polynomial */
    2396 typedef struct {
    2397     psPolynomialType type;              ///< Polynomial type
    2398     int nX, nY;                         ///< Number of terms in x and y
    2399     double **coeff;                     ///< Coefficients
    2400     double **coeffErr;                  ///< Error in coefficients
    2401     char **mask;                        ///< Coefficients mask
    2402 } psDPolynomial2D;
    2403 \end{datatype}
    2404 
    2405 etc.  In what follows, we only show the version for double-precision
    2406 two-dimensionals; the others may be inferred following the standard
    2407 naming convention exampled above.
    2408 
    2409 The constructor is:
    2410 \begin{prototype}
    2411 psDPolynomial2D *psDPolynomial2DAlloc(int nX, int nY, psPolynomialType type);
    2412 \end{prototype}
    2413 where \code{nX} and \code{nY} are the number of terms in x and y
    2414 respectively.  The coefficients, errors and masks are set initially to
    2415 zero.
     2396The element \code{ctype} defines the data type for the coefficients
     2397(allowed values of \code{PS_TYPE_F32} and \code{PS_TYPE_F64}).
     2398
     2399The constructors are:
     2400\begin{prototype}
     2401psPolynomial1D *psPolynomial1DAlloc(psPolynomialType type,
     2402                                    psElemType ctype,
     2403                                    int nX);
     2404psPolynomial2D *psPolynomial2DAlloc(psPolynomialType type,
     2405                                    psElemType ctype,
     2406                                    int nX, int nY);
     2407psPolynomial3D *psPolynomial3DAlloc(psPolynomialType type,
     2408                                    psElemType ctype,
     2409                                    int nX, int nY, int nZ);
     2410psPolynomial4D *psPolynomial4DAlloc(psPolynomialType type,
     2411                                    psElemType ctype,
     2412                                    int nX, int nY, int nZ, int nT);
     2413\end{prototype}
     2414where \code{nX}, \code{nY}, etc specify the polynomial order in the
     2415given dimension.  The coefficients, errors and masks are set initially
     2416to zero.
    24162417
    24172418To evaluate the polynomials at specific coordinates, we define:
    24182419\begin{prototype}
    2419 double psDPolynomial2DEval(const psDPolynomial2D *myPoly, double x, double y);
     2420psF64 psPolynomial2DEval(const psPolynomial2D *myPoly,
     2421                         psF64 x);
     2422psF64 psPolynomial2DEval(const psPolynomial2D *myPoly,
     2423                         psF64 x,
     2424                         psF64 y);               
     2425psF64 psPolynomial2DEval(const psPolynomial2D *myPoly,
     2426                         psF64 x,
     2427                         psF64 y,
     2428                         psF64 z);                 
     2429psF64 psPolynomial2DEval(const psPolynomial2D *myPoly,
     2430                         psF64 x,
     2431                         psF64 y,
     2432                         psF64 z,
     2433                         psF64 t);
    24202434\end{prototype}
    24212435
    24222436In the event that several evaluations are required, we also define:
    24232437\begin{prototype}
    2424 psVector *psDPolynomial2DEvalVector(const psDPolynomial2D *myPoly, const psVector *x, const psVector *y);
    2425 \end{prototype}
    2426 If the \code{x} and \code{y} vectors do not match the precision of the
    2427 polynomial, the function shall generate a warning, and convert the
    2428 vectors to the appropriate precision.  In the event that the \code{x}
    2429 and \code{y} vectors are of differing sizes, the function shall
    2430 generate a warning, truncate the longer vector to the size of the
    2431 shorter, and continue.  The precision of the output \code{psVector}
    2432 shall match that of the polynomial.  In evaluation, those coefficients
    2433 that have the corresponding \code{mask} element non-zero shall not be
    2434 evaluated.
     2438psVector *psPolynomial2DEvalVector(const psPolynomial2D *myPoly,
     2439                                   const psVector *x);
     2440psVector *psPolynomial2DEvalVector(const psPolynomial2D *myPoly,
     2441                                   const psVector *x,
     2442                                   const psVector *y);
     2443psVector *psPolynomial2DEvalVector(const psPolynomial2D *myPoly,
     2444                                   const psVector *x,
     2445                                   const psVector *y,
     2446                                   const psVector *z);
     2447psVector *psPolynomial2DEvalVector(const psPolynomial2D *myPoly,
     2448                                   const psVector *x,
     2449                                   const psVector *y,
     2450                                   const psVector *z,
     2451                                   const psVector *t);
     2452\end{prototype}
     2453The function shall accept input vectors of any type, converting to
     2454\code{psF64} as needed.  In the event that the \code{x} and \code{y}
     2455vectors are of differing sizes, the function shall generate a warning,
     2456truncate the longer vector to the size of the shorter, and continuing.
     2457The precision of the output \code{psVector} shall be \code{psF64}.  In
     2458evaluation, those coefficients that have the corresponding \code{mask}
     2459element non-zero shall not be evaluated.
    24352460
    24362461\subsubsection{Splines}
     
    26912716
    26922717\begin{prototype}
    2693 psPolynomial1D *psVectorFitPolynomial1D(psPolynomial1D *myPoly, const psVector *x, const psVector *y,
    2694                                         const psVector *yErr);
    2695 \end{prototype}
    2696 \code{psVectorFitPolynomial1d} returns the polynomial that best fits the
    2697 observations.  The input parameters are a polynomial that specifies
    2698 the fit order, \code{myPoly}, which will be altered and returned with
    2699 the best-fit coefficients; and the observations, \code{x}, \code{y}
    2700 and \code{yErr}.  The independent variable list, \code{x} may be
    2701 \code{NULL}, in which case the vector index is used.  The dependent
    2702 variable error, \code{yErr} may be null, in which case the solution is
    2703 determined in the assumption that all data errors are equal.  This
    2704 function must be valid only for types \code{psF32}, \code{psF64}.
     2718psPolynomial1D *psVectorFitPolynomial1D(psPolynomial1D *myPoly,
     2719                                        const psVector *mask,
     2720                                        unsigned int    maskValue
     2721                                        const psVector *f,
     2722                                        const psVector *fErr
     2723                                        const psVector *x);
     2724psPolynomial2D *psVectorFitPolynomial2D(psPolynomial1D *myPoly,
     2725                                        const psVector *mask,
     2726                                        unsigned int    maskValue
     2727                                        const psVector *f,
     2728                                        const psVector *fErr
     2729                                        const psVector *x,
     2730                                        const psVector *y);
     2731psPolynomial3D *psVectorFitPolynomial3D(psPolynomial1D *myPoly,
     2732                                        const psVector *mask,
     2733                                        unsigned int    maskValue
     2734                                        const psVector *f,
     2735                                        const psVector *fErr
     2736                                        const psVector *x,
     2737                                        const psVector *y,
     2738                                        const psVector *z);
     2739psPolynomial4D *psVectorFitPolynomial4D(psPolynomial1D *myPoly,
     2740                                        const psVector *mask,
     2741                                        unsigned int    maskValue
     2742                                        const psVector *f,
     2743                                        const psVector *fErr
     2744                                        const psVector *x,
     2745                                        const psVector *y,
     2746                                        const psVector *z,
     2747                                        const psVector *t);
     2748\end{prototype}
     2749These functions return the polynomial that best fits the input data.
     2750The provided polynomial, \code{myPoly}, specifies the fit order, and
     2751will be returnd with the best-fit coefficients.  The dependent
     2752variable and its error (\code{f, fErr}) are provided along with the
     2753appropriate number of independent variables (\code{x}, \code{y}, etc).
     2754In the special case of 1D fitting, the independent variable list,
     2755\code{x} may be \code{NULL}, in which case the vector index is used.
     2756The dependent variable error, \code{yErr} may be null, in which case
     2757the solution is determined in the assumption that all data errors are
     2758equal.  This function must be valid only for input data types of
     2759\code{psF32}, \code{psF64}. The \code{mask} and \code{maskValue}
     2760entries may be used to specify an input data set to ignore.  All of
     2761the input vectors must be the same length.
     2762
     2763\begin{prototype}
     2764psPolynomial1D *psVectorClipFitPolynomial1D(psPolynomial1D *myPoly,
     2765                                        psStats            *stats,
     2766                                        const psVector     *mask,
     2767                                        unsigned int        maskValue
     2768                                        const psVector     *f,
     2769                                        const psVector     *fErr
     2770                                        const psVector     *x);
     2771psPolynomial2D *psVectorClipFitPolynomial2D(psPolynomial1D *myPoly,
     2772                                        psStats            *stats,
     2773                                        const psVector     *mask,
     2774                                        unsigned int        maskValue
     2775                                        const psVector     *f,
     2776                                        const psVector     *fErr
     2777                                        const psVector     *x,
     2778                                        const psVector     *y);
     2779psPolynomial3D *psVectorClipFitPolynomial3D(psPolynomial1D *myPoly,
     2780                                        psStats            *stats,
     2781                                        const psVector     *mask,
     2782                                        unsigned int        maskValue
     2783                                        const psVector     *f,
     2784                                        const psVector     *fErr
     2785                                        const psVector     *x,
     2786                                        const psVector     *y,
     2787                                        const psVector     *z);
     2788psPolynomial4D *psVectorClipFitPolynomial4D(psPolynomial1D *myPoly,
     2789                                        psStats            *stats,
     2790                                        const psVector     *mask,
     2791                                        unsigned int        maskValue
     2792                                        const psVector     *f,
     2793                                        const psVector     *fErr
     2794                                        const psVector     *x,
     2795                                        const psVector     *y,
     2796                                        const psVector     *z,
     2797                                        const psVector     *t);
     2798\end{prototype}
     2799These functions replicate the capability of the vector fitting
     2800functions, but also include an iterative clipping stage.  The clipping
     2801parameters are defined by the \code{stats} entry, to which are also
     2802returned the clipped statistics for the final residuals.  Thus, if N
     2803clipping iterations are requested, the function performs the fit,
     2804constructs the residuals, measures the residual scatter, and masks the
     2805outlier vector elements.  This cycle is repeated N times, though on
     2806the last iteration, no additional masking is performed.  The provided
     2807mask must be respected, and any additionally masked elements are also
     2808masked with the same mask vector, which must be provided.  The
     2809elements masked by this routine are given the mask value of 1 and may
     2810thus be distinguished from input masked elements if they use a
     2811different mask value.
    27052812
    27062813\begin{prototype}
Note: See TracChangeset for help on using the changeset viewer.