/** @file psMathUtils.h
 *  @brief Standard Mathematical Functions.
 *  @ingroup GROUP00
 *
 *  This file contains standard math rotines.
 *
 *  @author GLG, MHPCC
 *
 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
 *  @date $Date: 2006-05-18 01:20:51 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
 */

#ifndef PS_MATHUTILS_H
#define PS_MATHUTILS_H

#include <stdio.h>
#include <stdbool.h>
#include <float.h>
#include <math.h>
#include "psVector.h"
#include "psScalar.h"
#include "psPolynomial.h"

/** \addtogroup GROUP00
 *  \{
 */

/** Performs a binary disection on a monotonically non-decreasing vector.
 *  Searches through an array of data for a specified value.
 *
 *  @return psS32    corresponding index number of specified value
 */
psS32 p_psVectorBinDisect(
    const psVector *bins,               ///< Array of non-decreasing values
    const psScalar *x                   ///< Target value to find
);

/** Interpolates a series of data points for evaluation at a specific coordinate.  Uses a
 *  Lagrange interpolation method.
 *
 *  @return psScalar*    Lagrange interpolation value at given location
 */
psScalar *p_psVectorInterpolate(
    psScalar *out,                      ///< Output scalar, or NULL
    const psVector *domain,             ///< Domain (x coords) for interpolation
    const psVector *range,              ///< Range (y coords) for interpolation
    psS32 order,                        ///< Order of interpolation function
    const psScalar *x                   ///< Location at which to evaluate
);

bool p_psNormalizeVectorRange(psVector* myData,
                              psF64 outLow,
                              psF64 outHigh);

/** \} */ // End of MathGroup Functions

#endif // #ifndef PS_MATHUTILS_H

