IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

Brought psStats.c up-to-date with the new psVector.

File:
1 edited

Legend:

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

    r660 r674  
    55/******************************************************************************
    66//#include "pslib.h"
    7 //#include "psMemory.h"
     7#include "psMemory.h"
     8#include "psVector.h"
    89//#include "psTrace.h"
    910//#include "psString.h"
     
    6364    psHistogram *newHist = NULL;
    6465    int numBins = 0;
    65     psType dummyFloatType;
    66     psType dummyIntType;
    67 
    68     dummyFloatType.type = PS_TYPE_FLOAT;
    69     dummyFloatType.dimen = PS_DIMEN_VECTOR;
    70     dummyIntType.type = PS_TYPE_FLOAT;
    71     dummyIntType.dimen = PS_DIMEN_VECTOR;
     66
    7267
    7368    numBins = 1 + ((upper - lower) / size);
    7469    newHist = (psHistogram *) psAlloc(sizeof(psHistogram));
    75     newHist->lower = psVectorAlloc(dummyFloatType, numBins);
    76     newHist->upper = psVectorAlloc(dummyFloatType, numBins);
    77     newHist->nums =  psVectorAlloc(dummyIntType, numBins);
     70    newHist->lower = psVectorAlloc(PS_TYPE_FLOAT, numBins);
     71    newHist->upper = psVectorAlloc(PS_TYPE_FLOAT, numBins);
     72    newHist->nums =  psVectorAlloc(PS_TYPE_INT32, numBins);
    7873    newHist->minVal = lower;
    7974    newHist->maxVal = upper;
     
    9287    int numBins = 0;
    9388    int i;
    94     psType dummyFloatType;
    95     psType dummyIntType;
    96 
    97     dummyFloatType.type = PS_TYPE_FLOAT;
    98     dummyFloatType.dimen = PS_DIMEN_VECTOR;
    99     dummyIntType.type = PS_TYPE_FLOAT;
    100     dummyIntType.dimen = PS_DIMEN_VECTOR;
    10189
    10290    if (lower->n != upper->n) {
     
    10593    numBins = lower->n;
    10694    newHist = (psHistogram *) psAlloc(sizeof(psHistogram));
    107     newHist->lower = psVectorAlloc(dummyFloatType, numBins);
    108     newHist->upper = psVectorAlloc(dummyFloatType, numBins);
     95    newHist->lower = psVectorAlloc(PS_TYPE_FLOAT, numBins);
     96    newHist->upper = psVectorAlloc(PS_TYPE_FLOAT, numBins);
    10997    for (i=0;i<numBins;i++) {
    11098        newHist->lower->vec.f[i] = lower->vec.f[i];
    11199        newHist->upper->vec.f[i] = upper->vec.f[i];
    112100    }
    113     newHist->nums = psVectorAlloc(dummyIntType, numBins);
     101    newHist->nums = psVectorAlloc(PS_TYPE_INT32, numBins);
    114102    newHist->minVal = minVal;
    115103    newHist->maxVal = maxVal;
     
    156144            if ((myVector->vec.f[i] >= myHist->lower->vec.f[i]) &&
    157145                    (myVector->vec.f[i] <= myHist->upper->vec.f[i])) {
    158                 myHist->nums->vec.i[i]++;
     146                myHist->nums->vec.i32[i]++;
    159147            } else {
    160148                psError(__func__, "data value was not within the bounds of the bin it should habe been in.");
     
    178166    if (maskVector != NULL) {
    179167        for (i=0;i<myVector->n;i++) {
    180             if (!(maskVal & maskVector->vec.i[i])) {
     168            if (!(maskVal & maskVector->vec.i32[i])) {
    181169                mean+= myVector->vec.f[i];
    182170                count++;
     
    203191    if (maskVector != NULL) {
    204192        for (i=0;i<myVector->n;i++) {
    205             if (!(maskVal & maskVector->vec.i[i])) {
     193            if (!(maskVal & maskVector->vec.i32[i])) {
    206194                if (myVector->vec.f[i] > max) {
    207                     max = maskVector->vec.i[i];
     195                    max = maskVector->vec.i32[i];
    208196                }
    209197            }
     
    212200        for (i=0;i<myVector->n;i++) {
    213201            if (myVector->vec.f[i] > max) {
    214                 max = maskVector->vec.i[i];
     202                max = maskVector->vec.i32[i];
    215203            }
    216204        }
     
    228216    if (maskVector != NULL) {
    229217        for (i=0;i<myVector->n;i++) {
    230             if (!(maskVal & maskVector->vec.i[i])) {
     218            if (!(maskVal & maskVector->vec.i32[i])) {
    231219                if (myVector->vec.f[i] < min) {
    232                     min = maskVector->vec.i[i];
     220                    min = maskVector->vec.i32[i];
    233221                }
    234222            }
     
    237225        for (i=0;i<myVector->n;i++) {
    238226            if (myVector->vec.f[i] < min) {
    239                 min = maskVector->vec.i[i];
     227                min = maskVector->vec.i32[i];
    240228            }
    241229        }
     
    256244    if (maskVector != NULL) {
    257245        for (i=0;i<myVector->n;i++) {
    258             if (!(maskVal & maskVector->vec.i[i])) {
     246            if (!(maskVal & maskVector->vec.i32[i])) {
    259247                numData++;
    260248            }
     
    275263    psVector *unsortedVector = NULL;
    276264    psVector *sortedVector = NULL;
    277     psType dummyFloatType;
    278265    int dataSize = 0;
    279266    int count = 0;
     
    281268    float median = 0.0;
    282269
    283     dummyFloatType.type = PS_TYPE_FLOAT;
    284     dummyFloatType.dimen = PS_DIMEN_VECTOR;
    285270    dataSize = p_psArrayNValues(myVector, maskVector, maskVal);
    286271
    287272    if (dataSize < MEDIAN_SIZE_THRESHOLD) {
    288         unsortedVector = psVectorAlloc(dummyFloatType, dataSize);
    289         sortedVector   = psVectorAlloc(dummyFloatType, dataSize);
     273        unsortedVector = psVectorAlloc(PS_TYPE_FLOAT, dataSize);
     274        sortedVector   = psVectorAlloc(PS_TYPE_FLOAT, dataSize);
    290275
    291276        count = 0;
    292277        if (maskVector != NULL) {
    293278            for (i=0;i<myVector->n;i++) {
    294                 if (!(maskVal & maskVector->vec.i[i])) {
     279                if (!(maskVal & maskVector->vec.i32[i])) {
    295280                    unsortedVector->vec.f[count++] = maskVector->vec.f[i];
    296281                }
Note: See TracChangeset for help on using the changeset viewer.