|
| 1 | +/*========================================================================= |
| 2 | + * |
| 3 | + * Copyright NumFOCUS |
| 4 | + * |
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | + * you may not use this file except in compliance with the License. |
| 7 | + * You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * https://www.apache.org/licenses/LICENSE-2.0.txt |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + * |
| 17 | + *=========================================================================*/ |
| 18 | + |
| 19 | +/* FEM-private copy of the EISPACK epslon routine, renamed to itkfem_epslon_. |
| 20 | + * v3p_netlib drops eispack under ITK_FUTURE_LEGACY_REMOVE, but the itk::fem |
| 21 | + * ITPACK solver (dsrc2c.c) still needs it, so FEM owns a self-contained copy |
| 22 | + * in every configuration. */ |
| 23 | + |
| 24 | +#include "itkfem_eispack.h" |
| 25 | +#ifdef __cplusplus |
| 26 | +extern "C" |
| 27 | +{ |
| 28 | +#endif |
| 29 | + typedef double doublereal; |
| 30 | +#ifndef abs |
| 31 | +# define abs(x) ((x) >= 0 ? (x) : -(x)) |
| 32 | +#endif |
| 33 | + |
| 34 | + /*< double precision function epslon (x) >*/ |
| 35 | + doublereal |
| 36 | + itkfem_epslon_(doublereal * x) |
| 37 | + { |
| 38 | + /* System generated locals */ |
| 39 | + doublereal ret_val, d__1; |
| 40 | + |
| 41 | + /* Local variables */ |
| 42 | + doublereal a, b, c__, eps; |
| 43 | + |
| 44 | + /*< double precision x >*/ |
| 45 | + |
| 46 | + /* estimate unit roundoff in quantities of size x. */ |
| 47 | + |
| 48 | + /*< double precision a,b,c,eps >*/ |
| 49 | + |
| 50 | + /* this program should function properly on all systems */ |
| 51 | + /* satisfying the following two assumptions, */ |
| 52 | + /* 1. the base used in representing floating point */ |
| 53 | + /* numbers is not a power of three. */ |
| 54 | + /* 2. the quantity a in statement 10 is represented to */ |
| 55 | + /* the accuracy used in floating point variables */ |
| 56 | + /* that are stored in memory. */ |
| 57 | + /* the statement number 10 and the go to 10 are intended to */ |
| 58 | + /* force optimizing compilers to generate code satisfying */ |
| 59 | + /* assumption 2. */ |
| 60 | + /* under these assumptions, it should be true that, */ |
| 61 | + /* a is not exactly equal to four-thirds, */ |
| 62 | + /* b has a zero for its last bit or digit, */ |
| 63 | + /* c is not exactly equal to one, */ |
| 64 | + /* eps measures the separation of 1.0 from */ |
| 65 | + /* the next larger floating point number. */ |
| 66 | + /* the developers of eispack would appreciate being informed */ |
| 67 | + /* about any systems where these assumptions do not hold. */ |
| 68 | + |
| 69 | + /* this version dated 4/6/83. */ |
| 70 | + |
| 71 | + /*< a = 4.0d0/3.0d0 >*/ |
| 72 | + a = 1.3333333333333333; |
| 73 | + /*< 10 b = a - 1.0d0 >*/ |
| 74 | + L10: |
| 75 | + b = a - 1.; |
| 76 | + /*< c = b + b + b >*/ |
| 77 | + c__ = b + b + b; |
| 78 | + /*< eps = dabs(c-1.0d0) >*/ |
| 79 | + eps = (d__1 = c__ - 1., abs(d__1)); |
| 80 | + /*< if (eps .eq. 0.0d0) go to 10 >*/ |
| 81 | + if (eps == 0.) |
| 82 | + { |
| 83 | + goto L10; |
| 84 | + } |
| 85 | + /*< epslon = eps*dabs(x) >*/ |
| 86 | + ret_val = eps * abs(*x); |
| 87 | + /*< return >*/ |
| 88 | + return ret_val; |
| 89 | + /*< end >*/ |
| 90 | + } /* itkfem_epslon_ */ |
| 91 | + |
| 92 | +#ifdef __cplusplus |
| 93 | +} |
| 94 | +#endif |
0 commit comments