IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 12, 2004, 9:36:07 AM (22 years ago)
Author:
gusciora
Message:

Added a few macros to declare and allocate static persistant polynomials.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/math/psStats.c

    r2341 r2342  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.92 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-11-12 19:29:39 $
     11 *  @version $Revision: 1.93 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-11-12 19:36:07 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    925925 
    926926XXX: Should we make the arguments psScalars?
     927 
     928XXX: Should we make the arguments PS_TYPE_F64?
    927929 *****************************************************************************/
    928930#define PS_FUNC_MACRO_NORMALIZE_VECTOR_RANGE(TYPE) \
     
    983985XXX: Terminate when f(x)-getThisValue is within some error tolerance.
    984986 
    985 XXX: Solve for X analytically.
     987XXX: Create a 2nd-order polynomial version and solve for X analytically.
    986988 *****************************************************************************/
    987989float p_ps1DPolyMedian(psPolynomial1D* myPoly,
     
    10201022
    10211023/******************************************************************************
    1022 fitQuadraticSearchForYThenReturnX(*xVec, *yVec, binNum, yVal): This routine
    1023 takes psVectors of x/y pairs as input, and fits a quadratic to the 3 points
    1024 surrounding element binNum in the vectors (the midpoint between element i
    1025 and i+1 is used for x[i]).  It then determines for what value x does that
    1026 quadratic f(x) = yVal (the input parameter).
     1024fitQuadraticSearchForYThenReturnX(*xVec, *yVec, binNum, yVal): A general
     1025routine which fits a quadratic to three points and returns the x-value
     1026corresponding to the input y-value.  This routine takes psVectors of x/y pairs
     1027as input, and fits a quadratic to the 3 points surrounding element binNum in
     1028the vectors (the midpoint between element i and i+1 is used for x[i]).  It
     1029then determines for what value x does that quadratic f(x) = yVal (the input
     1030parameter).
    10271031 
    10281032XXX: After you fit the polynomial, solve for X analytically.
     
    10351039                                        float yVal)
    10361040{
     1041    PS_VECTOR_CHECK_NULL(xVec, NAN);
     1042    PS_VECTOR_CHECK_NULL(yVec, NAN);
     1043    PS_VECTOR_CHECK_TYPE(xVec, PS_TYPE_F64, NAN);
     1044    PS_VECTOR_CHECK_TYPE(yVec, PS_TYPE_F64, NAN);
     1045    PS_VECTOR_CHECK_SIZE_EQUAL(xVec, yVec, NAN);
     1046    PS_INT_CHECK_RANGE(binNum, 0, (xVec->n - 1), NAN);
     1047
    10371048    PS_VECTOR_DECLARE_ALLOC_STATIC(x, 3, PS_TYPE_F64);
    10381049    PS_VECTOR_DECLARE_ALLOC_STATIC(y, 3, PS_TYPE_F64);
    10391050    PS_VECTOR_DECLARE_ALLOC_STATIC(yErr, 3, PS_TYPE_F64);
    1040     static psPolynomial1D* myPoly = NULL;
    1041 
    1042     if (myPoly == NULL) {
    1043         myPoly = psPolynomial1DAlloc(2, PS_POLYNOMIAL_ORD);
    1044         p_psMemSetPersistent(myPoly, true);
    1045     }
     1051    PS_POLY_1D_DECLARE_ALLOC_STATIC(myPoly, 2, PS_POLYNOMIAL_ORD);
    10461052    float tmpFloat;
    10471053
    10481054    if ((binNum > 0) && (binNum < (yVec->n - 2))) {
     1055        // The general case.  We have all three points.
    10491056        x->data.F64[0] = (double) (0.5 * (xVec->data.F32[binNum - 1] + xVec->data.F32[binNum]));
    10501057        x->data.F64[1] = (double) (0.5 * (xVec->data.F32[binNum] + xVec->data.F32[binNum+1]));
     
    10701077        tmpFloat = p_ps1DPolyMedian(myPoly, x->data.F64[0], x->data.F64[2], yVal);
    10711078    } else {
     1079        // The special case where we have two points only at the beginning of
     1080        // the vectors x and y.
    10721081        if (binNum == 0) {
    10731082            tmpFloat = 0.5 * (xVec->data.F32[binNum] +
    10741083                              xVec->data.F32[binNum + 1]);
    10751084        } else if (binNum == (xVec->n - 1)) {
     1085            // The special case where we have two points only at the end of
     1086            // the vectors x and y.
    10761087            // XXX: Is this right?
    10771088            tmpFloat = xVec->data.F32[binNum];
Note: See TracChangeset for help on using the changeset viewer.