Main Page | Class Hierarchy | Class List | File List | Class Members | Related Pages

steamcalculator_macros.h

00001 /* 00002 00003 freesteam - IAPWS-IF97 steam tables library 00004 Copyright (C) 2004-2005 John Pye 00005 00006 This program is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU General Public License 00008 as published by the Free Software Foundation; either version 2 00009 of the License, or (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00019 00020 */ 00021 00022 //------------------------------------------------------------------------- 00023 // These #defines set up some series-evaluation and debug-output functions 00024 00025 #include "isinfnan.h" 00026 00027 // Output messages and expression debug stuff 00028 00029 #define SHOW_STRVAL(EXPR) \ 00030 printf("NOTE: "); \ 00031 for(int xprloop=0;xprloop<expr_func_level;xprloop++){ \ 00032 printf(" "); \ 00033 } \ 00034 printf("%s = %s\n",#EXPR,(EXPR)); 00035 00036 #define SHOW_VALUE_LABEL(EXPR,LABEL) \ 00037 { \ 00038 printf("NOTE: "); \ 00039 for(int xprloop=0;xprloop<expr_func_level;xprloop++){ \ 00040 printf(" "); \ 00041 } \ 00042 printf("%s = %8.5e\n",#LABEL,(Num)(EXPR)); \ 00043 } 00044 00045 #define SHOW_VALUE(EXPR) SHOW_VALUE_LABEL((EXPR),(EXPR)) 00046 00047 00048 // create a function which returns an evaluated series expression within a class 00049 #define LOOP_SUM_FUNC(CLASSNAME,FUNCNAME,EXPR,LOOPMAX) \ 00050 Num CLASSNAME::FUNCNAME(){ \ 00051 Num s=0; \ 00052 for(int i=0;i<LOOPMAX;i++){\ 00053 s+=(EXPR); \ 00054 } \ 00055 return s; \ 00056 } 00057 00058 // create a function which returns an evaluated series expression within a class 00059 // and passes SteamCalculator object 00060 #define LOOP_SUM_FUNC_OBJ(CLASSNAME,FUNCNAME,EXPR,LOOPMAX) \ 00061 Num CLASSNAME::FUNCNAME(const SteamCalculator &c) const{ \ 00062 Num s=0; \ 00063 for(int i=0;i<LOOPMAX;i++){\ 00064 s+=(EXPR); \ 00065 } \ 00066 ENSURE(!isnan(s)); \ 00067 ENSURE(!isinf(s)); \ 00068 return s; \ 00069 } 00070 00071 // create a function which returns an evaluated expression within a class 00072 #define EXPR_FUNC(CLASSNAME,FUNC,EXPR) \ 00073 Num CLASSNAME::FUNC() const{ \ 00074 Num FUNC=0; \ 00075 FUNC=(EXPR); \ 00076 return FUNC; \ 00077 } 00078 00079 // create a function which returns an evaluated expression within a class 00080 // ... passing in a SteamCalculator object with parameters 00081 #define EXPR_FUNC_OBJ(CLASSNAME,FUNC,EXPR,TYPE) \ 00082 TYPE CLASSNAME::FUNC(const SteamCalculator &c) const{ \ 00083 TYPE FUNC=(EXPR); \ 00084 ENSURE(!isinf(FUNC)); \ 00085 ENSURE(!isnan(FUNC)); \ 00086 return FUNC; \ 00087 } 00088 00089 // this one adds a simple expresssion plus a series expression with control over the loop limits 00090 #define EXPR_LOOP_SUM_FUNC_OBJ(CLASSNAME,FUNCNAME,EXT_EXPR,LOOP_EXPR,LOOP_START,LOOPMAX) \ 00091 Num CLASSNAME::FUNCNAME(const SteamCalculator &c) const{ \ 00092 Num s=(EXT_EXPR); \ 00093 for(int i=(LOOP_START);i<(LOOPMAX);i++){\ 00094 s+=(LOOP_EXPR); \ 00095 } \ 00096 return s; \ 00097 }

Generated on Tue Mar 22 19:07:05 2005 for freesteam by doxygen 1.3.8