IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 486


Ignore:
Timestamp:
Apr 20, 2004, 2:40:32 PM (22 years ago)
Author:
harman
Message:

Added double array

Location:
trunk/psLib/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/collections/psArray.c

    r485 r486  
    88 *  @author Ross Harman, MHPCC
    99 *   
    10  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2004-04-21 00:18:05 $
     10 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2004-04-21 00:40:32 $
    1212 *
    1313 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1919#include "psMemory.h"
    2020#include "psArray.h"
    21 #include "psLogMsg.h"
    2221
    2322/******************************************************************************/
     
    5453/* FUNCTION IMPLEMENTATION - PUBLIC                                          */
    5554/*****************************************************************************/
     55
     56psIntArray* psIntArrayAlloc(int nalloc)
     57{
     58    psIntArray *psArr = (psIntArray*)p_psAlloc(sizeof(psIntArray), __FILE__, __LINE__);
     59    psArr->type.dimen = PS_DIMEN_VECTOR;
     60    psArr->type.type = PS_TYPE_INT;
     61    psArr->nalloc = nalloc;
     62    psArr->n = 0;
     63
     64    if(nalloc == 0) {
     65        psArr->arr = NULL;
     66    } else {
     67        psArr->arr = p_psAlloc(nalloc*sizeof(int), __FILE__, __LINE__);
     68    }
     69
     70    return psArr;
     71}
     72
     73psIntArray *psIntArrayRealloc(psIntArray *psArr, int nalloc)
     74{
     75    if(psArr == NULL) {
     76        return psIntArrayAlloc(nalloc);
     77    }
     78    if(nalloc <= psArr->nalloc) {
     79        if (psArr->n < nalloc) {
     80            psArr->n = nalloc;
     81        }
     82    } else {
     83        psArr->arr = p_psRealloc(psArr->arr, nalloc*sizeof(int), __FILE__, __LINE__);
     84        psArr->nalloc = nalloc;
     85    }
     86    return psArr;
     87}
     88
     89void psIntArrayFree(psIntArray *restrict psArr)
     90{
     91    if (psArr == NULL) {
     92        return;
     93    }
     94    p_psFree(psArr->arr, __FILE__, __LINE__);
     95    p_psFree(psArr, __FILE__, __LINE__);
     96}
    5697
    5798psFloatArray* psFloatArrayAlloc(int nalloc)
     
    97138}
    98139
    99 psIntArray* psIntArrayAlloc(int nalloc)
     140psDoubleArray* psDoubleArrayAlloc(int nalloc)
    100141{
    101     psIntArray *psArr = (psIntArray*)p_psAlloc(sizeof(psIntArray), __FILE__, __LINE__);
     142    psDoubleArray *psArr = (psDoubleArray*)p_psAlloc(sizeof(psDoubleArray), __FILE__, __LINE__);
    102143    psArr->type.dimen = PS_DIMEN_VECTOR;
    103     psArr->type.type = PS_TYPE_INT;
     144    psArr->type.type = PS_TYPE_DOUBLE;
    104145    psArr->nalloc = nalloc;
    105146    psArr->n = 0;
     
    108149        psArr->arr = NULL;
    109150    } else {
    110         psArr->arr = p_psAlloc(nalloc*sizeof(int), __FILE__, __LINE__);
     151        psArr->arr = p_psAlloc(nalloc*sizeof(double), __FILE__, __LINE__);
    111152    }
    112153
     
    114155}
    115156
    116 psIntArray *psIntArrayRealloc(psIntArray *psArr, int nalloc)
     157psDoubleArray *psDoubleArrayRealloc(psDoubleArray *psArr, int nalloc)
    117158{
    118159    if(psArr == NULL) {
    119         return psIntArrayAlloc(nalloc);
     160        return psDoubleArrayAlloc(nalloc);
    120161    }
    121162    if(nalloc <= psArr->nalloc) {
     
    124165        }
    125166    } else {
    126         psArr->arr = p_psRealloc(psArr->arr, nalloc*sizeof(int), __FILE__, __LINE__);
     167        psArr->arr = p_psRealloc(psArr->arr, nalloc*sizeof(double), __FILE__, __LINE__);
    127168        psArr->nalloc = nalloc;
    128169    }
     
    130171}
    131172
    132 void psIntArrayFree(psIntArray *restrict psArr)
     173void psDoubleArrayFree(psDoubleArray *restrict psArr)
    133174{
    134175    if (psArr == NULL) {
  • trunk/psLib/src/collections/psArray.h

    r485 r486  
    88 *  @author Ross Harman, MHPCC
    99 *   
    10  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2004-04-21 00:18:05 $
     10 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2004-04-21 00:40:32 $
    1212 *
    1313 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    9696typedef struct
    9797{
    98     psType type; ///< Type of data. THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT!
    99     int nalloc;  ///< Total number of elements available.
    100     int n;   ///< Number of elements in use.
    101     float *arr;  ///< Array data.
     98    psType type;    ///< Type of data. THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT!
     99    int nalloc;     ///< Total number of elements available.
     100    int n;          ///< Number of elements in use.
     101    float *arr;     ///< Array data.
    102102}
    103103psFloatArray;
     104
     105/** An array of doubles.
     106 *
     107 * Struct for maintaining an array of double precision floating point numbers.
     108 *
     109 */
     110typedef struct
     111{
     112    psType type;    ///< Type of data.  THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT!
     113    int nalloc;     ///< Total number of elements available.
     114    int n;          ///< Number of elements in use.
     115    double *arr;    ///< Array data.
     116}
     117psDoubleArray;
    104118
    105119/*****************************************************************************/
     
    107121/*****************************************************************************/
    108122
    109 /** Allocate an integer array */
     123/** Allocate an integer array.
     124 *
     125 * Uses psLib memory allocation functions to create an array of integers as defined by the psIntArray struct.
     126 *
     127 */
    110128psIntArray *psIntArrayAlloc(
    111129    int nalloc  ///< Total number of elements to make available
    112130);
    113131
    114 /** Reallocate an integer array */
     132/** Reallocate an integer array.
     133 *
     134 * Uses psLib memory allocation functions to reallocate an array of integers as defined by the psIntArray
     135 * struct.
     136 *
     137 */
    115138psIntArray *psIntArrayRealloc(
    116139    psIntArray *myArray,    ///< Array to reallocate.
     
    119142
    120143
    121 /** Deallocate an integer array */
     144/** Deallocate an integer array
     145 *
     146 * Uses psLib memory allocation functions to deallocate an array of integers as defined by the psIntArray
     147 * struct.
     148 *
     149 */
    122150void psIntArrayFree(
    123151    psIntArray *restrict myArray    ///< Array to free
     
    153181    psFloatArray *restrict myArray  ///< Array to free
    154182);
     183
     184/** Allocate a Double array.
     185 *
     186 * Uses psLib memory allocation functions to create an array of doubles as defined by the psDoubleArray
     187 * struct.
     188 *
     189 */
     190psDoubleArray *psDoubleArrayAlloc(
     191    int nalloc  ///< Total number of elements to make available.
     192);
     193
     194/** Reallocate a Double array.
     195 *
     196 * Uses psLib memory allocation functions to reallocate an array of Doubles as defined by the psDoubleArray
     197 * struct.
     198 *
     199 */
     200psDoubleArray *psDoubleArrayRealloc(
     201    psDoubleArray *myArray, ///< Array to reallocate.
     202    int nalloc              ///< Total number of elements to make available.
     203);
     204
     205/** Deallocate a Double array
     206 *
     207 * Uses psLib memory allocation functions to deallocate an array of doubles as defined by the psDoubleArray
     208 * struct.
     209 *
     210 */
     211void psDoubleArrayFree(
     212    psDoubleArray *restrict myArray  ///< Array to free
     213);
     214
     215
     216
     217
     218
     219
     220
    155221
    156222/** An array of complex numbers.
     
    182248
    183249
    184 /************************************************************************************************************/
    185 
    186 /** An array of double-precision real numbers */
    187 typedef struct
    188 {
    189     psType type;  ///< Type of data.  THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT!
    190     int nalloc;   ///< Total number of elements available
    191     int n;    ///< Number of elements in use
    192     double *arr;  ///< The array data
    193 }
    194 psDoubleArray;
    195 
    196 /** Constructor \ingroup DataGroup */
    197 psDoubleArray *psDoubleArrayAlloc(int nalloc) ///< Total number of elements to make available
    198 ;
    199 
    200 /** Reallocator \ingroup DataGroup */
    201 psDoubleArray *psDoubleArrayRealloc(psDoubleArray *myArray, ///< Array to reallocate
    202                                     int nalloc) ///< Total number of elements to make available
    203 ;
    204 
    205 /** Destructor \ingroup DataGroup */
    206 void psDoubleArrayFree(psDoubleArray *restrict myArray) ///< Array to free
    207 ;
     250
    208251
    209252/** Array of pointers to void.
  • trunk/psLib/src/collections/psSort.c

    r485 r486  
    1414 *  @author Ross Harman, MHPCC
    1515 *   
    16  *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    17  *  @date $Date: 2004-04-21 00:18:05 $
     16 *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     17 *  @date $Date: 2004-04-21 00:40:32 $
    1818 *
    1919 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    187187    }
    188188
    189     tmpFloatArray = psFloatArrayAlloc(inN, inN);
     189    tmpFloatArray = psFloatArrayAlloc(inN);
    190190    tmpFloatArray = psSort(tmpFloatArray, inArray);
    191191
  • trunk/psLib/src/types/psArray.c

    r485 r486  
    88 *  @author Ross Harman, MHPCC
    99 *   
    10  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2004-04-21 00:18:05 $
     10 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2004-04-21 00:40:32 $
    1212 *
    1313 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1919#include "psMemory.h"
    2020#include "psArray.h"
    21 #include "psLogMsg.h"
    2221
    2322/******************************************************************************/
     
    5453/* FUNCTION IMPLEMENTATION - PUBLIC                                          */
    5554/*****************************************************************************/
     55
     56psIntArray* psIntArrayAlloc(int nalloc)
     57{
     58    psIntArray *psArr = (psIntArray*)p_psAlloc(sizeof(psIntArray), __FILE__, __LINE__);
     59    psArr->type.dimen = PS_DIMEN_VECTOR;
     60    psArr->type.type = PS_TYPE_INT;
     61    psArr->nalloc = nalloc;
     62    psArr->n = 0;
     63
     64    if(nalloc == 0) {
     65        psArr->arr = NULL;
     66    } else {
     67        psArr->arr = p_psAlloc(nalloc*sizeof(int), __FILE__, __LINE__);
     68    }
     69
     70    return psArr;
     71}
     72
     73psIntArray *psIntArrayRealloc(psIntArray *psArr, int nalloc)
     74{
     75    if(psArr == NULL) {
     76        return psIntArrayAlloc(nalloc);
     77    }
     78    if(nalloc <= psArr->nalloc) {
     79        if (psArr->n < nalloc) {
     80            psArr->n = nalloc;
     81        }
     82    } else {
     83        psArr->arr = p_psRealloc(psArr->arr, nalloc*sizeof(int), __FILE__, __LINE__);
     84        psArr->nalloc = nalloc;
     85    }
     86    return psArr;
     87}
     88
     89void psIntArrayFree(psIntArray *restrict psArr)
     90{
     91    if (psArr == NULL) {
     92        return;
     93    }
     94    p_psFree(psArr->arr, __FILE__, __LINE__);
     95    p_psFree(psArr, __FILE__, __LINE__);
     96}
    5697
    5798psFloatArray* psFloatArrayAlloc(int nalloc)
     
    97138}
    98139
    99 psIntArray* psIntArrayAlloc(int nalloc)
     140psDoubleArray* psDoubleArrayAlloc(int nalloc)
    100141{
    101     psIntArray *psArr = (psIntArray*)p_psAlloc(sizeof(psIntArray), __FILE__, __LINE__);
     142    psDoubleArray *psArr = (psDoubleArray*)p_psAlloc(sizeof(psDoubleArray), __FILE__, __LINE__);
    102143    psArr->type.dimen = PS_DIMEN_VECTOR;
    103     psArr->type.type = PS_TYPE_INT;
     144    psArr->type.type = PS_TYPE_DOUBLE;
    104145    psArr->nalloc = nalloc;
    105146    psArr->n = 0;
     
    108149        psArr->arr = NULL;
    109150    } else {
    110         psArr->arr = p_psAlloc(nalloc*sizeof(int), __FILE__, __LINE__);
     151        psArr->arr = p_psAlloc(nalloc*sizeof(double), __FILE__, __LINE__);
    111152    }
    112153
     
    114155}
    115156
    116 psIntArray *psIntArrayRealloc(psIntArray *psArr, int nalloc)
     157psDoubleArray *psDoubleArrayRealloc(psDoubleArray *psArr, int nalloc)
    117158{
    118159    if(psArr == NULL) {
    119         return psIntArrayAlloc(nalloc);
     160        return psDoubleArrayAlloc(nalloc);
    120161    }
    121162    if(nalloc <= psArr->nalloc) {
     
    124165        }
    125166    } else {
    126         psArr->arr = p_psRealloc(psArr->arr, nalloc*sizeof(int), __FILE__, __LINE__);
     167        psArr->arr = p_psRealloc(psArr->arr, nalloc*sizeof(double), __FILE__, __LINE__);
    127168        psArr->nalloc = nalloc;
    128169    }
     
    130171}
    131172
    132 void psIntArrayFree(psIntArray *restrict psArr)
     173void psDoubleArrayFree(psDoubleArray *restrict psArr)
    133174{
    134175    if (psArr == NULL) {
  • trunk/psLib/src/types/psArray.h

    r485 r486  
    88 *  @author Ross Harman, MHPCC
    99 *   
    10  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2004-04-21 00:18:05 $
     10 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2004-04-21 00:40:32 $
    1212 *
    1313 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    9696typedef struct
    9797{
    98     psType type; ///< Type of data. THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT!
    99     int nalloc;  ///< Total number of elements available.
    100     int n;   ///< Number of elements in use.
    101     float *arr;  ///< Array data.
     98    psType type;    ///< Type of data. THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT!
     99    int nalloc;     ///< Total number of elements available.
     100    int n;          ///< Number of elements in use.
     101    float *arr;     ///< Array data.
    102102}
    103103psFloatArray;
     104
     105/** An array of doubles.
     106 *
     107 * Struct for maintaining an array of double precision floating point numbers.
     108 *
     109 */
     110typedef struct
     111{
     112    psType type;    ///< Type of data.  THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT!
     113    int nalloc;     ///< Total number of elements available.
     114    int n;          ///< Number of elements in use.
     115    double *arr;    ///< Array data.
     116}
     117psDoubleArray;
    104118
    105119/*****************************************************************************/
     
    107121/*****************************************************************************/
    108122
    109 /** Allocate an integer array */
     123/** Allocate an integer array.
     124 *
     125 * Uses psLib memory allocation functions to create an array of integers as defined by the psIntArray struct.
     126 *
     127 */
    110128psIntArray *psIntArrayAlloc(
    111129    int nalloc  ///< Total number of elements to make available
    112130);
    113131
    114 /** Reallocate an integer array */
     132/** Reallocate an integer array.
     133 *
     134 * Uses psLib memory allocation functions to reallocate an array of integers as defined by the psIntArray
     135 * struct.
     136 *
     137 */
    115138psIntArray *psIntArrayRealloc(
    116139    psIntArray *myArray,    ///< Array to reallocate.
     
    119142
    120143
    121 /** Deallocate an integer array */
     144/** Deallocate an integer array
     145 *
     146 * Uses psLib memory allocation functions to deallocate an array of integers as defined by the psIntArray
     147 * struct.
     148 *
     149 */
    122150void psIntArrayFree(
    123151    psIntArray *restrict myArray    ///< Array to free
     
    153181    psFloatArray *restrict myArray  ///< Array to free
    154182);
     183
     184/** Allocate a Double array.
     185 *
     186 * Uses psLib memory allocation functions to create an array of doubles as defined by the psDoubleArray
     187 * struct.
     188 *
     189 */
     190psDoubleArray *psDoubleArrayAlloc(
     191    int nalloc  ///< Total number of elements to make available.
     192);
     193
     194/** Reallocate a Double array.
     195 *
     196 * Uses psLib memory allocation functions to reallocate an array of Doubles as defined by the psDoubleArray
     197 * struct.
     198 *
     199 */
     200psDoubleArray *psDoubleArrayRealloc(
     201    psDoubleArray *myArray, ///< Array to reallocate.
     202    int nalloc              ///< Total number of elements to make available.
     203);
     204
     205/** Deallocate a Double array
     206 *
     207 * Uses psLib memory allocation functions to deallocate an array of doubles as defined by the psDoubleArray
     208 * struct.
     209 *
     210 */
     211void psDoubleArrayFree(
     212    psDoubleArray *restrict myArray  ///< Array to free
     213);
     214
     215
     216
     217
     218
     219
     220
    155221
    156222/** An array of complex numbers.
     
    182248
    183249
    184 /************************************************************************************************************/
    185 
    186 /** An array of double-precision real numbers */
    187 typedef struct
    188 {
    189     psType type;  ///< Type of data.  THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT!
    190     int nalloc;   ///< Total number of elements available
    191     int n;    ///< Number of elements in use
    192     double *arr;  ///< The array data
    193 }
    194 psDoubleArray;
    195 
    196 /** Constructor \ingroup DataGroup */
    197 psDoubleArray *psDoubleArrayAlloc(int nalloc) ///< Total number of elements to make available
    198 ;
    199 
    200 /** Reallocator \ingroup DataGroup */
    201 psDoubleArray *psDoubleArrayRealloc(psDoubleArray *myArray, ///< Array to reallocate
    202                                     int nalloc) ///< Total number of elements to make available
    203 ;
    204 
    205 /** Destructor \ingroup DataGroup */
    206 void psDoubleArrayFree(psDoubleArray *restrict myArray) ///< Array to free
    207 ;
     250
    208251
    209252/** Array of pointers to void.
Note: See TracChangeset for help on using the changeset viewer.