HDF5 Extras  0.0.1
Convenience Functions for using HDF5 Better
Macros | Functions | Variables
GS_DataConversion.c File Reference
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <limits.h>
#include <float.h>
#include <math.h>
#include <complex.h>
#include "bstrlib.h"
#include "gmalloc.h"
#include "H5ATTR.h"
#include "globals.h"

Macros

#define RMIN   0
 
#define RMAX   1
 

Functions

int GS_InitializeNumberRanges (void)
 GS_InitializeNumberRanges initializes ranges for various types. More...
 
int GS_DataConversion (int in_type, const void *in_buffer, int out_type, void *out_buffer, int nelements)
 GS_DataConversion converts a data buffer between different types. More...
 

Variables

long int intranges [GS_DATATYPE_MAX+1][2]
 
double floatranges [GS_DATATYPE_MAX+1][2]
 

Function Documentation

int GS_DataConversion ( int  in_type,
const void *  in_buffer,
int  out_type,
void *  out_buffer,
int  nelements 
)

GS_DataConversion converts a data buffer between different types.

See also
GS_DatasetOpen(), GS_DatasetCreate(), GS_DatasetRead()
Parameters
[in]in_typeThe type of data in in_buffer. The valid datatypes are: GS_DATATYPE_UI1 (Unsigned Integer, 1-bit)
GS_DATATYPE_UI8 (Unsigned Integer, 8-bit)
GS_DATATYPE_SI8 (Signed Integer, 8-bit)
GS_DATATYPE_CI8 (Complex Integer, 8-bit (not supported))
GS_DATATYPE_UI16 (Unsigned Integer, 16-bit)
GS_DATATYPE_SI16 (Signed Integer, 16-bit)
GS_DATATYPE_CI16 (Complex Integer, 16-bit)
GS_DATATYPE_UI32 (Unsigned Integer, 32-bit)
GS_DATATYPE_SI32 (Signed Integer, 32-bit)
GS_DATATYPE_CI32 (Complex Integer, 32-bit)
GS_DATATYPE_CI64 (Complex Integer, 64-bit)
GS_DATATYPE_R32 (Real, 32-bit)
GS_DATATYPE_R64 (Real, 64-bit)
GS_DATATYPE_C64 (Complex, 64-bit)
GS_DATATYPE_C128 (Complex, 128-bit)
GS_DATATYPE_UI64 (Unsigned Integer, 64-bit)
GS_DATATYPE_SI64 (Signed Integer, 64-bit)
[in]in_bufferThe data we want to convert to a different type.
[in]out_typeThe type of data we want in out_buffer. Same valid datatypes as in in_type.
[in]out_bufferThe destination of the converted data from in_buffer.
[in]nelementsThe number of elements to convert.
Returns
TRUE on sucess, FALSE on failure.
Example
We have a buffer that is 1000 ints, and we'd like to convert it to doubles.
1 int inbuf[1000];
2 double outbuf[1000];
3 if(!GS_DataConversion(GS_DATATYPE_SI32,inbuf,
4  GS_DATATYPE_R64, outbuf,1000)){
5  printf("data conversion failed\n");
6 }
7 ...here use outbuf...
Details
YET: data type conversions....
int GS_InitializeNumberRanges ( void  )

GS_InitializeNumberRanges initializes ranges for various types.

GS_InitializeNumberRanges() initializes the ranges for each of the scalar number types used in GeoSci. This is needed during type conversions to avoid creating variables whose value is out-of-range.

See also
GS_DataConversion()
Returns
Returns TRUE on success, FALSE on failure.
Details
Initializes global variables intranges and floatranges to contain the minimum and maximum numbers possible for each datatype that GeoSci supports.