IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 642


Ignore:
Timestamp:
May 11, 2004, 2:40:23 PM (22 years ago)
Author:
gusciora
Message:

I removed psImage.o temporarily (since it was not compiling).

Location:
trunk/psLib/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/dataManip/Makefile

    r633 r642  
    33endif
    44
    5 TARGET = psImage.o psStats.o libpsDataManip.a
     5#TARGET = psImage.o psStats.o libpsDataManip.a
     6TARGET = psStats.o libpsDataManip.a
    67
    78all: $(TARGET)
  • trunk/psLib/src/dataManip/psStats.c

    r563 r642  
    44#include <stdarg.h>
    55#include "pslib.h"
    6 //#include "psMemory.h"
    7 //#include "psTrace.h"
    8 //#include "psString.h"
    9 //#include "psError.h"
    10 #include "psArray.h"
     6#include "psMemory.h"
     7#include "psTrace.h"
     8#include "psString.h"
     9#include "psError.h"
     10/******************************************************************************
     11//#include "psArray.h"
     12 *****************************************************************************/
    1113#include "psStats.h"
    1214
     
    6567    numBins = 1 + ((upper - lower) / size);
    6668    newHist = (psHistogram *) psAlloc(sizeof(psHistogram));
    67     newHist->lower = psFloatArrayAlloc(numBins);
    68     newHist->upper = psFloatArrayAlloc(numBins);
    69     newHist->nums = psIntArrayAlloc(numBins);
     69    newHist->lower = psVectorAlloc(numBins, PS_TYPE_FLOAT);
     70    newHist->upper = psVectorAlloc(numBins, PS_TYPE_FLOAT);
     71    newHist->nums =  psVectorAlloc(numBins, PS_TYPE_INT);
    7072    newHist->minVal = lower;
    7173    newHist->maxVal = upper;
     
    7678}
    7779
    78 psHistogram *psHistogramAllocGeneric(const psFloatArray *restrict lower,
    79                                      const psFloatArray *restrict upper,
     80psHistogram *psHistogramAllocGeneric(const psVector *restrict lower,
     81                                     const psVector *restrict upper,
    8082                                     float minVal,
    8183                                     float maxVal)
     
    9092    numBins = lower->n;
    9193    newHist = (psHistogram *) psAlloc(sizeof(psHistogram));
    92     newHist->lower = psFloatArrayAlloc(numBins);
    93     newHist->upper = psFloatArrayAlloc(numBins);
     94    newHist->lower = psVectorAlloc(numBins, PS_TYPE_FLOAT);
     95    newHist->upper = psVectorAlloc(numBins, PS_TYPE_FLOAT);
    9496    for (i=0;i<numBins;i++) {
    95         newHist->lower->arr[i] = lower->arr[i];
    96         newHist->upper->arr[i] = upper->arr[i];
    97     }
    98     newHist->nums = psIntArrayAlloc(numBins);
     97        newHist->lower->vec.vecF[i] = lower->vec.vecF[i];
     98        newHist->upper->vec.vecF[i] = upper->vec.vecF[i];
     99    }
     100    newHist->nums = psVectorAlloc(numBins, PS_TYPE_INT);
    99101    newHist->minVal = minVal;
    100102    newHist->maxVal = maxVal;
     
    124126        myHist->maxNum
    125127 *****************************************************************************/
    126 psHistogram *psGetArrayHistogram(       psHistogram *restrict myHist,
    127                                         const psFloatArray *restrict myArray)
     128psHistogram *psGetArrayHistogram(psHistogram *restrict myHist,
     129                                 const psVector *restrict myVector)
    128130{
    129131    int i = 0;
     
    132134
    133135    binSize = (myHist->maxVal - myHist->minVal) / (float) myHist->nums->n;
    134     for (i=0;i<myArray->n;i++) {
    135         if (myArray->arr[i] < myHist->minVal) {
     136    for (i=0;i<myVector->n;i++) {
     137        if (myVector->vec.vecF[i] < myHist->minVal) {
    136138            myHist->minNum++;
    137         } else if (myArray->arr[i] > myHist->maxVal) {
     139        } else if (myVector->vec.vecF[i] > myHist->maxVal) {
    138140            myHist->maxNum++;
    139141        } else {
    140             binNum = (int) ((myArray->arr[i] - myHist->minVal) / binSize);
    141             if ((myArray->arr[i] >= myHist->lower->arr[i]) &&
    142                     (myArray->arr[i] <= myHist->upper->arr[i])) {
    143                 myHist->nums->arr[i]++;
     142            binNum = (int) ((myVector->vec.vecF[i] - myHist->minVal) / binSize);
     143            if ((myVector->vec.vecF[i] >= myHist->lower->vec.vecF[i]) &&
     144                    (myVector->vec.vecF[i] <= myHist->upper->vec.vecF[i])) {
     145                myHist->nums->vec.vecI[i]++;
    144146            } else {
    145147                psError(__func__, "data value was not within the bounds of the bin it should habe been in.");
     
    153155    MISC STATISTICAL FUNCTIONS
    154156 *****************************************************************************/
    155 float p_psArraySampleMean(const psFloatArray *restrict myArray,
    156                           const psIntArray *restrict maskArray,
     157float p_psArraySampleMean(const psVector *restrict myVector,
     158                          const psVector *restrict maskVector,
    157159                          unsigned int maskVal)
    158160{
     
    160162    float mean = 0.0;
    161163
    162     if (maskArray != NULL) {
    163         for (i=0;i<myArray->n;i++) {
    164             if (!(maskVal & maskArray->arr[i])) {
    165                 mean+= maskArray->arr[i];
     164    if (maskVector != NULL) {
     165        for (i=0;i<myVector->n;i++) {
     166            if (!(maskVal & maskVector->vec.vecI[i])) {
     167                mean+= maskVector->vec.vecI[i];
    166168            }
    167169        }
    168170    } else {
    169         for (i=0;i<myArray->n;i++) {
    170             mean+= maskArray->arr[i];
     171        for (i=0;i<myVector->n;i++) {
     172            mean+= maskVector->vec.vecI[i];
    171173        }
    172174    }
     
    174176}
    175177
    176 float p_psArrayMax(const psFloatArray *restrict myArray,
    177                    const psIntArray *restrict maskArray,
     178float p_psArrayMax(const psVector *restrict myVector,
     179                   const psVector *restrict maskVector,
    178180                   unsigned int maskVal)
    179181{
     
    181183    float max = -1e99;
    182184
    183     if (maskArray != NULL) {
    184         for (i=0;i<myArray->n;i++) {
    185             if (!(maskVal & maskArray->arr[i])) {
    186                 if (myArray->arr[i] > max) {
    187                     max = maskArray->arr[i];
     185    if (maskVector != NULL) {
     186        for (i=0;i<myVector->n;i++) {
     187            if (!(maskVal & maskVector->vec.vecI[i])) {
     188                if (myVector->vec.vecF[i] > max) {
     189                    max = maskVector->vec.vecI[i];
    188190                }
    189191            }
    190192        }
    191193    } else {
    192         for (i=0;i<myArray->n;i++) {
    193             if (myArray->arr[i] > max) {
    194                 max = maskArray->arr[i];
     194        for (i=0;i<myVector->n;i++) {
     195            if (myVector->vec.vecF[i] > max) {
     196                max = maskVector->vec.vecI[i];
    195197            }
    196198        }
     
    199201}
    200202
    201 float p_psArrayMin(const psFloatArray *restrict myArray,
    202                    const psIntArray *restrict maskArray,
     203float p_psArrayMin(const psVector *restrict myVector, /* FLOATS */
     204                   const psVector *restrict maskVector, /* INTS */
    203205                   unsigned int maskVal)
    204206{
     
    206208    float min = 1e99;
    207209
    208     if (maskArray != NULL) {
    209         for (i=0;i<myArray->n;i++) {
    210             if (!(maskVal & maskArray->arr[i])) {
    211                 if (myArray->arr[i] < min) {
    212                     min = maskArray->arr[i];
     210    if (maskVector != NULL) {
     211        for (i=0;i<myVector->n;i++) {
     212            if (!(maskVal & maskVector->vec.vecI[i])) {
     213                if (myVector->vec.vecF[i] < min) {
     214                    min = maskVector->vec.vecI[i];
    213215                }
    214216            }
    215217        }
    216218    } else {
    217         for (i=0;i<myArray->n;i++) {
    218             if (myArray->arr[i] < min) {
    219                 min = maskArray->arr[i];
     219        for (i=0;i<myVector->n;i++) {
     220            if (myVector->vec.vecF[i] < min) {
     221                min = maskVector->vec.vecI[i];
    220222            }
    221223        }
     
    224226}
    225227
    226 int p_psArrayNValues(const psFloatArray *restrict myArray,
    227                      const psIntArray *restrict maskArray,
     228int p_psArrayNValues(const psVector *restrict myVector, // float
     229                     const psVector *restrict maskVector, // ints
    228230                     unsigned int maskVal)
    229231{
     
    231233    int numData = 0;
    232234
    233     if (maskArray != NULL) {
    234         for (i=0;i<myArray->n;i++) {
    235             if (!(maskVal & maskArray->arr[i])) {
     235    if (maskVector != NULL) {
     236        for (i=0;i<myVector->n;i++) {
     237            if (!(maskVal & maskVector->vec.vecI[i])) {
    236238                numData++;
    237239            }
    238240        }
    239241    } else {
    240         numData = myArray->n;
     242        numData = myVector->n;
    241243    }
    242244    return(numData);
    243245}
    244246
    245 psStats *psArrayStats(const psFloatArray *restrict myArray,
    246                       const psIntArray *restrict maskArray,
     247psStats *psArrayStats(const psVector *restrict myVector, // FLOAT
     248                      const psVector *restrict maskVector, // INT
    247249                      unsigned int maskVal,
    248250                      psStats *stats)
     
    251253
    252254    newStruct = psStatsAlloc(stats->options);
    253     if (myArray == NULL) {
     255    if (myVector == NULL) {
    254256        psError(__func__,
    255                 "Input data array (myArray) was NULL.");
    256     }
    257 
    258     if ((maskArray != NULL) &&
    259             (myArray->n != maskArray->n)) {
    260         psError(__func__, "Array data and array mask are of different sizes.");
     257                "Input data array (myVector) was NULL.");
     258    }
     259
     260    if ((maskVector != NULL) &&
     261            (myVector->n != maskVector->n)) {
     262        psError(__func__, "Vector data and vector mask are of different sizes.");
    261263    }
    262264
    263265    switch (stats->options) {
    264266    case PS_STAT_SAMPLE_MEAN:
    265         newStruct->max = p_psArraySampleMean(myArray, maskArray, maskVal);
     267        newStruct->max = p_psArraySampleMean(myVector, maskVector, maskVal);
    266268        break;
    267269    case PS_STAT_SAMPLE_MEDIAN:
     
    317319        break;
    318320    case PS_STAT_MAX:
    319         newStruct->max = p_psArrayMax(myArray, maskArray, maskVal);
     321        newStruct->max = p_psArrayMax(myVector, maskVector, maskVal);
    320322        break;
    321323    case PS_STAT_MIN:
    322         newStruct->min = p_psArrayMin(myArray, maskArray, maskVal);
     324        newStruct->min = p_psArrayMin(myVector, maskVector, maskVal);
    323325        break;
    324326    case PS_STAT_NVALUES:
    325         newStruct->nValues = p_psArrayNValues(myArray, maskArray, maskVal);
     327        newStruct->nValues = p_psArrayNValues(myVector, maskVector, maskVal);
    326328        break;
    327329    default:
  • trunk/psLib/src/dataManip/psStats.h

    r563 r642  
    66 *  \ingroup MathGroup
    77 */
     8
     9/******************************************************************************
     10    The following typedefs and functions belong in the psArray.h and psArray.c
     11    files.  However, those files are not available at this time, due to the
     12    changing definition of the psLib data/functions.  For temporary purposes
     13    only, I am including them here so that I can continue coding while our
     14    basic data types are still being implemented.
     15 *****************************************************************************/
     16typedef enum {
     17    PS_TYPE_CHAR,
     18    PS_TYPE_SHORT,
     19    PS_TYPE_INT,
     20    PS_TYPE_LONG,
     21    PS_TYPE_UCHAR,
     22    PS_TYPE_USHORT,
     23    PS_TYPE_UINT,
     24    PS_TYPE_ULONG,
     25    PS_TYPE_FLOAT,
     26    PS_TYPE_DOUBLE,
     27    PS_TYPE_COMPLEX,
     28    PS_TYPE_OTHER,
     29} psElemType;
     30
     31typedef enum {
     32    PS_DIMEN_SCALAR,
     33    PS_DIMEN_VECTOR,
     34    PS_DIMEN_TRANSV,
     35    PS_DIMEN_IMAGE,
     36    PS_DIMEN_OTHER
     37} psDimen;
     38
     39typedef struct
     40{
     41    psElemType type;
     42    psDimen dimen;
     43}
     44psType;
     45
     46typedef struct
     47{
     48    psType type;                ///< Type of data.
     49    int nalloc;                 ///< Total number of elements available.
     50    int n;                      ///< Number of elements in use.
     51
     52    union {
     53        int *vecI;
     54        float *vecF;
     55        double *vecD;
     56        //        complex float *vecC;
     57        void **vecP;
     58    }vec;                       ///< Union with array data.
     59}
     60psVector;
     61
     62psVector *psVectorAlloc(int        nalloc,
     63                        psElemType type)
     64{
     65    return(NULL);
     66}
     67
     68psVector *psVectorRealloc(psVector myVector,
     69                          int nalloc)
     70{
     71    return(NULL);
     72}
     73
     74void psVectorFree(psVector *restrict psArr)
     75{}
    876
    977/** statistics which may be calculated */
     
    65133/** Do Statistics on an array.  Returns a status value. \ingroup MathGroup */
    66134psStats *
    67 psArrayStats(const psFloatArray *restrict myArray, ///< Array to be analysed
    68              const psIntArray *restrict maskArray, ///< Ignore elements where (maskArray & maskVal) != 0
    69              ///< May be NULL
    70              unsigned int maskVal, ///< Only mask elements with one of these bits set in maskArray
     135psArrayStats(const psVector *restrict myVector, ///< Vector to be analysed
     136             // must be FLOAT
     137             const psVector *restrict maskVector, ///< Ignore elements where (maskVector & maskVal) != 0
     138             // must be INT or NULL
     139             unsigned int maskVal, ///< Only mask elements with one of these bits set in maskVector
    71140             psStats *stats  ///< stats structure defines stats to be calculated and how
    72141            );
     
    87156typedef struct
    88157{
    89     const psFloatArray *restrict lower; ///< Lower bounds for the bins
    90     const psFloatArray *restrict upper; ///< Upper bounds for the bins
    91     psIntArray *nums;   ///< Number in each of the bins
    92     float minVal, maxVal;  ///< Minimum and maximum values
    93     int minNum, maxNum;   ///< Number below the minimum and above the maximum
     158    const psVector *restrict lower; ///< Lower bounds for the bins (FLOAT)
     159    const psVector *restrict upper; ///< Upper bounds for the bins (FLOAT)
     160    psVector *nums;   ///< Number in each of the bins (INT)
     161    float minVal;
     162    float maxVal;  ///< Minimum and maximum values
     163    int minNum;
     164    int maxNum;   ///< Number below the minimum and above the maximum
    94165}
    95166psHistogram;
     
    104175/** Generic constructor \ingroup MathGroup */
    105176psHistogram *
    106 psHistogramAllocGeneric(const psFloatArray *restrict lower, ///< Lower bounds for the bins
    107                         const psFloatArray *restrict upper, ///< Upper bounds for the bins
     177psHistogramAllocGeneric(const psVector *restrict lower, ///< Lower bounds for the bins
     178                        const psVector *restrict upper, ///< Upper bounds for the bins
    108179                        float minVal, ///< Minimum value
    109180                        float maxVal ///< Maximum value
     
    119190psHistogram *
    120191psGetArrayHistogram(psHistogram *restrict myHist, ///< Histogram data
    121                     const psFloatArray *restrict myArray ///< Array to analyse
     192                    const psVector *restrict myVector ///< Vector to analyse
    122193                   );
    123194
  • trunk/psLib/src/math/psStats.c

    r563 r642  
    44#include <stdarg.h>
    55#include "pslib.h"
    6 //#include "psMemory.h"
    7 //#include "psTrace.h"
    8 //#include "psString.h"
    9 //#include "psError.h"
    10 #include "psArray.h"
     6#include "psMemory.h"
     7#include "psTrace.h"
     8#include "psString.h"
     9#include "psError.h"
     10/******************************************************************************
     11//#include "psArray.h"
     12 *****************************************************************************/
    1113#include "psStats.h"
    1214
     
    6567    numBins = 1 + ((upper - lower) / size);
    6668    newHist = (psHistogram *) psAlloc(sizeof(psHistogram));
    67     newHist->lower = psFloatArrayAlloc(numBins);
    68     newHist->upper = psFloatArrayAlloc(numBins);
    69     newHist->nums = psIntArrayAlloc(numBins);
     69    newHist->lower = psVectorAlloc(numBins, PS_TYPE_FLOAT);
     70    newHist->upper = psVectorAlloc(numBins, PS_TYPE_FLOAT);
     71    newHist->nums =  psVectorAlloc(numBins, PS_TYPE_INT);
    7072    newHist->minVal = lower;
    7173    newHist->maxVal = upper;
     
    7678}
    7779
    78 psHistogram *psHistogramAllocGeneric(const psFloatArray *restrict lower,
    79                                      const psFloatArray *restrict upper,
     80psHistogram *psHistogramAllocGeneric(const psVector *restrict lower,
     81                                     const psVector *restrict upper,
    8082                                     float minVal,
    8183                                     float maxVal)
     
    9092    numBins = lower->n;
    9193    newHist = (psHistogram *) psAlloc(sizeof(psHistogram));
    92     newHist->lower = psFloatArrayAlloc(numBins);
    93     newHist->upper = psFloatArrayAlloc(numBins);
     94    newHist->lower = psVectorAlloc(numBins, PS_TYPE_FLOAT);
     95    newHist->upper = psVectorAlloc(numBins, PS_TYPE_FLOAT);
    9496    for (i=0;i<numBins;i++) {
    95         newHist->lower->arr[i] = lower->arr[i];
    96         newHist->upper->arr[i] = upper->arr[i];
    97     }
    98     newHist->nums = psIntArrayAlloc(numBins);
     97        newHist->lower->vec.vecF[i] = lower->vec.vecF[i];
     98        newHist->upper->vec.vecF[i] = upper->vec.vecF[i];
     99    }
     100    newHist->nums = psVectorAlloc(numBins, PS_TYPE_INT);
    99101    newHist->minVal = minVal;
    100102    newHist->maxVal = maxVal;
     
    124126        myHist->maxNum
    125127 *****************************************************************************/
    126 psHistogram *psGetArrayHistogram(       psHistogram *restrict myHist,
    127                                         const psFloatArray *restrict myArray)
     128psHistogram *psGetArrayHistogram(psHistogram *restrict myHist,
     129                                 const psVector *restrict myVector)
    128130{
    129131    int i = 0;
     
    132134
    133135    binSize = (myHist->maxVal - myHist->minVal) / (float) myHist->nums->n;
    134     for (i=0;i<myArray->n;i++) {
    135         if (myArray->arr[i] < myHist->minVal) {
     136    for (i=0;i<myVector->n;i++) {
     137        if (myVector->vec.vecF[i] < myHist->minVal) {
    136138            myHist->minNum++;
    137         } else if (myArray->arr[i] > myHist->maxVal) {
     139        } else if (myVector->vec.vecF[i] > myHist->maxVal) {
    138140            myHist->maxNum++;
    139141        } else {
    140             binNum = (int) ((myArray->arr[i] - myHist->minVal) / binSize);
    141             if ((myArray->arr[i] >= myHist->lower->arr[i]) &&
    142                     (myArray->arr[i] <= myHist->upper->arr[i])) {
    143                 myHist->nums->arr[i]++;
     142            binNum = (int) ((myVector->vec.vecF[i] - myHist->minVal) / binSize);
     143            if ((myVector->vec.vecF[i] >= myHist->lower->vec.vecF[i]) &&
     144                    (myVector->vec.vecF[i] <= myHist->upper->vec.vecF[i])) {
     145                myHist->nums->vec.vecI[i]++;
    144146            } else {
    145147                psError(__func__, "data value was not within the bounds of the bin it should habe been in.");
     
    153155    MISC STATISTICAL FUNCTIONS
    154156 *****************************************************************************/
    155 float p_psArraySampleMean(const psFloatArray *restrict myArray,
    156                           const psIntArray *restrict maskArray,
     157float p_psArraySampleMean(const psVector *restrict myVector,
     158                          const psVector *restrict maskVector,
    157159                          unsigned int maskVal)
    158160{
     
    160162    float mean = 0.0;
    161163
    162     if (maskArray != NULL) {
    163         for (i=0;i<myArray->n;i++) {
    164             if (!(maskVal & maskArray->arr[i])) {
    165                 mean+= maskArray->arr[i];
     164    if (maskVector != NULL) {
     165        for (i=0;i<myVector->n;i++) {
     166            if (!(maskVal & maskVector->vec.vecI[i])) {
     167                mean+= maskVector->vec.vecI[i];
    166168            }
    167169        }
    168170    } else {
    169         for (i=0;i<myArray->n;i++) {
    170             mean+= maskArray->arr[i];
     171        for (i=0;i<myVector->n;i++) {
     172            mean+= maskVector->vec.vecI[i];
    171173        }
    172174    }
     
    174176}
    175177
    176 float p_psArrayMax(const psFloatArray *restrict myArray,
    177                    const psIntArray *restrict maskArray,
     178float p_psArrayMax(const psVector *restrict myVector,
     179                   const psVector *restrict maskVector,
    178180                   unsigned int maskVal)
    179181{
     
    181183    float max = -1e99;
    182184
    183     if (maskArray != NULL) {
    184         for (i=0;i<myArray->n;i++) {
    185             if (!(maskVal & maskArray->arr[i])) {
    186                 if (myArray->arr[i] > max) {
    187                     max = maskArray->arr[i];
     185    if (maskVector != NULL) {
     186        for (i=0;i<myVector->n;i++) {
     187            if (!(maskVal & maskVector->vec.vecI[i])) {
     188                if (myVector->vec.vecF[i] > max) {
     189                    max = maskVector->vec.vecI[i];
    188190                }
    189191            }
    190192        }
    191193    } else {
    192         for (i=0;i<myArray->n;i++) {
    193             if (myArray->arr[i] > max) {
    194                 max = maskArray->arr[i];
     194        for (i=0;i<myVector->n;i++) {
     195            if (myVector->vec.vecF[i] > max) {
     196                max = maskVector->vec.vecI[i];
    195197            }
    196198        }
     
    199201}
    200202
    201 float p_psArrayMin(const psFloatArray *restrict myArray,
    202                    const psIntArray *restrict maskArray,
     203float p_psArrayMin(const psVector *restrict myVector, /* FLOATS */
     204                   const psVector *restrict maskVector, /* INTS */
    203205                   unsigned int maskVal)
    204206{
     
    206208    float min = 1e99;
    207209
    208     if (maskArray != NULL) {
    209         for (i=0;i<myArray->n;i++) {
    210             if (!(maskVal & maskArray->arr[i])) {
    211                 if (myArray->arr[i] < min) {
    212                     min = maskArray->arr[i];
     210    if (maskVector != NULL) {
     211        for (i=0;i<myVector->n;i++) {
     212            if (!(maskVal & maskVector->vec.vecI[i])) {
     213                if (myVector->vec.vecF[i] < min) {
     214                    min = maskVector->vec.vecI[i];
    213215                }
    214216            }
    215217        }
    216218    } else {
    217         for (i=0;i<myArray->n;i++) {
    218             if (myArray->arr[i] < min) {
    219                 min = maskArray->arr[i];
     219        for (i=0;i<myVector->n;i++) {
     220            if (myVector->vec.vecF[i] < min) {
     221                min = maskVector->vec.vecI[i];
    220222            }
    221223        }
     
    224226}
    225227
    226 int p_psArrayNValues(const psFloatArray *restrict myArray,
    227                      const psIntArray *restrict maskArray,
     228int p_psArrayNValues(const psVector *restrict myVector, // float
     229                     const psVector *restrict maskVector, // ints
    228230                     unsigned int maskVal)
    229231{
     
    231233    int numData = 0;
    232234
    233     if (maskArray != NULL) {
    234         for (i=0;i<myArray->n;i++) {
    235             if (!(maskVal & maskArray->arr[i])) {
     235    if (maskVector != NULL) {
     236        for (i=0;i<myVector->n;i++) {
     237            if (!(maskVal & maskVector->vec.vecI[i])) {
    236238                numData++;
    237239            }
    238240        }
    239241    } else {
    240         numData = myArray->n;
     242        numData = myVector->n;
    241243    }
    242244    return(numData);
    243245}
    244246
    245 psStats *psArrayStats(const psFloatArray *restrict myArray,
    246                       const psIntArray *restrict maskArray,
     247psStats *psArrayStats(const psVector *restrict myVector, // FLOAT
     248                      const psVector *restrict maskVector, // INT
    247249                      unsigned int maskVal,
    248250                      psStats *stats)
     
    251253
    252254    newStruct = psStatsAlloc(stats->options);
    253     if (myArray == NULL) {
     255    if (myVector == NULL) {
    254256        psError(__func__,
    255                 "Input data array (myArray) was NULL.");
    256     }
    257 
    258     if ((maskArray != NULL) &&
    259             (myArray->n != maskArray->n)) {
    260         psError(__func__, "Array data and array mask are of different sizes.");
     257                "Input data array (myVector) was NULL.");
     258    }
     259
     260    if ((maskVector != NULL) &&
     261            (myVector->n != maskVector->n)) {
     262        psError(__func__, "Vector data and vector mask are of different sizes.");
    261263    }
    262264
    263265    switch (stats->options) {
    264266    case PS_STAT_SAMPLE_MEAN:
    265         newStruct->max = p_psArraySampleMean(myArray, maskArray, maskVal);
     267        newStruct->max = p_psArraySampleMean(myVector, maskVector, maskVal);
    266268        break;
    267269    case PS_STAT_SAMPLE_MEDIAN:
     
    317319        break;
    318320    case PS_STAT_MAX:
    319         newStruct->max = p_psArrayMax(myArray, maskArray, maskVal);
     321        newStruct->max = p_psArrayMax(myVector, maskVector, maskVal);
    320322        break;
    321323    case PS_STAT_MIN:
    322         newStruct->min = p_psArrayMin(myArray, maskArray, maskVal);
     324        newStruct->min = p_psArrayMin(myVector, maskVector, maskVal);
    323325        break;
    324326    case PS_STAT_NVALUES:
    325         newStruct->nValues = p_psArrayNValues(myArray, maskArray, maskVal);
     327        newStruct->nValues = p_psArrayNValues(myVector, maskVector, maskVal);
    326328        break;
    327329    default:
  • trunk/psLib/src/math/psStats.h

    r563 r642  
    66 *  \ingroup MathGroup
    77 */
     8
     9/******************************************************************************
     10    The following typedefs and functions belong in the psArray.h and psArray.c
     11    files.  However, those files are not available at this time, due to the
     12    changing definition of the psLib data/functions.  For temporary purposes
     13    only, I am including them here so that I can continue coding while our
     14    basic data types are still being implemented.
     15 *****************************************************************************/
     16typedef enum {
     17    PS_TYPE_CHAR,
     18    PS_TYPE_SHORT,
     19    PS_TYPE_INT,
     20    PS_TYPE_LONG,
     21    PS_TYPE_UCHAR,
     22    PS_TYPE_USHORT,
     23    PS_TYPE_UINT,
     24    PS_TYPE_ULONG,
     25    PS_TYPE_FLOAT,
     26    PS_TYPE_DOUBLE,
     27    PS_TYPE_COMPLEX,
     28    PS_TYPE_OTHER,
     29} psElemType;
     30
     31typedef enum {
     32    PS_DIMEN_SCALAR,
     33    PS_DIMEN_VECTOR,
     34    PS_DIMEN_TRANSV,
     35    PS_DIMEN_IMAGE,
     36    PS_DIMEN_OTHER
     37} psDimen;
     38
     39typedef struct
     40{
     41    psElemType type;
     42    psDimen dimen;
     43}
     44psType;
     45
     46typedef struct
     47{
     48    psType type;                ///< Type of data.
     49    int nalloc;                 ///< Total number of elements available.
     50    int n;                      ///< Number of elements in use.
     51
     52    union {
     53        int *vecI;
     54        float *vecF;
     55        double *vecD;
     56        //        complex float *vecC;
     57        void **vecP;
     58    }vec;                       ///< Union with array data.
     59}
     60psVector;
     61
     62psVector *psVectorAlloc(int        nalloc,
     63                        psElemType type)
     64{
     65    return(NULL);
     66}
     67
     68psVector *psVectorRealloc(psVector myVector,
     69                          int nalloc)
     70{
     71    return(NULL);
     72}
     73
     74void psVectorFree(psVector *restrict psArr)
     75{}
    876
    977/** statistics which may be calculated */
     
    65133/** Do Statistics on an array.  Returns a status value. \ingroup MathGroup */
    66134psStats *
    67 psArrayStats(const psFloatArray *restrict myArray, ///< Array to be analysed
    68              const psIntArray *restrict maskArray, ///< Ignore elements where (maskArray & maskVal) != 0
    69              ///< May be NULL
    70              unsigned int maskVal, ///< Only mask elements with one of these bits set in maskArray
     135psArrayStats(const psVector *restrict myVector, ///< Vector to be analysed
     136             // must be FLOAT
     137             const psVector *restrict maskVector, ///< Ignore elements where (maskVector & maskVal) != 0
     138             // must be INT or NULL
     139             unsigned int maskVal, ///< Only mask elements with one of these bits set in maskVector
    71140             psStats *stats  ///< stats structure defines stats to be calculated and how
    72141            );
     
    87156typedef struct
    88157{
    89     const psFloatArray *restrict lower; ///< Lower bounds for the bins
    90     const psFloatArray *restrict upper; ///< Upper bounds for the bins
    91     psIntArray *nums;   ///< Number in each of the bins
    92     float minVal, maxVal;  ///< Minimum and maximum values
    93     int minNum, maxNum;   ///< Number below the minimum and above the maximum
     158    const psVector *restrict lower; ///< Lower bounds for the bins (FLOAT)
     159    const psVector *restrict upper; ///< Upper bounds for the bins (FLOAT)
     160    psVector *nums;   ///< Number in each of the bins (INT)
     161    float minVal;
     162    float maxVal;  ///< Minimum and maximum values
     163    int minNum;
     164    int maxNum;   ///< Number below the minimum and above the maximum
    94165}
    95166psHistogram;
     
    104175/** Generic constructor \ingroup MathGroup */
    105176psHistogram *
    106 psHistogramAllocGeneric(const psFloatArray *restrict lower, ///< Lower bounds for the bins
    107                         const psFloatArray *restrict upper, ///< Upper bounds for the bins
     177psHistogramAllocGeneric(const psVector *restrict lower, ///< Lower bounds for the bins
     178                        const psVector *restrict upper, ///< Upper bounds for the bins
    108179                        float minVal, ///< Minimum value
    109180                        float maxVal ///< Maximum value
     
    119190psHistogram *
    120191psGetArrayHistogram(psHistogram *restrict myHist, ///< Histogram data
    121                     const psFloatArray *restrict myArray ///< Array to analyse
     192                    const psVector *restrict myVector ///< Vector to analyse
    122193                   );
    123194
Note: See TracChangeset for help on using the changeset viewer.