
/** @file  psScalar.h
 *
 *  @brief Contains basic scalar definitions and operations
 *
 *  This file defines the basic type for a scalar struct and functions useful
 *  in manupulating scalars.
 *
 *  @ingroup Scalar
 *
 *  @author Ross Harman, MHPCC
 *
 *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
 *  @date $Date: 2005-02-17 19:26:23 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
 */

#ifndef PS_SCALAR_H
#define PS_SCALAR_H

#include "psType.h"

/// @addtogroup Scalar
/// @{

/** Basic scalar data structure.
 *
 * Struct for maintaining a scalar of frequently used primitive types.
 *
 */
typedef struct
{
    psType type;                ///< Type of data.

    union {
        psU8 U8;                ///< Unsigned 8-bit integer data.
        psU16 U16;              ///< Unsigned 16-bit integer data.
        psU32 U32;              ///< Unsigned 32-bit integer data.
        psU64 U64;              ///< Unsigned 64-bit integer data.
        psS8 S8;                ///< Signed 8-bit integer data.
        psS16 S16;              ///< Signed 16-bit integer data.
        psS32 S32;              ///< Signed 32-bit integer data.
        psS64 S64;              ///< Signed 64-bit integer data.
        psF32 F32;              ///< Single-precision float data.
        psF64 F64;              ///< Double-precision float data.
        psC32 C32;              ///< Single-precision complex data.
        psC64 C64;              ///< Double-precision complex data.
    } data;                     ///< Union for data types.
}
psScalar;

/*****************************************************************************/

/* FUNCTION PROTOTYPES                                                       */

/*****************************************************************************/

/** Allocate a scalar.
 *
 * Uses psLib memory allocation functions to create scalar data as defined by the psType type.
 * Accepts a complex 64 bit float for input value, as max size, but resizes according to
 * correct type.
 *
 * @return psScalar*   Pointer to a new psScalar.
 */
psScalar* psScalarAlloc(
    psC64 value,                       ///< Data to be put into psScalar.
    psElemType dataType                ///< Type of data to be held by psScalar.
);

/** Copy a scalar.
 *
 * Uses psLib memory allocation functions to copy a scalar.
 *
 * @return psScalar*    A copy of the input scalar
 */
psScalar* psScalarCopy(
    psScalar *scalar                   ///< Scalar to copy.
);

/// @}

#endif
