sundials_types.h

Go to the documentation of this file.
00001 /*
00002  * -----------------------------------------------------------------
00003  * $Revision: 1.2 $
00004  * $Date: 2006/11/29 00:05:07 $
00005  * ----------------------------------------------------------------- 
00006  * Programmer(s): Scott Cohen, Alan Hindmarsh, Radu Serban, and
00007  *                Aaron Collier @ LLNL
00008  * -----------------------------------------------------------------
00009  * Copyright (c) 2002, The Regents of the University of California.
00010  * Produced at the Lawrence Livermore National Laboratory.
00011  * All rights reserved.
00012  * For details, see the LICENSE file.
00013  *------------------------------------------------------------------
00014  * This header file exports two types: realtype and booleantype,
00015  * as well as the constants TRUE and FALSE.
00016  *
00017  * Users should include the header file sundials_types.h in every
00018  * program file and use the exported name realtype instead of
00019  * float, double or long double.
00020  *
00021  * The constants SUNDIALS_SINGLE_PRECISION, SUNDIALS_DOUBLE_PRECISION
00022  * and SUNDIALS_LONG_DOUBLE_PRECISION indicate the underlying data
00023  * type of realtype. It is set at the configuration stage.
00024  *
00025  * The legal types for realtype are float, double and long double.
00026  *
00027  * The macro RCONST gives the user a convenient way to define
00028  * real-valued constants. To use the constant 1.0, for example,
00029  * the user should write the following:
00030  *
00031  *   #define ONE RCONST(1.0)
00032  *
00033  * If realtype is defined as a double, then RCONST(1.0) expands
00034  * to 1.0. If realtype is defined as a float, then RCONST(1.0)
00035  * expands to 1.0F. If realtype is defined as a long double,
00036  * then RCONST(1.0) expands to 1.0L. There is never a need to
00037  * explicitly cast 1.0 to (realtype).
00038  *------------------------------------------------------------------
00039  */
00040   
00041 #ifndef _SUNDIALSTYPES_H
00042 #define _SUNDIALSTYPES_H
00043 
00044 #ifdef __cplusplus  /* wrapper to enable C++ usage */
00045 extern "C" {
00046 #endif
00047 
00048 #ifndef _SUNDIALS_CONFIG_H
00049 #define _SUNDIALS_CONFIG_H
00050 #include <sundials/sundials_config.h>
00051 #endif
00052 
00053 #include <float.h>
00054 
00055 /*
00056  *------------------------------------------------------------------
00057  * Type realtype
00058  * Macro RCONST
00059  * Constants BIG_REAL, SMALL_REAL, and UNIT_ROUNDOFF
00060  *------------------------------------------------------------------
00061  */
00062 
00063 #if defined(SUNDIALS_SINGLE_PRECISION)
00064 
00065 typedef float realtype;
00066 # define RCONST(x) x##F
00067 # define BIG_REAL FLT_MAX
00068 # define SMALL_REAL FLT_MIN
00069 # define UNIT_ROUNDOFF FLT_EPSILON
00070 
00071 #elif defined(SUNDIALS_DOUBLE_PRECISION)
00072 
00073 typedef double realtype;
00074 # define RCONST(x) x
00075 # define BIG_REAL DBL_MAX
00076 # define SMALL_REAL DBL_MIN
00077 # define UNIT_ROUNDOFF DBL_EPSILON
00078 
00079 #elif defined(SUNDIALS_EXTENDED_PRECISION)
00080 
00081 typedef long double realtype;
00082 # define RCONST(x) x##L
00083 # define BIG_REAL LDBL_MAX
00084 # define SMALL_REAL LDBL_MIN
00085 # define UNIT_ROUNDOFF LDBL_EPSILON
00086 
00087 #endif
00088 
00089 /*
00090  *------------------------------------------------------------------
00091  * Type : booleantype
00092  *------------------------------------------------------------------
00093  * Constants : FALSE and TRUE
00094  *------------------------------------------------------------------
00095  * ANSI C does not have a built-in boolean data type. Below is the
00096  * definition for a new type called booleantype. The advantage of
00097  * using the name booleantype (instead of int) is an increase in
00098  * code readability. It also allows the programmer to make a
00099  * distinction between int and boolean data. Variables of type
00100  * booleantype are intended to have only the two values FALSE and
00101  * TRUE which are defined below to be equal to 0 and 1,
00102  * respectively.
00103  *------------------------------------------------------------------
00104  */
00105 
00106 #ifndef booleantype
00107 #define booleantype int
00108 #endif
00109 
00110 #ifndef FALSE
00111 #define FALSE 0
00112 #endif
00113 
00114 #ifndef TRUE
00115 #define TRUE 1
00116 #endif
00117 
00118 #ifdef __cplusplus
00119 }
00120 #endif
00121 
00122 #endif

Generated on Fri Sep 26 07:44:17 2008 for SimTKcore by  doxygen 1.5.6