IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 10, 2004, 4:04:48 PM (22 years ago)
Author:
Paul Price
Message:

Expanded out the array definitions.
Added psType, for use in vector, matrix arithmetic etc.
Defined a psVector as a psFloatArray.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/archive/pslib/include/psStdArrays.h

    r206 r210  
    1919    PS_TYPE_DOUBLE,                     //!< Double-precision floating point
    2020    PS_TYPE_COMPLEX                     //!< Complex numbers consisting of floating point
     21    PS_TYPE_OTHER                       //!< Something else that's not supported for arithmetic
    2122} psElemType;
    2223
     
    2526    PS_DIMEN_SCALAR,                    //!< Scalar
    2627    PS_DIMEN_VECTOR,                    //!< A vector
    27     PS_DIMEN_MATRIX                     //!< A matrix
     28    PS_DIMEN_MATRIX,                    //!< A matrix
     29    PS_DIMEN_OTHER                      //!< Something else that's not supported for arithmetic
    2830} psDimen;
    2931
     
    3436} psType;
    3537
     38/************************************************************************************************************/
     39
    3640/**
    37  * ps- typedefs so that array names comply with the standard naming convention. These should NOT be used
    38  * generally.
     41 * ps- typedefs. These should NOT be used generally, but only where the number of bits in a type must be
     42 * guaranteed, or for use in macros to preserve the standard naming conventions.
    3943 */
    4044typedef float          psFloat;         ///< BITPIX -32 (float)
     
    6367typedef uint64_t       psUlong;         
    6468
     69/************************************************************************************************************/
     70
    6571/** An array of real numbers */
    66 PS_DECLARE_ARRAY_TYPE(psFloat);
    67 PS_CREATE_ARRAY_TYPE(psFloat);
     72typedef struct {
     73    enum psType type;                   //!< Type of data.  THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT!
     74    int size;                           //!< Total number of elements available
     75    int n;                              //!< Number of elements in use
     76    float *arr;                         //!< The array data
     77} psFloatArray;
     78
     79/** Constructor */
     80psFloatArray *psFloatArrayAlloc(int s,  //!< Total number of elements to make available
     81                                int n   //!< Number of elements that will be used
     82    );
     83/** Reallocator */
     84psFloatArray *psFloatArrayRealloc(psFloatArray *myArray, //!< Array to reallocate
     85                                  int s //!< Total number of elements to make available
     86    );
     87/** Destructor */
     88void psFloatArrayFree(psFloatArray *restrict myArray //!< Array to free
     89    );
     90
     91/************************************************************************************************************/
    6892
    6993/** Define a vector as an array of real numbers */
    7094typedef psFloatArray psVector;
     95#define psVectorAlloc(S,N) psFloatArrayAlloc(S,N) //!< Constructor
     96#define psVectorRealloc(A,S) psFloatArrayRealloc(A,S) //!< Reallocator
     97#define psVectorFree(A) psFloatArrayFree(A) //!< Destructor
     98
     99/************************************************************************************************************/
    71100
    72101/** An array of complex numbers */
    73 PS_DECLARE_ARRAY_TYPE(psComplex);
     102typedef struct {
     103    enum psType type;                   //!< Type of data.  THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT!
     104    int size;                           //!< Total number of elements available
     105    int n;                              //!< Number of elements in use
     106    complex float *arr;                 //!< The array data
     107} psComplexArray;
     108
     109/** Constructor */
     110psComplexArray *psComplexArrayAlloc(int s, //!< Total number of elements to make available
     111                                    int n       //!< Number of elements that will be used
     112    );
     113/** Reallocator */
     114psComplexArray *psComplexArrayRealloc(psComplexArray *myArray, //!< Array to reallocate
     115                                      int s     //!< Total number of elements to make available
     116    );
     117/** Destructor */
     118void psComplexArrayFree(psComplexArray *restrict myArray //!< Array to free
     119    );
     120
     121/************************************************************************************************************/
    74122
    75123/** An array of integers */
    76 PS_DECLARE_ARRAY_TYPE(psInt);
     124typedef struct {
     125    enum psType type;                   //!< Type of data.  THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT!
     126    int size;                           //!< Total number of elements available
     127    int n;                              //!< Number of elements in use
     128    int *arr;                           //!< The array data
     129} psIntArray;
     130
     131/** Constructor */
     132psIntArray *psIntArrayAlloc(int s,      //!< Total number of elements to make available
     133                            int n       //!< Number of elements that will be used
     134    );
     135/** Reallocator */
     136psIntArray *psIntArrayRealloc(psIntArray *myArray, //!< Array to reallocate
     137                              int s     //!< Total number of elements to make available
     138    );
     139/** Destructor */
     140void psIntArrayFree(psIntArray *restrict myArray //!< Array to free
     141    );
     142
     143/************************************************************************************************************/
    77144
    78145/** An array of double-precision real numbers */
    79 PS_DECLARE_ARRAY_TYPE(psDouble);
     146typedef struct {
     147    enum psType type;                   //!< Type of data.  THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT!
     148    int size;                           //!< Total number of elements available
     149    int n;                              //!< Number of elements in use
     150    double *arr;                        //!< The array data
     151} psDoubleArray;
    80152
    81 PS_DECLARE_ARRAY_TYPE(psFloatArray);    ///< Declare an array of real vectors (psFloatArrayArray).
     153/** Constructor */
     154psDoubleArray *psDoubleArrayAlloc(int s, //!< Total number of elements to make available
     155                                  int n //!< Number of elements that will be used
     156    );
     157/** Reallocator */
     158psDoubleArray *psDoubleArrayRealloc(psDoubleArray *myArray, //!< Array to reallocate
     159                                    int s       //!< Total number of elements to make available
     160    );
     161/** Destructor */
     162void psDoubleArrayFree(psDoubleArray *restrict myArray //!< Array to free
     163    );
     164
     165/************************************************************************************************************/
     166
     167/** An array of real vectors */
     168typedef struct {
     169    enum psType type;                   //!< Type of data.  THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT!
     170    int size;                           //!< Total number of elements available
     171    int n;                              //!< Number of elements in use
     172    psFloatArray *arr;                  //!< The array data
     173} psVectorArray;
     174
     175/** Constructor */
     176psVectorArray *psVectorArrayAlloc(int s, //!< Total number of elements to make available
     177                                  int n //!< Number of elements that will be used
     178    );
     179/** Reallocator */
     180psVectorArray *psVectorArrayRealloc(psVectorArray *myArray, //!< Array to reallocate
     181                                    int s       //!< Total number of elements to make available
     182    );
     183/** Destructor */
     184void psVectorArrayFree(psVectorArray *restrict myArray //!< Array to free
     185    );
     186
     187/************************************************************************************************************/
    82188
    83189#endif
Note: See TracChangeset for help on using the changeset viewer.