Removed unnecessary MIN and MAX macros

This commit is contained in:
Ray Speth 2013-04-29 18:05:10 +00:00
parent 0a059d406a
commit 7d79b30c27
5 changed files with 17 additions and 43 deletions

View file

@ -26,6 +26,7 @@
#include <math.h>
#include <float.h>
#include <limits.h>
#include <algorithm>
#include "cantera/base/config.h"
#ifndef _MSC_VER
#include <unistd.h>
@ -41,13 +42,6 @@ using namespace std;
#include "mdp_allo.h"
//#include "cantera/base/mdp_allo.h"
#include "tok_input_util.h"
#ifndef MAX
# define MAX(x,y) (( (x) > (y) ) ? (x) : (y))
#endif
#ifndef MIN
# define MIN(x,y) (( (x) < (y) ) ? (x) : (y))
#endif
int Debug_Flag = true;
double grtol = 1.0E-3;
@ -796,8 +790,8 @@ int main(int argc, char* argv[])
* Right now, if the number of data rows differ, we will punt.
* Maybe later we can do something more significant
*/
int nDataRowsMIN = MIN(nDataRows1, nDataRows2);
int nDataRowsMAX = MAX(nDataRows1, nDataRows2);
int nDataRowsMIN = min(nDataRows1, nDataRows2);
int nDataRowsMAX = max(nDataRows1, nDataRows2);
if (nDataRows1 != nDataRows2) {
printf("Number of Data rows in file1, %d, is different than file2, %d\n",
nDataRows1, nDataRows2);
@ -811,7 +805,7 @@ int main(int argc, char* argv[])
read_title(fp2, &title2, nTitleLines2);
if (nTitleLines1 > 0 || nTitleLines2 > 0) {
int n = MIN(nTitleLines1, nTitleLines2);
int n = min(nTitleLines1, nTitleLines2);
for (i = 0; i < n; i++) {
if (strcmp(title1[i], title2[i]) != 0) {
printf("Title Line %d differ:\n\t\"%s\"\n\t\"%s\"\n", i, title1[i], title2[i]);
@ -864,7 +858,7 @@ int main(int argc, char* argv[])
* Do a Comparison of the names to find the maximum number
* of matches.
*/
nColMAX = MAX(nCol1, nCol2);
nColMAX = max(nCol1, nCol2);
compColList = mdp_alloc_int_2(nColMAX, 2, -1);
nColcomparisons = 0;
@ -945,7 +939,7 @@ int main(int argc, char* argv[])
curVarValues1 = NVValues1[i1];
curVarValues2 = NVValues2[i2];
atol_j = get_atol(curVarValues1, nDataRows1, gatol);
atol_j = MIN(atol_j, get_atol(curVarValues2, nDataRows2, gatol));
atol_j = min(atol_j, get_atol(curVarValues2, nDataRows2, gatol));
for (j = 0; j < nDataRowsMIN; j++) {
slope1 = 0.0;

View file

@ -3,6 +3,7 @@
#include <string.h>
#include <new>
#include <algorithm>
#include <stdarg.h>
#include "mdp_allo.h"
@ -32,13 +33,6 @@ int MDP_MP_myproc = 0;
int MDP_ALLO_errorOption = 3;
#define MDP_ALLOC_INTERFACE_ERROR 230346
#ifndef MAX
# define MAX(x,y) (( (x) > (y) ) ? (x) : (y))
#endif
#ifndef MIN
# define MIN(x,y) (( (x) < (y) ) ? (x) : (y))
#endif
/****************************************************************************/
/****************************************************************************/
@ -989,8 +983,8 @@ void mdp_realloc_dbl_2(double** *array_hdl, int ndim1, int ndim2,
if (ndim2 <= 0) {
ndim2 = 1;
}
ndim1Old = MAX(ndim1Old, 0);
ndim2Old = MAX(ndim2Old, 0);
ndim1Old = std::max(ndim1Old, 0);
ndim2Old = std::max(ndim2Old, 0);
/*
* One way to do it, if old information isn't needed. In this algorithm
* the arrays are never malloced at the same time.
@ -1014,8 +1008,8 @@ void mdp_realloc_dbl_2(double** *array_hdl, int ndim1, int ndim2,
/*
* Now, let's initialize the arrays
*/
int ndim1Min = MIN(ndim1, ndim1Old);
int ndim2Min = MIN(ndim2, ndim2Old);
int ndim1Min = std::min(ndim1, ndim1Old);
int ndim2Min = std::min(ndim2, ndim2Old);
double** array_new = *array_hdl;
/*
* When the second dimensions are equal, we can copy blocks
@ -1150,7 +1144,7 @@ void mdp_realloc_VecFixedStrings(char** *array_hdl, int numStrings,
}
array = (char**) mdp_array_alloc(2, numStrings, lenString, sizeof(char));
if (array != NULL) {
int len = MIN(numStrings, numOldStrings);
int len = std::min(numStrings, numOldStrings);
ao = *array_hdl;
if (ao) {
for (i = 0; i < len; i++) {
@ -1414,7 +1408,7 @@ void mdp_realloc_ptr_1(void** *array_hdl, int numLen, int numOldLen)
size_t bytenum = sizeof(void*) * numLen;
void** array = (void**) smalloc(bytenum);
if (array != NULL) {
int len = MIN(numLen, numOldLen);
int len = std::min(numLen, numOldLen);
if (*array_hdl) {
void** ao = *array_hdl;
for (int i = 0; i < len; i++) {

View file

@ -17,10 +17,6 @@
#include <cmath>
#include <iostream>
#ifndef MAX
#define MAX(x,y) (( (x) > (y) ) ? (x) : (y))
#endif
using namespace std;
namespace VCSnonideal
@ -80,7 +76,7 @@ int VCS_SOLVE::vcs_setMolesLinProg()
for (ik = 0; ik < m_numSpeciesTot; ik++) {
if (m_speciesUnknownType[ik] != VCS_SPECIES_INTERFACIALVOLTAGE) {
m_molNumSpecies_old[ik] = MAX(0.0, m_molNumSpecies_old[ik]);
m_molNumSpecies_old[ik] = max(0.0, m_molNumSpecies_old[ik]);
}
}
@ -180,14 +176,14 @@ int VCS_SOLVE::vcs_setMolesLinProg()
// Redo the iteration, if a component went from positive to zero on this step.
double dsLocal = idir*dxi_min;
m_molNumSpecies_old[ik] += dsLocal;
m_molNumSpecies_old[ik] = MAX(0.0, m_molNumSpecies_old[ik]);
m_molNumSpecies_old[ik] = max(0.0, m_molNumSpecies_old[ik]);
for (size_t jcomp = 0; jcomp < m_numComponents; jcomp++) {
bool full = false;
if (m_molNumSpecies_old[jcomp] > 1.0E-15) {
full = true;
}
m_molNumSpecies_old[jcomp] += sc_irxn[jcomp] * dsLocal;
m_molNumSpecies_old[jcomp] = MAX(0.0, m_molNumSpecies_old[jcomp]);
m_molNumSpecies_old[jcomp] = max(0.0, m_molNumSpecies_old[jcomp]);
if (full) {
if (m_molNumSpecies_old[jcomp] < 1.0E-60) {
redo = true;

View file

@ -25,10 +25,6 @@
using namespace std;
using namespace Cantera;
#ifndef MAX
#define MAX(x,y) (( (x) > (y) ) ? (x) : (y))
#endif
namespace VCSnonideal
{
@ -55,7 +51,7 @@ void VCS_SOLVE::checkDelta1(double* const dsLocal,
}
}
for (size_t iphase = 0; iphase < m_numPhases; iphase++) {
double denom = MAX(m_totalMolNum, 1.0E-4);
double denom = max(m_totalMolNum, 1.0E-4);
if (!vcs_doubleEqual(dchange[iphase]/denom, delTPhMoles[iphase]/denom)) {
plogf("checkDelta1: we have found a problem\n");
exit(EXIT_FAILURE);

View file

@ -26,12 +26,6 @@
using namespace std;
#define MAX(x,y) (( (x) > (y) ) ? (x) : (y))
/*****************************************************************/
/*****************************************************************/
#include "cantera/transport.h"
#include "cantera/IdealGasMix.h"
#include "cantera/transport/TransportFactory.h"