From 2125f01f97abfe343fc5e0cc078bf1d081b2e441 Mon Sep 17 00:00:00 2001 From: Ian Jauslin Date: Fri, 20 May 2016 20:30:15 +0000 Subject: Initial commit --- src/root_ldouble.h | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/root_ldouble.h (limited to 'src/root_ldouble.h') diff --git a/src/root_ldouble.h b/src/root_ldouble.h new file mode 100644 index 0000000..a20643b --- /dev/null +++ b/src/root_ldouble.h @@ -0,0 +1,55 @@ +/* +Copyright 2016 Ian Jauslin + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/* + Preprocessor macros for root finding using long doubles +*/ + + +// reset CPP macros +#undef ROOT_FUNC +#undef ROOT_FLOAT_TYPE +#undef ROOT_FLOAT_INIT +#undef ROOT_FLOAT_FREE +#undef ROOT_FLOAT_SET +#undef ROOT_FLOAT_SUB +#undef ROOT_FLOAT_DIV +#undef ROOT_FLOAT_CMP +#undef ROOT_FLOAT_ABS +#undef ROOT_FLOAT_ISNUMBER +#undef ROOT_FLOAT_ISZERO + + +// suffix of function names +#define ROOT_FUNC(NAME) NAME ## _ldouble + +// type of floats +#define ROOT_FLOAT_TYPE long double +// set float +#define ROOT_FLOAT_SET(FLOAT, VAL) FLOAT=VAL +// subtract floats +#define ROOT_FLOAT_SUB(FLOAT, VAL1, VAL2) FLOAT=VAL1-VAL2 +// divide floats +#define ROOT_FLOAT_DIV(FLOAT, VAL1, VAL2) FLOAT=VAL1/VAL2 +// compare floats (0 if equal, -1 if <, +1 if >) +#define ROOT_FLOAT_CMP(VAL1, VAL2) VAL1-VAL2 +// abs of float +#define ROOT_FLOAT_ABS(FLOAT, VAL) FLOAT=fabsl(VAL) +// check whether a float is a regular number +#define ROOT_FLOAT_ISNUMBER(FLOAT) (fpclassify(FLOAT)>=FP_ZERO) +// whether float is 0 +#define ROOT_FLOAT_ISZERO(VAL) (VAL==0.) + -- cgit v1.2.3-70-g09d2