
# ifndef PS_LIB_UTILS
# define PS_LIB_UTILS

// XXX EAM : psEllipse needs to be be included in psLib
# include "psEllipse.h"

// structure to carry a dynamic string
typedef struct
{
    int NLINE;
    int Nline;
    char *line;
}
psLine;

# define psMemCopy(A)(psMemIncrRefCounter((A)))

// XXX EAM : my version using varience instead of stdev
bool psMinimizeGaussNewtonDelta_EAM (psVector *delta,
                                     const psVector *params,
                                     const psVector *paramMask,
                                     const psArray  *x,
                                     const psVector *y,
                                     const psVector *yErr,
                                     psMinimizeLMChi2Func func);

// minimize : using varience vs sigma and parameter limits
psBool       p_psMinLM_GuessABP_EAM (psImage  *Alpha, psVector *Beta, psVector *Params, const psImage  *alpha, const psVector *beta, const psVector *params, const psVector *paramMask, const psVector *beta_lim, const psVector *params_min, const psVector *params_max, psF64 lambda);
psBool       psMinimizeLMChi2_EAM(psMinimization *min, psImage *covar, psVector *params, const psVector *paramMask, const psArray *x, const psVector *y, const psVector *yErr, psMinimizeLMChi2Func func);
psF64        p_psMinLM_dLinear (const psVector *Beta, const psVector *beta, psF64 lambda);

// psLib extra utilities
bool       psTimerStart (char *name);   // added to SDRS
//XXX: I removed this: bool       psTimerClear (char *name);   // added to SDRS
psF64       psTimerMark (char *name);    // added to SDRS
void       psTimerFree ();              // added to SDRS (as psTimerStop)
psS32       psLogArguments (int *argc, char **argv);   // added to SDRS (part of psArgumentVerbosity)
psS32       psTraceArguments (int *argc, char **argv); // added to SDRS (part of psArgumentVerbosity)
//XXX: remove: int      psArgumentGet (int argc, char **argv, char *arg); // added to SDRS
//XXX: remove: int      psArgumentRemove (int N, int *argc, char **argv); // added to SDRS
//XXX: remove: psVector    *psVectorCreate (double lower, double upper, double delta, psElemType type); // added to SDRS
// psVector    *psGetRowVectorFromImage(psImage *image, psU32 row); // added to SDRS (as psImageRow)
//XXX: remove: int          psImageCountPixelMask (psImage *mask, psU8 value); // added to SDRS

// basic image functions
bool         psImageInit (psImage *image,...); // added to SDRS (v.15)
void      psImageSmooth_EAM (psImage *image, float sigma, float Nsigma); // added to SDRS (v.15)

// psLine functions -- keep out for now?
psLine      *psLineAlloc (int Nline);
bool      psLineInit (psLine *line);
bool      psLineAdd (psLine *line, char *format, ...);

// not included in the .h file -- these are fairly lame, keep out?
bool p_psVectorPrint (int fd, psVector *a, char *name);
bool p_psVectorPrintRow (int fd, psVector *a, char *name);

# endif
