1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
/*******************************************************************
Copyright (C) 2017 AMPL Optimization, Inc.; written by David M. Gay.
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that the copyright notice and this permission notice and warranty
disclaimer appear in supporting documentation.
The author and AMPL Optimization, Inc. disclaim all warranties with
regard to this software, including all implied warranties of
merchantability and fitness. In no event shall the author be liable
for any special, indirect or consequential damages or any damages
whatsoever resulting from loss of use, data or profits, whether in an
action of contract, negligence or other tortious action, arising out
of or in connection with the use or performance of this software.
*******************************************************************/
#include "jac2dim.h"
int
x2_check_ASL(ASL_fgh *asl, real *X)
{
expr_v *V;
int *vm;
real *Xe, *vscale;
if (x0len == 0) {
x0kind = 0;
return 0;
}
if (x0kind == ASL_first_x || memcmp(Lastx, X, x0len)) {
if (asl->i.Derrs)
deriv_errclear_ASL(&asl->i);
want_deriv = want_derivs;
memcpy(Lastx, X, x0len);
asl->i.nxval++;
V = var_e;
Xe = (real*)((char*)X + x0len);
vscale = asl->i.vscale;
if ((vm = asl->i.vmap)) {
if (vscale)
while(X < Xe)
V[*vm++].v = *vscale++ * *X++;
else
while(X < Xe)
V[*vm++].v = *X++;
}
else {
if (vscale)
while(X < Xe)
(V++)->v = *vscale++ * *X++;
else
while(X < Xe)
(V++)->v = *X++;
}
x0kind = 0;
if (comb)
comeval(asl, 0, comb);
return 1;
}
return 0;
}
int
x2known_ASL(ASL *asl, real *X, fint *nerror)
{
Jmp_buf err_jmp0;
int ij, rc;
ASL_CHECK(asl, ASL_read_fgh, "x2known");
rc = 1;
if (asl->i.xknown_ignore)
goto ret;
if (nerror && *nerror >= 0) {
asl->i.err_jmp_ = &err_jmp0;
ij = setjmp(err_jmp0.jb);
if ((*nerror = ij))
goto done;
}
errno = 0; /* in case f77 set errno opening files */
co_index = nlo ? -1 : 0;
rc = x2_check_ASL((ASL_fgh*)asl, X);
asl->i.x_known = 1;
done:
asl->i.err_jmp_ = 0;
ret:
return rc;
}
|