/** @file  psPolynomialUtils.h
 *
 * extra psPolynomial-related functions
 */

#ifndef PS_POLYNOMIAL_UTILS_H
#define PS_POLYNOMIAL_UTILS_H

#include "psVector.h"
#include "psImage.h"
#include "psCoord.h"
#include "psStats.h"
#include "psPolynomial.h"

// perform vector clip-fit based on significance of deviations
psPolynomial4D *psVectorChiClipFitPolynomial4D(
    psPolynomial4D *poly,               // Polynomial to fit
    psStats *stats,                     // Statistics to use in clipping
    const psVector *mask,               // Mask for input values
    psMaskType maskValue,               // Mask value
    const psVector *f,                  // Value of the function, f(x,y,z,t)
    const psVector *fErr,               // Error in the value
    const psVector *x,                  // x ordinate
    const psVector *y,                  // y ordinate
    const psVector *z,                  // z ordinate
    const psVector *t                   // t ordinate
);

// fit a 2D 2nd order polynomial to the 9 pixels centered on (x,y)
psPolynomial2D *psImageBicubeFit(const psImage *image, // Image to fit
                                 int x, int y // Pixels of centre of fit
                                );

// detemine the min(max) of the special 2D 2nd order polynomial
psPlane psImageBicubeMin(const psPolynomial2D *poly // The polynomial
                        );

#endif /* PS_POLY_UTILS_H */
