2 #ifndef __INTEL_LLVM_COMPILER
4 #pragma float_control(precise, on)
6 #pragma STDC FENV_ACCESS ON
9 #include <../../nrnconf.h>
22 #if NRN_ENABLE_ARCH_INDEP_EXP_POW
26 #define EPS hoc_epsilon
34 #elif defined(NRN_CHECK_FE_EXCEPTIONS)
37 #ifdef math_errhandling
39 static_assert(math_errhandling & MATH_ERREXCEPT);
48 std::feclearexcept(FE_ALL_EXCEPT);
52 static double errcheck(
double,
const char*);
71 #if NRN_ENABLE_ARCH_INDEP_EXP_POW
73 static double accuracy32(
double val) {
75 double mant = frexp(val, &ex);
77 double prec = 4294967296.0;
78 double result = mant * prec;
85 static double pow_arch_indep(
double x,
double y) {
86 mpfr_prec_t prec = 53;
87 mpfr_rnd_t rnd = MPFR_RNDN;
93 mpfr_set_d(
x_, x, rnd);
94 mpfr_set_d(
y_, y, rnd);
98 double r = mpfr_get_d(
x_, rnd);
106 static double exp_arch_indep(
double x) {
107 mpfr_prec_t prec = 53;
108 mpfr_rnd_t rnd = MPFR_RNDN;
111 mpfr_init2(
x_, prec);
112 mpfr_set_d(
x_, x, rnd);
113 mpfr_exp(
x_,
x_, rnd);
114 double r = mpfr_get_d(
x_, rnd);
119 static double pow_precision32(
double x,
double y) {
120 return accuracy32(
pow(x, y));
123 static double exp_precision32(
double x) {
124 return accuracy32(
exp(x));
127 static double (*pow_ptr)(
double x,
double y) =
pow;
128 static double (*pow_ieee_ptr)(
double x,
130 static double (*exp_ptr)(
double x) =
exp;
132 int nrn_use_exp_pow_precision(
int style) {
136 }
else if (style == 1) {
137 pow_ptr = pow_arch_indep;
138 exp_ptr = exp_arch_indep;
139 }
else if (style == 2) {
140 pow_ptr = pow_precision32;
141 exp_ptr = exp_precision32;
151 style =
chkarg(1, 0.0, 2.0);
153 #if NRN_ENABLE_ARCH_INDEP_EXP_POW
154 style = nrn_use_exp_pow_precision(style);
167 #if NRN_ENABLE_ARCH_INDEP_EXP_POW
168 return (*pow_ptr)(x, y);
181 std::feraiseexcept(FE_OVERFLOW);
184 fprintf(stderr,
"exp(%g) out of range, returning exp(700)\n", x);
187 fprintf(stderr,
"No more errno warnings during this execution\n");
192 #if NRN_ENABLE_ARCH_INDEP_EXP_POW
193 return (*exp_ptr)(x);
203 }
else if (x > 700) {
206 std::feraiseexcept(FE_OVERFLOW);
226 return (
double) (long) (x -
EPS);
228 return (
double) (long) (x +
EPS);
242 (std::fetestexcept(FE_DIVBYZERO) || std::fetestexcept(FE_OVERFLOW) ||
243 std::fetestexcept(FE_UNDERFLOW)))) {
250 fprintf(stderr,
"No more errno warnings during this execution\n");
#define y_(arg)
Crout matrix decomposition : Forward/Backward substitution.
double chkarg(int, double low, double high)
double * hoc_getarg(int narg)
int hoc_errno_check(void)
double hoc_pow(double x, double y)
static const auto check_fe_except
void hoc_use_exp_pow_precision()
static const auto errno_enabled
static double errcheck(double, const char *)
double hoc_Sqrt(double x)
static void clear_fe_except()
double hoc_Log10(double x)
double hoc1_Exp(double x)
double hoc_integer(double x)
double hoc_Pow(double x, double y)
void hoc_execerror(const char *s1, const char *s2)
void hoc_warning(const char *s1, const char *s2)
HOC interpreter function declarations (included by hocdec.h)