Revision: 70413 http://sourceforge.net/p/brlcad/code/70413 Author: brlcad Date: 2017-11-21 03:39:46 +0000 (Tue, 21 Nov 2017) Log Message: ----------- restore vmath.h to a stand-alone state dependency-wise, not reliant upon any other cad header. it needs just a little work to make itself independent of system headers.
vmath.h should turn into a proper single-header project. Modified Paths: -------------- brlcad/trunk/include/bu/defines.h brlcad/trunk/include/vmath.h Modified: brlcad/trunk/include/bu/defines.h =================================================================== --- brlcad/trunk/include/bu/defines.h 2017-11-21 03:01:15 UTC (rev 70412) +++ brlcad/trunk/include/bu/defines.h 2017-11-21 03:39:46 UTC (rev 70413) @@ -190,71 +190,6 @@ #endif -/** - * fastf_t - Intended to be the fastest floating point data type on - * the current machine, with at least 64 bits of precision. On 16 and - * 32 bit machines, this is typically "double", but on 64 bit machines, - * it is often "float". Virtually all floating point variables (and - * more complicated data types, like vect_t and mat_t) are defined as - * fastf_t. The one exception is when a subroutine return is a - * floating point value; that is always declared as "double". - * - * TODO: If used pervasively, it should eventually be possible to make - * fastf_t a GMP C++ type for fixed-precision computations. - */ -typedef double fastf_t; - -/** - * Definitions about limits of floating point representation - * Eventually, should be tied to type of hardware (IEEE, IBM, Cray) - * used to implement the fastf_t type. - * - * MAX_FASTF - Very close to the largest value that can be held by a - * fastf_t without overflow. Typically specified as an integer power - * of ten, to make the value easy to spot when printed. TODO: macro - * function syntax instead of constant (DEPRECATED) - * - * SQRT_MAX_FASTF - sqrt(MAX_FASTF), or slightly smaller. Any number - * larger than this, if squared, can be expected to * produce an - * overflow. TODO: macro function syntax instead of constant - * (DEPRECATED) - * - * SMALL_FASTF - Very close to the smallest value that can be - * represented while still being greater than zero. Any number - * smaller than this (and non-negative) can be considered to be - * zero; dividing by such a number can be expected to produce a - * divide-by-zero error. All divisors should be checked against - * this value before actual division is performed. TODO: macro - * function syntax instead of constant (DEPRECATED) - * - * SQRT_SMALL_FASTF - sqrt(SMALL_FASTF), or slightly larger. The - * value of this is quite a lot larger than that of SMALL_FASTF. Any - * number smaller than this, when squared, can be expected to produce - * a zero result. TODO: macro function syntax instead of constant - * (DEPRECATED) - * - */ -#if defined(vax) -/* DEC VAX "D" format, the most restrictive */ -# define MAX_FASTF 1.0e37 /* Very close to the largest number */ -# define SQRT_MAX_FASTF 1.0e18 /* This squared just avoids overflow */ -# define SMALL_FASTF 1.0e-37 /* Anything smaller is zero */ -# define SQRT_SMALL_FASTF 1.0e-18 /* This squared gives zero */ -#else -/* IBM format, being the next most restrictive format */ -# define MAX_FASTF 1.0e73 /* Very close to the largest number */ -# define SQRT_MAX_FASTF 1.0e36 /* This squared just avoids overflow */ -# define SMALL_FASTF 1.0e-77 /* Anything smaller is zero */ -# if defined(aux) -# define SQRT_SMALL_FASTF 1.0e-40 /* _doprnt error in libc */ -# else -# define SQRT_SMALL_FASTF 1.0e-39 /* This squared gives zero */ -# endif -#endif - -/** DEPRECATED, do not use */ -#define SMALL SQRT_SMALL_FASTF - /** @} */ #endif /* BU_DEFINES_H */ Modified: brlcad/trunk/include/vmath.h =================================================================== --- brlcad/trunk/include/vmath.h 2017-11-21 03:01:15 UTC (rev 70412) +++ brlcad/trunk/include/vmath.h 2017-11-21 03:39:46 UTC (rev 70413) @@ -102,11 +102,11 @@ /* for floating point tolerances and other math constants */ #include <float.h> -/* for fastf_t */ -#include "bu/defines.h" +#ifdef __cplusplus +extern "C" { +#endif -__BEGIN_DECLS #ifndef M_ # define M_ XXX /**< all with 36-digits of precision */ @@ -182,6 +182,57 @@ /** + * Definitions about limits of floating point representation + * Eventually, should be tied to type of hardware (IEEE, IBM, Cray) + * used to implement the fastf_t type. + * + * MAX_FASTF - Very close to the largest value that can be held by a + * fastf_t without overflow. Typically specified as an integer power + * of ten, to make the value easy to spot when printed. TODO: macro + * function syntax instead of constant (DEPRECATED) + * + * SQRT_MAX_FASTF - sqrt(MAX_FASTF), or slightly smaller. Any number + * larger than this, if squared, can be expected to * produce an + * overflow. TODO: macro function syntax instead of constant + * (DEPRECATED) + * + * SMALL_FASTF - Very close to the smallest value that can be + * represented while still being greater than zero. Any number + * smaller than this (and non-negative) can be considered to be + * zero; dividing by such a number can be expected to produce a + * divide-by-zero error. All divisors should be checked against + * this value before actual division is performed. TODO: macro + * function syntax instead of constant (DEPRECATED) + * + * SQRT_SMALL_FASTF - sqrt(SMALL_FASTF), or slightly larger. The + * value of this is quite a lot larger than that of SMALL_FASTF. Any + * number smaller than this, when squared, can be expected to produce + * a zero result. TODO: macro function syntax instead of constant + * (DEPRECATED) + * + */ +#if defined(vax) +/* DEC VAX "D" format, the most restrictive */ +# define MAX_FASTF 1.0e37 /* Very close to the largest number */ +# define SQRT_MAX_FASTF 1.0e18 /* This squared just avoids overflow */ +# define SMALL_FASTF 1.0e-37 /* Anything smaller is zero */ +# define SQRT_SMALL_FASTF 1.0e-18 /* This squared gives zero */ +#else +/* IBM format, being the next most restrictive format */ +# define MAX_FASTF 1.0e73 /* Very close to the largest number */ +# define SQRT_MAX_FASTF 1.0e36 /* This squared just avoids overflow */ +# define SMALL_FASTF 1.0e-77 /* Anything smaller is zero */ +# if defined(aux) +# define SQRT_SMALL_FASTF 1.0e-40 /* _doprnt error in libc */ +# else +# define SQRT_SMALL_FASTF 1.0e-39 /* This squared gives zero */ +# endif +#endif + +/** DEPRECATED, do not use */ +#define SMALL SQRT_SMALL_FASTF + +/** * It is necessary to have a representation of 1.0/0.0 or log(0), * i.e., "infinity" that fits within the dynamic range of the machine * being used. This constant places an upper bound on the size object @@ -261,6 +312,20 @@ * Types for matrices and vectors. */ +/** + * fastf_t - Intended to be the fastest floating point data type on + * the current machine, with at least 64 bits of precision. On 16 and + * 32 bit machines, this is typically "double", but on 64 bit machines, + * it is often "float". Virtually all floating point variables (and + * more complicated data types, like vect_t and mat_t) are defined as + * fastf_t. The one exception is when a subroutine return is a + * floating point value; that is always declared as "double". + * + * TODO: If used pervasively, it should eventually be possible to make + * fastf_t a GMP C++ type for fixed-precision computations. + */ +typedef double fastf_t; + /** @brief 2-tuple vector */ typedef fastf_t vect2d_t[ELEMENTS_PER_VECT2D]; @@ -2138,8 +2203,11 @@ */ #define MAT_INIT_ZERO {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0} -__END_DECLS +#ifdef __cplusplus +} /* end extern "C" */ +#endif + #endif /* VMATH_H */ /** @} */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ BRL-CAD Source Commits mailing list brlcad-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/brlcad-commits