#include <string.h>
#include "luksan.h"
-#define max(a,b) ((a) > (b) ? (a) : (b))
-#define min(a,b) ((a) < (b) ? (a) : (b))
+#define MAX2(a,b) ((a) > (b) ? (a) : (b))
+#define MIN2(a,b) ((a) < (b) ? (a) : (b))
/* *********************************************************************** */
/* SUBROUTINE PLIS ALL SYSTEMS 01/09/22 */
}
/* Computing MIN */
i__1 = stat_1->nit - kit;
- k = min(i__1,*mf);
+ k = MIN2(i__1,*mf);
if (k <= 0) {
- irest = max(irest,1);
+ irest = MAX2(irest,1);
goto L12620;
}
b = luksan_mxudot__(nf, &xo[1], &go[1], &ix[1], &kbf);
if (b <= 0.) {
- irest = max(irest,1);
+ irest = MAX2(irest,1);
goto L12620;
}
uo[1] = 1. / b;
snorm = sqrt(luksan_mxudot__(nf, &s[1], &s[1], &ix[1], &kbf));
/* Computing MIN */
i__1 = k + 1;
- k = min(i__1,*mf);
+ k = MIN2(i__1,*mf);
luksan_mxdrsu__(nf, &k, &xo[1], &go[1], &uo[1]);
L12620:
iterd = 0;
/* TEST ON DESCENT DIRECTION */
if (snorm <= 0.) {
- irest = max(irest,1);
+ irest = MAX2(irest,1);
} else if (p + told * gnorm * snorm <= 0.) {
irest = 0;
} else {
/* UNIFORM DESCENT CRITERION */
- irest = max(irest,1);
+ irest = MAX2(irest,1);
}
if (irest == 0) {
rmin = alf1 * gnorm / snorm;
/* Computing MIN */
d__1 = alf2 * gnorm / snorm, d__2 = *xmax / snorm;
- rmax = min(d__1,d__2);
+ rmax = MIN2(d__1,d__2);
}
}
if (*iterm != 0) {
p = po;
luksan_mxvcop__(nf, &xo[1], &x[1]);
luksan_mxvcop__(nf, &go[1], &gf[1]);
- irest = max(irest,1);
+ irest = MAX2(irest,1);
ld = kd;
goto L11130;
}
and we'll assume that the main limiting factor is the memory.
We'll assume that at least MEMAVAIL memory, or 4*n memory, whichever
is bigger, is available. */
- mf = max(MEMAVAIL/n, 4);
+ mf = MAX2(MEMAVAIL/n, 4);
if (stop->maxeval && stop->maxeval <= mf)
- mf = max(stop->maxeval - 5, 1); /* mf > maxeval seems not good */
+ mf = MAX2(stop->maxeval - 5, 1); /* mf > maxeval seems not good */
retry_alloc:
- work = (double*) malloc(sizeof(double) * (n * 4 + max(n,n*mf)*2 +
- max(n,mf)*2));
+ work = (double*) malloc(sizeof(double) * (n * 4 + MAX2(n,n*mf)*2 +
+ MAX2(n,mf)*2));
if (!work) {
if (mf > 0) {
mf = 0; /* allocate minimal memory */
}
xl = work; xu = xl + n; gf = xu + n; s = gf + n;
- xo = s + n; go = xo + max(n,n*mf);
- uo = go + max(n,n*mf); vo = uo + max(n,mf);
+ xo = s + n; go = xo + MAX2(n,n*mf);
+ uo = go + MAX2(n,n*mf); vo = uo + MAX2(n,mf);
for (i = 0; i < n; ++i) {
int lbu = lb[i] <= -0.99 * HUGE_VAL; /* lb unbounded */
original Fortran code, but it is used upon
input to plis if mf > 0 ... perhaps ALLOCATE initializes
arrays to zero by default? */
- memset(xo, 0, sizeof(double) * max(n,n*mf));
+ memset(xo, 0, sizeof(double) * MAX2(n,n*mf));
plis_(&n, &nb, x, ix, xl, xu,
gf, s, xo, go, uo, vo,