@@ -1018,26 +1018,40 @@ Transformation::nonlinear_only_numerix(const Py::Tuple & args, const Py::Dict &k
10181018
10191019 double thisx = *(double *)(x->data + i*x->strides [0 ]);
10201020 double thisy = *(double *)(y->data + i*y->strides [0 ]);
1021- try {
1022- this ->nonlinear_only_api (&thisx, &thisy);
1023- }
1024- catch (...) {
1025-
1021+ if (MPL_isnan64 (thisx) || MPL_isnan64 (thisy)) {
10261022 if (returnMask) {
10271023 *(unsigned char *)(retmask->data + i*retmask->strides [0 ]) = 0 ;
1028- *(double *)(retx->data + i*retx->strides [0 ]) = 0.0 ;
1029- *(double *)(rety->data + i*rety->strides [0 ]) = 0.0 ;
1030- continue ;
10311024 }
1032- else {
1033- throw Py::ValueError (" Domain error on this->nonlinear_only_api(&thisx, &thisy) in Transformation::nonlinear_only_numerix" );
1025+ double MPLnan; // don't require C99 math features - find our own nan
1026+ if (MPL_isnan64 (thisx)) {
1027+ MPLnan=thisx;
1028+ } else {
1029+ MPLnan=thisy;
1030+ }
1031+ *(double *)(retx->data + i*retx->strides [0 ]) = MPLnan;
1032+ *(double *)(rety->data + i*rety->strides [0 ]) = MPLnan;
1033+ } else {
1034+ try {
1035+ this ->nonlinear_only_api (&thisx, &thisy);
1036+ }
1037+ catch (...) {
1038+
1039+ if (returnMask) {
1040+ *(unsigned char *)(retmask->data + i*retmask->strides [0 ]) = 0 ;
1041+ *(double *)(retx->data + i*retx->strides [0 ]) = 0.0 ;
1042+ *(double *)(rety->data + i*rety->strides [0 ]) = 0.0 ;
1043+ continue ;
1044+ }
1045+ else {
1046+ throw Py::ValueError (" Domain error on this->nonlinear_only_api(&thisx, &thisy) in Transformation::nonlinear_only_numerix" );
1047+ }
10341048 }
1035- }
10361049
1037- *(double *)(retx->data + i*retx->strides [0 ]) = thisx;
1038- *(double *)(rety->data + i*rety->strides [0 ]) = thisy;
1039- if (returnMask) {
1040- *(unsigned char *)(retmask->data + i*retmask->strides [0 ]) = 1 ;
1050+ *(double *)(retx->data + i*retx->strides [0 ]) = thisx;
1051+ *(double *)(rety->data + i*rety->strides [0 ]) = thisy;
1052+ if (returnMask) {
1053+ *(unsigned char *)(retmask->data + i*retmask->strides [0 ]) = 1 ;
1054+ }
10411055 }
10421056
10431057 }
0 commit comments