IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 5, 2004, 12:47:21 PM (22 years ago)
Author:
gusciora
Message:

Added macros in psConstants.h to check for NULL and mis-typed vectors.

File:
1 edited

Legend:

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

    r1928 r1963  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.63 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-09-29 19:52:53 $
     11 *  @version $Revision: 1.64 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-10-05 22:47:21 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    836836
    837837/*****************************************************************************
    838 p_psNormalizeVector(myData): this is a private function which normalizes the
     838p_psNormalizeVectorF32(myData): this is a private function which normalizes the
    839839elements of a vector to a range between 0.0 and 1.0.
    840840 *****************************************************************************/
    841 void p_psNormalizeVector(psVector* myData)
     841void p_psNormalizeVectorF32(psVector* myData)
    842842{
    843843    float min = (float)HUGE;
     
    867867p_psNormalizeVectorF64(myData): this is a private function which normalizes the
    868868elements of a vector to a range between -1.0 and 1.0.
    869  
    870 XXX: incorporate this into above
    871  
    872869XXX: 0-1 or -1:1?
    873870 *****************************************************************************/
    874871void p_psNormalizeVectorF64(psVector* myData)
    875872{
    876     float min = (float)HUGE;
    877     float max = (float)-HUGE;
    878     float range = 0.0;
     873    float min = (double)HUGE;
     874    float max = (double)-HUGE;
     875    double range = 0.0;
    879876    int i = 0;
    880877
     
    892889        myData->data.F64[i] = -1.0 + 2.0 *
    893890                              ((myData->data.F64[i] - min) / range);
     891    }
     892
     893    //    for (i = 0; i < myData->n; i++) {
     894    //        myData->data.F64[i] = (myData->data.F64[i] - 0.5 * (min + max)) /
     895    //                              (0.5 * (max - min));
     896    //    }
     897}
     898
     899void p_psNormalizeVector(psVector* myData)
     900{
     901    if (myData->type.type == PS_TYPE_F32) {
     902        p_psNormalizeVectorF32(myData);
     903    } else if (myData->type.type == PS_TYPE_F64) {
     904        p_psNormalizeVectorF64(myData);
     905    } else {
     906        psError(__func__, "Unalowable data type.\n");
    894907    }
    895908}
     
    11911204    // The following was necessary to fit a gaussian to the data, since
    11921205    // gaussian functions produce data between 0.0 and 1.0.
    1193     // p_psNormalizeVector(robustHistogramVector);
     1206    // p_psNormalizeVectorF32(robustHistogramVector);
    11941207
    11951208    /**************************************************************************
Note: See TracChangeset for help on using the changeset viewer.