IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 13, 2004, 3:12:59 PM (22 years ago)
Author:
gusciora
Message:

bug-fixing and sync with the new psVector structs.

File:
1 edited

Legend:

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

    r674 r679  
    166166    if (maskVector != NULL) {
    167167        for (i=0;i<myVector->n;i++) {
    168             if (!(maskVal & maskVector->vec.i32[i])) {
     168            if (!(maskVal & maskVector->vec.ui8[i])) {
    169169                mean+= myVector->vec.f[i];
    170170                count++;
     
    172172        }
    173173        mean/= (float) count;
    174         return(mean);
    175174    } else {
    176175        for (i=0;i<myVector->n;i++) {
    177176            mean+= myVector->vec.f[i];
    178177        }
    179     }
    180     mean/= myVector->n;
     178        mean/= (float) myVector->n;
     179    }
    181180    return(mean);
    182181}
     
    189188    float max = -1e99;
    190189
     190    printf("COOL: p_psArrayMax()\n");
    191191    if (maskVector != NULL) {
    192192        for (i=0;i<myVector->n;i++) {
    193             if (!(maskVal & maskVector->vec.i32[i])) {
     193            if (!(maskVal & maskVector->vec.ui8[i])) {
    194194                if (myVector->vec.f[i] > max) {
    195                     max = maskVector->vec.i32[i];
     195                    max = myVector->vec.f[i];
    196196                }
    197197            }
     
    200200        for (i=0;i<myVector->n;i++) {
    201201            if (myVector->vec.f[i] > max) {
    202                 max = maskVector->vec.i32[i];
     202                max = myVector->vec.f[i];
    203203            }
    204204        }
     
    216216    if (maskVector != NULL) {
    217217        for (i=0;i<myVector->n;i++) {
    218             if (!(maskVal & maskVector->vec.i32[i])) {
     218            if (!(maskVal & maskVector->vec.ui8[i])) {
    219219                if (myVector->vec.f[i] < min) {
    220                     min = maskVector->vec.i32[i];
     220                    min = myVector->vec.f[i];
    221221                }
    222222            }
     
    225225        for (i=0;i<myVector->n;i++) {
    226226            if (myVector->vec.f[i] < min) {
    227                 min = maskVector->vec.i32[i];
     227                min = myVector->vec.f[i];
    228228            }
    229229        }
     
    244244    if (maskVector != NULL) {
    245245        for (i=0;i<myVector->n;i++) {
    246             if (!(maskVal & maskVector->vec.i32[i])) {
     246            if (!(maskVal & maskVector->vec.ui8[i])) {
    247247                numData++;
    248248            }
     
    277277        if (maskVector != NULL) {
    278278            for (i=0;i<myVector->n;i++) {
    279                 if (!(maskVal & maskVector->vec.i32[i])) {
     279                if (!(maskVal & maskVector->vec.ui8[i])) {
    280280                    unsortedVector->vec.f[count++] = maskVector->vec.f[i];
    281281                }
     
    319319}
    320320
    321 psStats *psArrayStats(const psVector *restrict myVector, // FLOAT
    322                       const psVector *restrict maskVector, // INT
     321/******************************************************************************
     322 
     323    NOTE: The current strategy is to implement everything assuming that all
     324    input data is of type PS_TYPE_FLOAT.  Once the basic code is in place,
     325    we will macro-ize everything and add PS_TYPE_UINT16 and PS_TYPE_DOUBLE.
     326 
     327 *****************************************************************************/
     328psStats *psArrayStats(const psVector *restrict myVector,
     329                      const psVector *restrict maskVector,
    323330                      unsigned int maskVal,
    324331                      psStats *stats)
     
    328335    newStruct = psStatsAlloc(stats->options);
    329336    if (myVector == NULL) {
    330         psError(__func__,
     337        psAbort(__func__,
    331338                "Input data array (myVector) was NULL.");
    332339    }
    333340
    334     if ((maskVector != NULL) &&
    335             (myVector->n != maskVector->n)) {
    336         psError(__func__, "Vector data and vector mask are of different sizes.");
     341    if (myVector->type.type != PS_TYPE_FLOAT) {
     342        psAbort(__func__,
     343                "Only data type PS_TYPE_FLOAT is currently supported.");
     344    }
     345
     346    if (maskVector != NULL) {
     347        if (myVector->n != maskVector->n) {
     348            psAbort(__func__,
     349                    "Vector data and vector mask are of different sizes.");
     350        }
     351        if (maskVector->type.type != PS_TYPE_UINT8) {
     352            psAbort(__func__,
     353                    "Vector mask must be type PS_TYPE_UINT8");
     354        }
    337355    }
    338356
     
    426444    //    OLD CODE: Should we check for an unknown option?
    427445    //    default:
    428     //        psError(__func__, "Unknown options 0x%x.\n", stats->options);
     446    //        psAbort(__func__, "Unknown options 0x%x.\n", stats->options);
    429447
    430448    return(newStruct);
Note: See TracChangeset for help on using the changeset viewer.