psScalar.h

Go to the documentation of this file.
00001 /* @file  psScalar.h
00002  * @brief Basic scalar definitions and operations
00003  *
00004  * This file defines the basic type for a scalar struct and functions useful
00005  * in manupulating scalars.
00006  *
00007  * @author Ross Harman, MHPCC
00008  *
00009  * @version $Revision: 1.21 $ $Name:  $
00010  * @date $Date: 2007/01/23 22:47:23 $
00011  * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
00012  */
00013 
00014 #ifndef PS_SCALAR_H
00015 #define PS_SCALAR_H
00016 
00017 /// @addtogroup MathOps Mathematical Operations
00018 /// @{
00019 
00020 #include "psType.h"
00021 
00022 /** Basic scalar data structure.
00023  *
00024  * Struct for maintaining a scalar of frequently used primitive types.
00025  *
00026  */
00027 typedef struct
00028 {
00029     psMathType type;            ///< Type of data.
00030 
00031     union {
00032         psS8 S8;                ///< Signed 8-bit integer data.
00033         psS16 S16;              ///< Signed 16-bit integer data.
00034         psS32 S32;              ///< Signed 32-bit integer data.
00035         psS64 S64;              ///< Signed 64-bit integer data.
00036         psU8 U8;                ///< Unsigned 8-bit integer data.
00037         psU16 U16;              ///< Unsigned 16-bit integer data.
00038         psU32 U32;              ///< Unsigned 32-bit integer data.
00039         psU64 U64;              ///< Unsigned 64-bit integer data.
00040         psF32 F32;              ///< Single-precision float data.
00041         psF64 F64;              ///< Double-precision float data.
00042         psC32 C32;              ///< Single-precision complex data.
00043         psC64 C64;              ///< Double-precision complex data.
00044     } data;                     ///< Union for data types.
00045 }
00046 psScalar;
00047 
00048 /*****************************************************************************/
00049 
00050 /* FUNCTION PROTOTYPES                                                       */
00051 
00052 /*****************************************************************************/
00053 
00054 /** Allocate a scalar.
00055  *
00056  * Uses psLib memory allocation functions to create scalar data as defined by the psType type.
00057  * Accepts a complex 64 bit float for input value, as max size, but resizes according to
00058  * correct type.
00059  *
00060  * @return psScalar*   Pointer to a new psScalar.
00061  */
00062 psScalar* psScalarAlloc(
00063     double complex value,              ///< Data to be put into psScalar.
00064     psElemType type                    ///< Type of data to be held by psScalar.
00065 );
00066 
00067 
00068 /** Checks the type of a particular pointer.
00069  *
00070  *  Uses the appropriate deallocation function in psMemBlock to check the ptr datatype.
00071  *
00072  *  @return bool:       True if the pointer matches a psScalar structure, false otherwise.
00073  */
00074 bool psMemCheckScalar(
00075     psPtr ptr                          ///< the pointer whose type to check
00076 );
00077 
00078 
00079 /** Copy a scalar.
00080  *
00081  * Uses psLib memory allocation functions to copy a scalar.
00082  *
00083  * @return psScalar*    A copy of the input scalar
00084  */
00085 psScalar* psScalarCopy(
00086     const psScalar *value              ///< Scalar to copy.
00087 );
00088 
00089 /// @}
00090 #endif // #ifndef PS_SCALAR_H

Generated on Fri Feb 2 22:24:35 2007 for pslib by  doxygen 1.5.1