sundials_math.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 D. Cohen, Alan C. Hindmarsh 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 is the header file for a simple C-language math library. The
00015  * routines listed here work with the type realtype as defined in
00016  * the header file sundials_types.h.
00017  * -----------------------------------------------------------------
00018  */
00019 
00020 #ifndef _SUNDIALSMATH_H
00021 #define _SUNDIALSMATH_H
00022 
00023 #ifdef __cplusplus  /* wrapper to enable C++ usage */
00024 extern "C" {
00025 #endif
00026 
00027 #include <sundials/sundials_types.h>
00028 
00029 /*
00030  * -----------------------------------------------------------------
00031  * Macros : MIN and MAX
00032  * -----------------------------------------------------------------
00033  * MIN(A,B) returns the minimum of A and B
00034  *
00035  * MAX(A,B) returns the maximum of A and B
00036  *
00037  * SQR(A) returns A^2
00038  * -----------------------------------------------------------------
00039  */
00040 
00041 #ifndef MIN
00042 #define MIN(A, B) ((A) < (B) ? (A) : (B))
00043 #endif
00044 
00045 #ifndef MAX
00046 #define MAX(A, B) ((A) > (B) ? (A) : (B))
00047 #endif
00048 
00049 #ifndef SQR
00050 #define SQR(A) ((A)*(A))
00051 #endif
00052 
00053 #ifndef ABS
00054 #define ABS RAbs
00055 #endif
00056 
00057 #ifndef SQRT
00058 #define SQRT RSqrt
00059 #endif
00060 
00061 #ifndef EXP
00062 #define EXP RExp
00063 #endif
00064 
00065 /*
00066  * -----------------------------------------------------------------
00067  * Function : RPowerI
00068  * -----------------------------------------------------------------
00069  * Usage : int exponent;
00070  *         realtype base, ans;
00071  *         ans = RPowerI(base,exponent);
00072  * -----------------------------------------------------------------
00073  * RPowerI returns the value of base^exponent, where base is of type
00074  * realtype and exponent is of type int.
00075  * -----------------------------------------------------------------
00076  */
00077 
00078 SUNDIALS_EXPORT realtype RPowerI(realtype base, int exponent);
00079 
00080 /*
00081  * -----------------------------------------------------------------
00082  * Function : RPowerR
00083  * -----------------------------------------------------------------
00084  * Usage : realtype base, exponent, ans;
00085  *         ans = RPowerR(base,exponent);
00086  * -----------------------------------------------------------------
00087  * RPowerR returns the value of base^exponent, where both base and
00088  * exponent are of type realtype. If base < ZERO, then RPowerR
00089  * returns ZERO.
00090  * -----------------------------------------------------------------
00091  */
00092 
00093 SUNDIALS_EXPORT realtype RPowerR(realtype base, realtype exponent);
00094 
00095 /*
00096  * -----------------------------------------------------------------
00097  * Function : RSqrt
00098  * -----------------------------------------------------------------
00099  * Usage : realtype sqrt_x;
00100  *         sqrt_x = RSqrt(x);
00101  * -----------------------------------------------------------------
00102  * RSqrt(x) returns the square root of x. If x < ZERO, then RSqrt
00103  * returns ZERO.
00104  * -----------------------------------------------------------------
00105  */
00106 
00107 SUNDIALS_EXPORT realtype RSqrt(realtype x);
00108 
00109 /*
00110  * -----------------------------------------------------------------
00111  * Function : RAbs (a.k.a. ABS)
00112  * -----------------------------------------------------------------
00113  * Usage : realtype abs_x;
00114  *         abs_x = RAbs(x);
00115  * -----------------------------------------------------------------
00116  * RAbs(x) returns the absolute value of x.
00117  * -----------------------------------------------------------------
00118  */
00119 
00120 SUNDIALS_EXPORT realtype RAbs(realtype x);
00121 
00122 /*
00123  * -----------------------------------------------------------------
00124  * Function : RExp (a.k.a. EXP)
00125  * -----------------------------------------------------------------
00126  * Usage : realtype exp_x;
00127  *         exp_x = RExp(x);
00128  * -----------------------------------------------------------------
00129  * RExp(x) returns e^x (base-e exponential function).
00130  * -----------------------------------------------------------------
00131  */
00132 
00133 SUNDIALS_EXPORT realtype RExp(realtype x);
00134 
00135 #ifdef __cplusplus
00136 }
00137 #endif
00138 
00139 #endif

Generated on Thu Aug 12 16:37:27 2010 for SimTKcore by  doxygen 1.6.1