/** @file psMathUtils.h
 *  @brief Standard Mathematical Functions.
 *  @ingroup GROUP00
 *
 *  This file contains standard math rotines.
 *
 *  @author GLG, MHPCC
 *
 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
 *  @date $Date: 2006-02-17 00:56:48 $
 *
 *  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(
    psVector *bins,                    ///< Array of non-decreasing values
    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,
    psVector *domain,                  ///< Domain (x coords) for interpolation
    psVector *range,                   ///< Range (y coords) for interpolation
    psS32 order,                       ///< Order of interpolation function
    psScalar *x                        ///< Location at which to evaluate
);

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

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

#endif // #ifndef PS_MATHUTILS_H

